Replies: 1 comment
-
I found that the signature result in the example in tests and the result of decoderwtransaction are also incorrect. Is there a problem with the code? SigningInput buildInputP2PKH(bool omitKey = false) {
} TEST(BitcoinSigning, SignP2PKH) {
} [root@localhost BTC]# ./bitcoin-cli -regtest -rpcuser=zhangwenge -rpcpassword=123456 -rpcport=8332 decoderawtransaction 0100000001fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f000000006a47304402202819d70d4bec472113a1392cadc0860a7a1b34ea0869abb4bdce3290c3aba086022023eff75f410ad19cdbe6c6a017362bd554ce5fb906c13534ddc306be117ad30a012103c9f4836b9a4f77fc0d81f7bcb01b7f1b35916864b9476c241ce9fc198bd25432ffffffff02b0bf0314000000001976a914769bdff96a02f9135a1d19b749db6a78fe07dc9088acaefd3c11000000001976a9149e089b6889e032d46e3b915a3392edfd616fb1c488ac00000000 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all,
I use wallet-core to build bitcoin transactions, I meet following problems:
Decode the signed transaction with decoderwtransaction and find that the txid of utxo is different from the input.
Broadcast transaction, return error bad txns inputs missingorspent. I think other netizens also reported this error.
The following is my test code and operation log. Please help to see what the problem is?
thank you.
//test code:
void TOKEN_SendBTC()
{
// Setup input
TW::Bitcoin::SigningInput input;
input.hashType = TW::Bitcoin::hashTypeForCoin(TWCoinTypeBitcoin);
input.amount = 100'000'000;
input.byteFee = 1;
input.toAddress = "bcrt1q0d8qtm0wuf2caggfldylgspzsu45lr3ja6nnsa";
input.changeAddress = "bcrt1qscknkrlq52t99u5phraz8drkladwehjrq8sdt8";
input.coinType = TWCoinTypeBitcoin;
}
//raw transaction
BTC tx = 0100000001d5ea6e3d864908f12da3bc161939b9e3d263a3efcd62a11d2f60734305bda6cd000000006a4730440220236db911a787a7712d0d6c082ff0a5ae79184b8f9cf886185e7e8a120cc1876402200fbc30736276d800692bacfed5a70d3aca7519fb0b2971b3e42d4d7f05524ad9012102492220e489c7438cfdbb96b6082021ab59f0209314df83068ae7a2497beb692cffffffff0200e1f505000000001600147b4e05edeee2558ea109fb49f44022872b4f8e322410102401000000160014862d3b0fe0a29652f281b8fa23b476ff5aecde4300000000
./bitcoin-cli -regtest -rpcuser=root -rpcpassword=123456 -rpcport=8332 sendrawtransaction 0100000001d5ea6e3d864908f12da3bc161939b9e3d263a3efcd62a11d2f60734305bda6cd000000006a4730440220236db911a787a7712d0d6c082ff0a5ae79184b8f9cf886185e7e8a120cc1876402200fbc30736276d800692bacfed5a70d3aca7519fb0b2971b3e42d4d7f05524ad9012102492220e489c7438cfdbb96b6082021ab59f0209314df83068ae7a2497beb692cffffffff0200e1f505000000001600147b4e05edeee2558ea109fb49f44022872b4f8e322410102401000000160014862d3b0fe0a29652f281b8fa23b476ff5aecde4300000000
error code: -25
error message:
bad-txns-inputs-missingorspent
[root@localhost BTC]#
[root@localhost BTC]#
[root@localhost BTC]# ./bitcoin-cli -regtest -rpcuser=zhangwenge -rpcpassword=123456 -rpcport=8332 decoderawtransaction 0100000001d5ea6e3d864908f12da3bc161939b9e3d263a3efcd62a11d2f60734305bda6cd000000006a4730440220236db911a787a7712d0d6c082ff0a5ae79184b8f9cf886185e7e8a120cc1876402200fbc30736276d800692bacfed5a70d3aca7519fb0b2971b3e42d4d7f05524ad9012102492220e489c7438cfdbb96b6082021ab59f0209314df83068ae7a2497beb692cffffffff0200e1f505000000001600147b4e05edeee2558ea109fb49f44022872b4f8e322410102401000000160014862d3b0fe0a29652f281b8fa23b476ff5aecde4300000000
{
"txid": "04edf9e98bbf9d6de56a884df8ca0110b8cabf001252cb2291659d3b1781fb95",
"hash": "04edf9e98bbf9d6de56a884df8ca0110b8cabf001252cb2291659d3b1781fb95",
"version": 1,
"size": 219,
"vsize": 219,
"weight": 876,
"locktime": 0,
"vin": [
{
"txid": "cda6bd054373602f1da162cdefa363d2e3b9391916bca32df10849863d6eead5",
"vout": 0,
"scriptSig": {
"asm": "30440220236db911a787a7712d0d6c082ff0a5ae79184b8f9cf886185e7e8a120cc1876402200fbc30736276d800692bacfed5a70d3aca7519fb0b2971b3e42d4d7f05524ad9[ALL] 02492220e489c7438cfdbb96b6082021ab59f0209314df83068ae7a2497beb692c",
"hex": "4730440220236db911a787a7712d0d6c082ff0a5ae79184b8f9cf886185e7e8a120cc1876402200fbc30736276d800692bacfed5a70d3aca7519fb0b2971b3e42d4d7f05524ad9012102492220e489c7438cfdbb96b6082021ab59f0209314df83068ae7a2497beb692c"
},
"sequence": 4294967295
}
],
"vout": [
{
"value": 1.00000000,
"n": 0,
"scriptPubKey": {
"asm": "0 7b4e05edeee2558ea109fb49f44022872b4f8e32",
"hex": "00147b4e05edeee2558ea109fb49f44022872b4f8e32",
"address": "bcrt1q0d8qtm0wuf2caggfldylgspzsu45lr3ja6nnsa",
"type": "witness_v0_keyhash"
}
},
{
"value": 48.99999780,
"n": 1,
"scriptPubKey": {
"asm": "0 862d3b0fe0a29652f281b8fa23b476ff5aecde43",
"hex": "0014862d3b0fe0a29652f281b8fa23b476ff5aecde43",
"address": "bcrt1qscknkrlq52t99u5phraz8drkladwehjrq8sdt8",
"type": "witness_v0_keyhash"
}
}
]
}
[root@localhost BTC]#
Beta Was this translation helpful? Give feedback.
All reactions