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:
- Create a raw transaction with
createrawtransaction
providing as arguments the inputs and outputs for the transaction
- 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
- 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.