JavaScript/TypeScript client for Bitcore Wallet Service.
API— main client, extends EventEmitter (polls notifications)Key— HD seed manager (mnemonic/xprv), derivesCredentialsCredentials— serializable wallet identity (chain, network, xpub, request keys)Request— HTTP wrapper used by APIVerifier,Utils,PayPro,PayProV2,BulkClient— helpers
import { API, Key } from 'bitcore-wallet-client';
// 1) Point to your BWS instance
const client = new API({ baseUrl: 'http://localhost:3232/bws/api', logLevel: 'info' });
// 2) Create a new seed and derive credentials (single-sig BTC, livenet, account 0)
const key = new Key({ seedType: 'new' });
const credentials = key.createCredentials(undefined, {
coin: 'btc', chain: 'btc', network: 'livenet', account: 0, n: 1
});
// 3) Attach credentials to client
client.fromObj(credentials.toObj());
// 4) Create a wallet (server enforces auth via headers built by client)
client['request'].post('/v2/wallets/', { // or use high-level API methods if available
name: 'My Wallet', m: 1, n: 1, network: 'livenet', coin: 'btc'
}, (err, res) => { /* ... */ });client.initialize({ notificationIncludeOwn: true }, () => {
client.on('notification', n => console.log('notification', n));
});- Create/join wallet: POST
/v2/wallets/, then/v2/wallets/:id/copayers/ - Create address: POST
/v4/addresses/ - Balance: GET
/v1/balance/ - UTXOs: GET
/v1/utxos/ - Create TXP: POST
/v3/txproposals/ - Sign TXP: POST
/v2/txproposals/:id/signatures/(signatures generated usingKey+Utils) - Publish/broadcast: POST
/v1/txproposals/:id/publish/then/v1/txproposals/:id/broadcast/
Notes:
- See
Credentials.FIELDSfor serializable fields andKeyfor encryption helpers. - The client sets required headers/signatures automatically using the attached credentials.