Using bitcoin-cli to handle witness for a valid transaction from rawtransaction

8 replies 496 views
maxcoinMember
Posts: 27 · Reputation: 238
#1Feb 3, 2021, 02:54 AM
Hey everyone, I’m reaching out because I’ve tried a bunch of things to fix my problem but haven’t had any luck. Hoping you guys can give me a hand. So first off, here’s my setup: Bitcoin Core version v24.0.1 (release build) MacOS 14.0 Shell: zsh My full Bitcoin node is running with txindex=1, and I’m using `./bitcoind`. All of this is happening through the `./bitcoin-cli` command. I’ve picked a wallet and listed the unspent outputs. My goal is to combine multiple inputs into a single output. I chose three transactions for testing and one address for change. I tried to create my transaction from `rawtransaction`, but I’m thinking maybe I should go a different route. I also attempted `walletcreatefundedpsbt`, but I ran into an error saying 'Insufficient funds.' So, I manually selected my UTXOs and built the raw transaction like this: ./bitcoin-cli -rpcwallet=MY_WALLET createrawtransaction "[{\"txid\":\"tx_id_1\",\"vout\": 0, \"scriptPubKey\":\"Script_1\"}, {\"txid\":\"tx_id_2\",\"vout\": 1, \"scriptPubKey\":\"Script_2\"}, {\"txid\":\"tx_id_3\",\"vout\": 1, \"scriptPubKey\":\"Script_3\"}]" "[{\"recipient\" : amt}]" Then I went to sign it with `signrawtransactionwithwallet`, but got this error: { "txid": "tx_id_1", "vout": 0, "witness": [ ], "scriptSig": "", "sequence": 4294967293, "error": "Witness program was passed an empty witness" } This happens for all UTXOs. I even tried signing each ScriptPubKey as a message with `signmessage` but I need the private key for that. When I attempt `dumpvkey`, I get an error saying 'Only legacy wallets are supported by this command.' Just to note, my wallet is Taproot.
3 Reply Quote Share
BasedGasHero Member
Posts: 460 · Reputation: 2335
#2Feb 3, 2021, 06:32 AM
Make sure UTXOs have spendable funds in it. To get list of all available spendable UTXOs use 'listunspent' in the command console. To create Raw transaction, Use 'createrawtransaction ' command and make sure scriptPubKey provided are correct for each UTXO. To Sign Raw transaction, use 'signrawtransactionwithwallet' After Signing, verify the signed transaction by 'decoderawtransaction' command. Now Broadcast your transaction To get your private key in bitcoin core, use 'dumpprivkey' followed by the respective address
1 Reply Quote Share
maxcoinMember
Posts: 27 · Reputation: 238
#3Feb 3, 2021, 10:27 PM
Ok thanks for your answer but I well double checked and info are correct. It's really during the 'signrawtransactionwithwallet' step where the problem cames out caused by Witness program was passed an empty witness. But I don't find how to manage with witness. I followed your previous step to build my first transactioon and it was good. But for this one it doesn't work.
6 Reply Quote Share
ryan_nodeSenior Member
Posts: 204 · Reputation: 859
#4Feb 4, 2021, 03:36 AM
Are you certain that all of the inputs that you have specified belong to the wallet? You have the correct vout values? When you used listunspent, did it say that those utxos are spendable? Can you also post the output of getwalletinfo?
4 Reply Quote Share
maxcoinMember
Posts: 27 · Reputation: 238
#5Feb 4, 2021, 04:12 AM
> Are you certain that all of the inputs that you have specified belong to the wallet? Yes it's in the output of ./bitcoin-cli -rpcwallet=MY_WALLET listunspent > You have the correct vout values? Yes the vout is the right one. And I think that I should have another error if the problem comes from vout. > When you used listunspent, did it say that those utxos are spendable? Yes each of them are spendable. > Can you also post the output of getwalletinfo? {   "walletname": "cor",   "walletversion": 169900,   "format": "sqlite",   "balance": 0.00071184,   "unconfirmed_balance": 0.00000000,   "immature_balance": 0.00000000,   "txcount": 44,   "keypoolsize": 1000,   "keypoolsize_hd_internal": 0,   "paytxfee": 0.00000000,   "private_keys_enabled": false,   "avoid_reuse": true,   "scanning": false,   "descriptors": true,   "external_signer": false } I don't know if it's important or new but each output looks like this :   {     "txid": "d13...",     "vout": 0,     "address": "bc1p...",     "label": "",     "scriptPubKey": "5120...",     "amount": 0.00010000,     "confirmations": 43033,     "spendable": true,     "solvable": true,     "desc": "descriptor",     "parent_descs": [       "another_descriptor"     ],     "reused": false,     "safe": true   } [moderator's note: consecutive posts merged]
1 Reply Quote Share
ryan_nodeSenior Member
Posts: 204 · Reputation: 859
#6Feb 4, 2021, 07:47 AM
How did you create this wallet? It does not have private keys enabled, so you will be unable to sign any transactions.
3 Reply Quote Share
maxcoinMember
Posts: 27 · Reputation: 238
#7Feb 4, 2021, 01:40 PM
Aaaaah ! I created with ord command-line
1 Reply Quote Share
ryan_nodeSenior Member
Posts: 204 · Reputation: 859
#8Feb 5, 2021, 05:02 PM
Then you need to look at ord's documentation, and probably be using it to send as well. The private keys are not in Bitcoin Core so there's nothing that you can do with it directly to send.
3 Reply Quote Share
maxcoinMember
Posts: 27 · Reputation: 238
#9Feb 5, 2021, 08:28 PM
Ok ! Yes totally you're right ! Thanks a lot for all your help !!!🙏🙏🙏
4 Reply Quote Share

Related topics