Bitcoin Forum
May 02, 2024, 08:45:10 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Managing witness with bitcoin-cli to a valid transaction from rawtransaction  (Read 65 times)
GaloisField (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 1


View Profile WWW
December 16, 2023, 02:54:18 PM
 #1

Hello,


I post a message today cause I tried multiple ways to manage with my issue but I didn't find any solution. Maybe you can help me ?


First my version and OS :

Bitcoin Core version v24.0.1 (release build)
MacOS 14.0
Shell : zsh


My Bitcoin full node is running with txindex=1. I'm running `./bitcoind`. Everything what I'm talking is under `./bitcoin-cli` command.

I selected a wallet, and listed unspent. I want to merge multiple inputs into one single output.

I selected transactions that I want to merge 3 for the test and one address to give the change.

I try to build my tx from `rawtransaction` but maybe I should use another. Here I tried also `walletcreatefundedpsbt` but I got the error : Insufficient funds.

So, I selected my utxos and build rawtransaction as follow :

./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}]"

Here I take the output to sign it (with `signrawtransactionwithwallet`), I got the error :

{
      "txid": "tx_id_1",
      "vout": 0,
      "witness": [
      ],
      "scriptSig": "",
      "sequence": 4294967293,
      "error": "Witness program was passed an empty witness"
 }

This for all utxos.

So, I tried to sign manually each ScriptPubKey as message with signmessage but I need the pvkey. When I try dumpvkey I have the error : Only legacy wallets are supported by this command

The wallet is a taproot wallet (bc1p...).

I don't know what step to follow in order to add the witness and be able to sign this raw transaction and send to the network. I think sending on the network is not the hardest part but I didn't find how to handle signatures for this...

It's not a multisig wallet and I have the control of it.

Do you have any ideas or suggestions ?

Thanks for your reading I hope that we can solve this together Smiley
1714682710
Hero Member
*
Offline Offline

Posts: 1714682710

View Profile Personal Message (Offline)

Ignore
1714682710
Reply with quote  #2

1714682710
Report to moderator
If you want to be a moderator, report many posts with accuracy. You will be noticed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714682710
Hero Member
*
Offline Offline

Posts: 1714682710

View Profile Personal Message (Offline)

Ignore
1714682710
Reply with quote  #2

1714682710
Report to moderator
Findingnemo
Hero Member
*****
Offline Offline

Activity: 2324
Merit: 758


Bitcoin = Financial freedom


View Profile
December 16, 2023, 03:48:51 PM
 #2

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.

Code:
./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_address\": amount, \"change_address\": change}"

To Sign Raw transaction, use 'signrawtransactionwithwallet'

Code:
./bitcoin-cli -rpcwallet=MY_WALLET signrawtransactionwithwallet "hex_of_raw_transaction"

After Signing, verify the signed transaction by 'decoderawtransaction' command.

Code:
./bitcoin-cli -rpcwallet=MY_WALLET decoderawtransaction "signed_hex_transaction"

Now Broadcast your transaction

Code:
./bitcoin-cli -rpcwallet=MY_WALLET sendrawtransaction "signed_hex_transaction"



To get your private key in bitcoin core, use 'dumpprivkey' followed by the respective address

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits.
..........UNLEASH..........
THE ULTIMATE
GAMING EXPERIENCE
DUELBITS
FANTASY
SPORTS
████▄▄█████▄▄
░▄████
███████████▄
▐███
███████████████▄
███
████████████████
███
████████████████▌
███
██████████████████
████████████████▀▀▀
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
.
▬▬
VS
▬▬
████▄▄▄█████▄▄▄
░▄████████████████▄
▐██████████████████▄
████████████████████
████████████████████▌
█████████████████████
███████████████████
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
/// PLAY FOR  FREE  ///
WIN FOR REAL
..PLAY NOW..
View ArchiveReport to moderator
GaloisField (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 1


View Profile WWW
December 16, 2023, 04:01:17 PM
 #3

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.

achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6577


Just writing some code


View Profile WWW
December 16, 2023, 04:22:56 PM
 #4

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?

GaloisField (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 1


View Profile WWW
December 16, 2023, 04:35:29 PM
 #5

> 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
}

GaloisField (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 1


View Profile WWW
December 16, 2023, 04:37:36 PM
 #6

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
  }
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6577


Just writing some code


View Profile WWW
December 16, 2023, 05:31:05 PM
 #7

How did you create this wallet? It does not have private keys enabled, so you will be unable to sign any transactions.

GaloisField (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 1


View Profile WWW
December 16, 2023, 05:47:46 PM
 #8

Aaaaah !

I created with ord command-line
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6577


Just writing some code


View Profile WWW
December 16, 2023, 09:10:29 PM
Merited by Findingnemo (1)
 #9

I created with ord command-line
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.

GaloisField (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 1


View Profile WWW
December 16, 2023, 10:07:27 PM
 #10

Ok ! Yes totally you're right !

Thanks a lot for all your help !!!🙏🙏🙏
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!