Closed yogiben closed 8 years ago
Have you tried catching the error on the client?
client.on('error', function(err) {
// handle client errors here
console.log(err);
});
@unusualbob good idea.
I thought the error would be logged by
client.on('ready', function() {
client.get('invoices', function(err, invoices) {
console.log(err || invoices);
});
});
the error is { error: 'Unauthorized sin' }
.
@unusualbob is there a list of error messages anywhere?
Googling unauthorized sin
does not return so much
unauthorized sin is a bitpay specific error that indicates there is a problem with your private key. How did you generate your private key?
@yogiben no we don't publish a list of our error messages. It's possible you haven't paired with your account, maybe?
@yogiben what @ionux said seems like the most likely cause. If you did not go through the steps in the CLI tutorial to pair your key with your bitpay account (and if you don't have an account on either bitpay.com or test.bitpay.com) then your private key will not be authorized. The "SIN" is an identification number that is created from your public key, and must be associated with your account through the pairing process. The ruby client guide has a short section on authentication that you might find helpful.
@philosodad @ionux
I followed the steps in this repo's readme:
bitpay keygen
bitpay pair
I pair the key (confirmed on my Bitpay dashboard) and am able to successfully return invoices with the example command
bitpay request -T merchant -R invoices -P '{"dateStart":"2014-01-01"}'
I initialize in my project
var bitpay = require('bitpay');
var privkey = fs.readFileSync('path/to/private.key');
var client = bitpay.createClient(privkey);
and log the error
client.on('error', function(err) {
// handle client errors here
console.log(err);
});
Logging the output of the command
{ domain: null,
_events: {},
_maxListeners: 10,
defaults:
{ getTokens: true,
signRequests: true,
config:
{ apiHost: 'bitpay.com',
apiPort: 443,
forceSSL: true } },
options:
{ getTokens: true,
signRequests: true,
config:
{ apiHost: 'bitpay.com',
apiPort: 443,
forceSSL: true } },
privkey: <Buffer 12 34 ...>,
tokens: {},
apiHost: 'bitpay.com',
apiPort: 443,
facade: 'merchant' }
I'm gone through the setup multiple times.
The pairing should definitely have worked as I'm able to successfully make requests with the cli.
@ionux who's currently maintaining this for bitpay?
@yogiben send an email to support@bitpay.com and a ticket will be routed to the correct engineer.
https://github.com/bitpay/node-bitpay-client/pull/73 fixes an issue regarding utf-8 and has performance improvements.
However I think the problem here is that path/to/private.key
is likely encrypted, and needs to be decrypted first, similar to: https://github.com/bitpay/node-bitpay-client/blob/master/lib/cli-utils.js#L13
@ionux Bitpay support have been unhelpful so far. It's taken over a week since the first request and they haven't connected me with anyone technical yet.
This is a video of my interpretation of the walkthrough:
I'd be very curious to see someone set up a working example.
@braydonf I tried using the latest commit but got the same error.
I've opened a pull request with better documentation, can you take a look at that and let me know if it helps? You can view it here on my fork: https://github.com/unusualbob/node-bitpay-client/blob/betterReadme/README.md#module
Followed tutorial
the app crashes with the following error message