Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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