Closed bellaj closed 6 years ago
i haven't noticed that the input i am trying to consume is a p2sh not a p2pkh.
@bellaj hi, How did you solve this problem?
@ShangXoL Here's the type of transaction he made.
@junderw thank you very much
@junderw can you help me ? If 'txb.addInput(unspent.txId, unspent.vout)' had more than one , What changes will “ txb.sign(0, keyPair, p2sh.redeem.output, null, unspent.value) ” take?
What do you mean by more than one? More than one input or more than one signature required?
@dcousens More than one input
@dcousens if more than one input , How to deal with parameter "unspent.value" of function "txb.sign()"?
@ShangXoL to have more than one input
, is identical to having more than one unspent
.
If you have multiple inputs
, you should have multiple unspents
.
Use each unspent
's .value
respectively.
@dcousens var bitcoin = require("bitcoinjs-lib"); const net = bitcoin.networks.testnet; const keyPair = bitcoin.ECPair.fromWIF("cTDMViKByraUgTryu2bUrv4nj9KF6tjhb9gj1vy9SEQeFQH6hcjL", net); const p2wpkh = bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey, network: net }) const p2sh = bitcoin.payments.p2sh({ redeem: p2wpkh, network: net })
var tx = new bitcoin.TransactionBuilder(net); tx.setVersion(2); tx.addInput("58aab89435bad892ff0817f5296d48faa564dfc369b12121c2e5521ec5f7db0b", 0);//99990000 tx.addInput("31f4d3025a026738ab45b62078c64924f26eee5c7bd1ca5b8f84a46be6e963c9", 1);//70000000 tx.addOutput("2NGVjpAzsd9JPnm1jKHeJtNk3e1FBsCHXZU", 169980000); tx.sign(0, keyPair, p2sh.redeem.output, null, 169990000);//<-------------------------- console.log(tx.build().toHex());
tx.sign(0, keyPair, p2sh.redeem.output, null, 169990000);//<--------------------------
is that so?
no
99990000 and 70000000
tx.sign(0, keyPair, p2sh.redeem.output, null, 99990000)
tx.sign(1, keyPair, p2sh.redeem.output, null, 70000000)
@junderw @dcousens Thank you so much, i get it
I am trying to run the following code snippet:
If i use the generated raw transaction using bitcoin core cliet i keep getting the error:
16: mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element)