Skip to content

Keys not working after a while, nonce seems to be the issue. Add expire parameter ? #17

@NewCompte

Description

@NewCompte

Hi,

We have been using your library on one of our servers. We keep having to make new keys because the old one stops working.

I have tested the following change with an old key and it works again:

  function setExpire(url) {
    var expireTime = String(Math.floor(Date.now()/1000) + 15);
    if (url.indexOf("?") > -1) {
      return url + '&expire=' + expireTime;
    }
    return url + '?expire=' + expireTime;
  }

  function get (url, callback) {
    url = setExpire(url);

(...)

  function post (url, param, callback) {
    url = setExpire(url);

Doc on expire feature:

https://developers.coinbase.com/docs/wallet/authentication

Out-of-order Processing

Sometimes network traffic can cause near-simultaneous API calls to arrive out of order. Since the nonce must always be increasing, an API call with a higher nonce may arrive earlier than a separate call with a lower nonce if they are initiated very quickly together. When this happens, the 2nd call will be dropped as invalid. To address this, a separate expire parameter can be included, specifying a unix timestamp after which the call will not process.

When the expire parameter is included, the nonce is ignored. We recommend setting the expire parameter to no greater than 15 minutes in the future to prevent replay attempts.

Example

GET https://coinbase.com/api/v1/account/balance?expire=1406139548

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions