2

I'm trying to compare raw_transaction with a sign_raw_transaction. is there any way to do that ? ( Using rpc commande if possible) What i want to do is :

  • create raw_transaction
  • signing it
  • compare the hexencoded ( signed raw tx) with raw tx. To see if they are "the same"

Thanks

2 Answers 2

0

Yes, you can use the RPC commands createrawtransaction, signrawtransactionwithkey, and decoderawtransaction to create, sign, and compare a raw transaction in Bitcoin.

Here is the RPC API Reference.

Here's what you should do:

  1. Create a raw transaction with createrawtransaction providing as arguments the inputs and outputs for the transaction
  2. Sign the raw transaction with signrawtransactionwithkey providing the raw transaction and the private keys as arguments; this will return the signed raw transaction in hex
  3. Compare the signed raw transaction with the original raw transaction, you can use the decoderawtransaction command on both; this will return a JSON object containing details about the transaction, including the inputs and outputs. You can then compare these details to see if they match.

It's worth mentioning that the one transaction before using signrawtransactionwithkey and the one after can't be "the same" because the second one it will include the signature and the public key of the inputs, which are not present in the first one.

0

If the transaction is fully segwit (i.e., all transaction inputs spend segwit or taproot outputs), then the txid does not depend on any of the data added during signing.

Thus, for such transactions, there is a very simple way to verify they are identical ignoring signatures: compare their txid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.