BitGo / bitgo-utxo-lib

UTXO coins functions implemented in pure JavaScript
86 stars 146 forks source link

Unable to build zcash single transaction #14

Closed kristieguo closed 5 years ago

kristieguo commented 5 years ago

Hi, I am trying to build a regular zcash transaction but ran into issue, the code is as below:

  const transferTo = 'tmVdCtuT7veiasFxwAy95rJdWSrU5Huusq1'
  const transferFromTxId = '0289011e07c120bbdb70c3f5113884d90790c6b241d751cbe529cc207c21496b'

  const NETWORK = bitgo.networks.zcashTest
  const tx = new bitgo.TransactionBuilder(NETWORK)
  tx.addInput(transferFromTxId, 0)
  tx.addOutput(transferTo, 1000000)

  const keyPair = bitgo.ECPair.fromWIF(privateKey, NETWORK)

  try {
    tx.sign(0, keyPair)
  } catch (err) {
    console.log(err)
  }

  const signedTx = tx.build()
  console.log(signedTx.toHex())

The error it caused is:

{ Error: Expected property "2" of type Satoshi, got undefined
    at tfSubError (/Users/tiangeguo/jadepool-BN/node_modules/typeforce/errors.js:93:9)
    at /Users/tiangeguo/jadepool-BN/node_modules/typeforce/index.js:159:17
    at Array.every (<anonymous>)
    at _tuple (/Users/tiangeguo/jadepool-BN/node_modules/typeforce/index.js:155:20)
    at typeforce (/Users/tiangeguo/jadepool-BN/node_modules/typeforce/index.js:196:9)
    at Transaction.hashForZcashSignature (/Users/tiangeguo/jadepool-BN/node_modules/bitgo-utxo-lib/src/transaction.js:614:3)
    at TransactionBuilder.sign (/Users/tiangeguo/jadepool-BN/node_modules/bitgo-utxo-lib/src/transaction_builder.js:801:29)
    at validateAddress (/Users/tiangeguo/jadepool-BN/test/unit/testzcash.js:25:8)
    at Object.<anonymous> (/Users/tiangeguo/jadepool-BN/test/unit/testzcash.js:36:1)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
  message: 'Expected property "2" of type Satoshi, got undefined',
  __label: undefined,
  __property: 2,
  __type: [Function: Satoshi],
  __value: undefined,
  __valueTypeName: '' }
(node:35920) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Not enough signatures provided
(node:35920) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
kristieguo commented 5 years ago

Sorry, Duplicate of #12 , closing this issue.