btcpayserver: BitPay Node.JS Client error interacting with BTCPayServer "no-bitid"
I’ve successfully paired the Bitpay Node.JS client with my local instance of BTCPayServer, but when i try to invoke the api i’m getting this weird “no-bitid” error.
root@ubuntu:/home/ubuntu/node_modules/bitpay/lib# bitpay pair
Do you have a pairing code?
no
Okay, we can get a pairing code, please choose a facade:
1) Point of Sale
2) Merchant
: 1
Your token information:
Client ID: Tf71..................................ZYR3
Pairing Code: zEXgMr5
Label: node-bitpay-client-ubuntu
Facade: pos
Your pairing code will be available until: Wed Apr 11 2018 20:17:57 GMT-0300 (-03)
Pair this client with another organization by giving an administrator this pairing code:
zEXgMr5
Pair this client with your organization:
https://0.0.0.0:23000/api-access-request?pairingCode=zEXgMr5
Then i access the link on the browser and get the message “Pairing is successful”, the token is now activated.
But when i try to invoke any methods i only get errors
root@ubuntu:/home/ubuntu/node_modules/bitpay/lib# bitpay whoami
Enter Key Password:
Error: { error: 'no-bitid' }
root@ubuntu:/home/ubuntu/node_modules/bitpay/lib# bitpay request -T pos -R invoices
Enter Key Password:
Error: { error: 'no-bitid' }
root@ubuntu:/home/ubuntu/node_modules/bitpay/lib# bitpay request -T pos -X post -R invoices -P '{"price": 15, "currency": "USD"}'
Enter Key Password:
Error: { error: 'no-bitid' }
I’ve commented the lines that check the type of the model of “controller.User.Identity” on “Extensions.cs” (just to help debugging)
public static BitIdentity GetBitIdentity(this Controller controller, bool throws = true) {
// if (!(controller.User.Identity is BitIdentity))
// return throws ? throw new UnauthorizedAccessException("no-bitid") : (BitIdentity)null;
return (BitIdentity)controller.User.Identity;
}
Now this error is thrown at server console
crit: PayServer: Unhandled exception in BTCPayMiddleware
System.InvalidCastException: Unable to cast object of type 'System.Security.Claims.ClaimsIdentity' to type 'BTCPayServer.Authentication.BitIdentity'.
at BTCPayServer.Extensions.GetBitIdentity(Controller controller, Boolean throws) in /home/ubuntu/btcpay/btcpayserver/BTCPayServer/Extensions.cs:line 117
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (13 by maintainers)
No I can’t fix this easily actually. Well anyway it works good! 😃
w00t… anyway it is a btcpay bug you had the 80 in the url… will check if I can solve this.
Also verify that the pubkey used is well registered into stores/user tokens (the pairing should have done it)
Here: https://github.com/btcpayserver/btcpayserver/blob/master/BTCPayServer/Hosting/BTCpayMiddleware.cs#L69
Can you add
Logs.PayServer.LogInformation($"key ({key.ToHex()}), sig ({sig}), url ({url}), body ({body})");And tell me what it gives you
Can you print what the node client is signing when sending the request? Your process seems right.
So the issue is the following: Your client is signing a request thinking your instance URI is “https://0.0.0.0:23000/”… but your btcpay server think its address is “http://127.0.0.1:23000/”.
If you want your btcpay instance to use the same address as your bitpay client you can use
--externalurl http://127.0.0.1:23000/and use the same url for your client!UPDATE: Sorry I have not read enough your post!
Uncomment those lines. This error only mean you are not signing your request as you should do with Bitpay.
You need to pair a private key of your client with the server via a process Bitpay call “pairing”. There is two way of doing it: server side pairing and client side pairing. Check this for python
https://support.bitpay.com/hc/en-us/articles/115003001203-How-do-I-configure-and-use-the-BitPay-Python-Library-
The process for nodejs should be same. BTCpayServer support both mode.