使用bitcore-wallet-client时遇到错误

时间:2019-06-19 07:55:59

标签: node.js bitcoin bitcore

我使用“ bitcore-wallet-client”并尝试发送交易,但遇到一些错误。

首先,我从助记符导入钱包,使用Testnet网络

import * as BWC from 'bitcore-wallet-client'

const bwc = new BWC({
  baseUrl: 'https://bws.bitpay.com/bws/api',
  timeout: 100000,
  transports: ['polling']
})
function importMnemonic() {
  return new Promise(resolve => {
    bwc.importFromMnemonic('my mnemonic', {
          network: 'testnet',
          passphrase: null,
          derivationStrategy: 'BIP44',
          account: 0,
          coin: 'btc'
        }, err => {
          if (err) {
            console.log(err)
          } else {
           resolve(bwc)
          }
        })
 })
}

然后,我尝试发送交易

importMnemonic().then(walletClient => {
  bwc.import(walletClient.export())
  const txp = {
    outputs: [{
            toAddress: 'mgEacU8XArUTFPvhBPnGS6M7j7XqCau5zb',
            amount: 100000,
            message: null,
            encryptedMessage: null
          }],
          feeLevel: 'normal',
  }
  bwc.createTxProposal(txp, (err, txp) => {
        if (err) {
          console.log('createTxProposal',err)
          return
        }
        console.log('createTxProposal',txp)
        bwc.publishTxProposal({txp: txp}, (err, publishedTxp) => {
          if (err) {
            console.log('publishTxProposal',err)
            return
          }
          console.log('publishTxProposal',publishedTxp)
          bwc.signTxProposal(publishedTxp, (err, signedTxp) => {
            if (err) {
              console.log('signTxProposal',err)
              return
            }
            console.log('signTxProposal',signedTxp)
            bwc.broadcastTxProposal(signedTxp, (err, broadcastedTxp, memo) => {
              if (err) {
                console.log('broadcastTxProposal',err)
                return
              }
              console.log('broadcastTxProposal',broadcastedTxp)
            })
          })
        })
      })
})

但是它在'publishTxProposal'方法中引发了错误:

NodeError { message: "Transaction proposal not found", stack: "Transaction proposal not found. Error at new NodeError"}

这是什么原因?请帮助我!

0 个答案:

没有答案