Skip to content

RPC commands require token to be set in client options #163

@pinheadmz

Description

@pinheadmz

For RPC calls when wallet-auth: true, the admin token needs to be set as an option when instantiating the client:

const {WalletClient, Network} = require('bcoin');
const network = Network.get('regtest');

const walletOptions = {
  network: network.type,
  port: network.walletPort,
  apiKey: 'api-key'
  token: <ADMIN TOKEN OR WALLET TOKEN>
}

const walletClient = new WalletClient(walletOptions);

(async () => {
  const result = await walletClient.execute('getwalletinfo');
  console.log(result);
})();

The token property is stored in the bcurl/client, without setting this property there is no other way to add a token to an RPC call -- note that with the REST-API HTTP calls the docs already specify to add ?token=... or --token=...

https://bcoin.io/api-docs/?shell--curl#wallet-authentication

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions