Understanding Bitcoin: Why does walletprocesspsbt complete the PSBT but not return the transaction hex

Since you are using the popular wallet function “processbt” to complete the payment script binary tree (PSBT) and add the “bip32.derivation” path, it is because of your statement that this command returns the completed PSBT. However, if a new derivation path is added to an already signed and completed PSBT, the transaction hex is not returned directly.

In Bitcoin, the hash of each transaction is represented as a 64-byte hexadecimal string. When you add a new derivation path to PSBT, the wallet process psbt creates this new hexadecimal representation of the transaction hash value. It does this by using the “bip32.derivation” method and then compressing the resulting binary data.

Here’s how it works step by step:

  • Wallet process psbt signs the input transaction with its private key.
  • It creates a Payment Script Binary Tree (PSBT) from the signed transaction, which contains all the information needed to generate the output.
  • Wallet processpsbt adds a new derivation path to PSBT using the bip32.derivation method and specifies a custom derivation path.

Running walletprocesspsbt finalize psbt creates a finalized PSBT with the derivation path added. Instead of returning the event hexes directly, it returns an object containing the finalized PSBT and other metadata.

Why is the event hex number not returned?

Bitcoin: Why does walletprocesspsbt finalize the psbt but not return the transaction hex?

Wallet processpsbt returns the finalized PSBT because it is a binary format representing the Payment Script Tree. The bip32.derivation method uses a hashing algorithm (SHA-256 in this case) to generate a new derivation path and its associated hash value.

When you pass the finalized PSBT to an RPC command such as getrawtransaction or dump its contents using dumpwallet, the wallet returns the same processpsbt object containing the finalized PSBT and other metadata. However, the transaction hash is not returned directly; instead, it is embedded in this object.

Example use case:

Suppose you have a signed transaction with a 30-byte txid and vout input index (e.g. txinmap = [0x1234, 0x5678]). The wallet processpsbt signs the transaction with its private key:

walletprocesspsbt finalize txid vout1 txinmap=0x1234 0x5678 --derivepath=myderivation

After running this command, you will get a finalized PSBT containing the binary data and other metadata of the signed transaction. Then add a new derivation path to PSBT using “bip32.derivation”:

walletprocesspsbt finalize psbt txid vout1 txinmap=0x1234 0x5678 --derivepath=myderivation --addpath=bip32path

Wallet processpsbt returns an object containing the finalized PSBT and other metadata, including the transaction hash as a hexadecimal string.

To summarize, when you use the walletprocesspsbt command to add a new derived path to an already signed and finalized PSBT, the command returns an object containing the finalized PSBT and other metadata. The hexadecimal number of the event is not returned directly; instead, it is embedded in this object.

Rate this post

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *