JSPM

bitcore-wallet-client

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1060
  • Score
    100M100P100Q94631F

Client for bitcore-wallet-service

Package Exports

  • bitcore-wallet-client

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bitcore-wallet-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

bitcore-wallet-client

Build Status Coverage Status

The official client library for [bitcore-wallet-service] (https://github.com/bitpay/bitcore-wallet-service).

Description

This package communicated to BWS (Bitcore wallet service) using its REST API. All REST endpoints are wrapped on simple async call. All relevant responses from BWS are checked independently by the peers, thus the importance of using this library with talking with a third party BWS instance.

See [Bitcore-wallet] (https://github.com/bitpay/bitcore-wallet) for a simple CLI wallet implementation that relays on BWS and uses bitcore-wallet-client.

Quick Start

  var client = new Client({
    baseUrl: bws_instance_url,
    verbose: true,
  });

 client.createWallet("my Wallet", "Irene", 2, 3, 'testnet', function(err, secret) {
    // Handle err
    console.log(' Wallet Created. Share this secret with your copayers:' + secret);
    fs.writeFileSync('wallet.dat', client.export());
 });
 
 // Then, from other Copayer
 
   var client = new Client({
    baseUrl: bws_instance_url,
    verbose: true,
  });

 client.joinWallet(secret,  "Thomas", function(err, secret) {
    // Handle err
    console.log(' Wallet Joined!);
    fs.writeFileSync('wallet.dat', client.export());
 });
 

API Client

##new API(opts) ClientAPI constructor.

Params

  • opts Object

##API.seedFromExtendedPrivateKey(xPrivKey) Seed from extended private key

Params

  • xPrivKey String

##API.seedFromRandom(xPrivKey) Seed from random

Params

  • network String

##API.export(opts) Export wallet

Params

  • opts Object
    • compressed Boolean
    • password String

##API.import(opts) Import wallet

Params

  • opts Object
    • compressed Boolean
    • password String

##API.toString() Return a serialized object with credentials

##API.fromString(str) Get credentials from an object

Params

  • str Object

##API._doRequest(method, url, args, cb) Do a request

Params

  • method Object
  • url String
  • args Object
  • cb Callback

##API._doPostRequest(url, args, cb) Post a request

Params

  • url String
  • args Object
  • cb Callback

##API._doGetRequest(url, cb) Get a request

Params

  • url String
  • cb Callback

##API._doDeleteRequest(url, cb) Delete a request

Params

  • url String
  • cb Callback

##API._doJoinWallet(walletId, walletPrivKey, xPubKey, copayerName, cb) Join

Params

  • walletId String
  • walletPrivKey String
  • xPubKey String
  • copayerName String
  • cb Callback

##API.isComplete() Return if wallet is complete

##API.openWallet(cb) Opens a wallet and tries to complete the public key ring.

Params

  • cb Callback

Returns: Callback - cb - Returns an error and a flag indicating that the wallet has just been completed and needs to be persisted
##API.createWallet(walletName, copayerName, m, n, network, cb) Create a wallet.

Params

  • walletName String
  • copayerName String
  • m Number
  • n Number
  • network String - 'livenet' or 'testnet'
  • cb Callback

Returns: Callback - cb - Returns the wallet
##API.joinWallet(secret, copayerName, cb) Join to an existent wallet

Params

  • secret String
  • copayerName String
  • cb Callback

Returns: Callback - cb - Returns the wallet
##API.getStatus(cb) Get status of the wallet

Params

  • cb Callback

Returns: Callback - cb - Returns error or an object with status information
##API.sendTxProposal(opts) Send a transaction proposal

Params

  • opts Object
    • toAddress String
    • amount Number
    • message String

Returns: Callback - cb - Return error or the transaction proposal
##API.createAddress(cb) Create a new address

Params

  • cb Callback

Returns: Callback - cb - Return error or the address
##API.getMainAddresses(opts, cb) Get your main addresses

Params

  • opts Object
    • doNotVerify Boolean
  • cb Callback

Returns: Callback - cb - Return error or the array of addresses
##API.getBalance(cb) Update wallet balance

Params

  • cb Callback

##API.getTxProposals(opts) Get list of transactions proposals

Params

  • opts Object
    • doNotVerify Boolean
    • forAirGapped Boolean

Returns: Callback - cb - Return error or array of transactions proposals
##API.getSignatures(opts) Get list of transactions proposals

Params

  • opts Object
    • doNotVerify Boolean
    • forAirGapped Boolean

Returns: Callback - cb - Return error or array of transactions proposals
##API.signTxProposal(txp, cb) Sign a transaction proposal

Params

  • txp Object
  • cb Callback

Returns: Callback - cb - Return error or object
##API.rejectTxProposal(txp, reason, cb) Reject a transaction proposal

Params

  • txp Object
  • reason String
  • cb Callback

Returns: Callback - cb - Return error or object
##API.broadcastTxProposal(txp, cb) Broadcast a transaction proposal

Params

  • txp Object
  • cb Callback

Returns: Callback - cb - Return error or object
##API.removeTxProposal(txp, cb) Remove a transaction proposal

Params

  • txp Object
  • cb Callback

Returns: Callback - cb - Return error or empty
##API.getTxHistory(opts, cb) Get transaction history

Params

  • opts Object
  • cb Callback

Returns: Callback - cb - Return error or array of transactions