<p>Yes, you can use the RPC commands <code>createrawtransaction</code>, <code>signrawtransactionwithkey</code>, and <code>decoderawtransaction</code> to create, sign, and compare a raw transaction in Bitcoin.</p>
<p>Here is the <a href="https://developer.bitcoin.org/reference/rpc/index.html" rel="nofollow noreferrer">RPC API Reference</a>.</p>
<p>Here's what you should do:</p>
<ol>
<li><strong>Create a raw transaction</strong> with <code>createrawtransaction</code> providing as arguments the inputs and outputs for the transaction</li>
<li><strong>Sign the raw transaction</strong> with <code>signrawtransactionwithkey</code> providing the raw transaction and the private keys as arguments; this will return the signed raw transaction in hex</li>
<li><strong>Compare the signed raw transaction</strong> with the original raw transaction, you can use the <code>decoderawtransaction</code> 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.</li>
</ol>
<p>It's worth mentioning that the one transaction before using <code>signrawtransactionwithkey</code> and the one after can't be &quot;the same&quot; because the second one it will include the signature and the public key of the inputs, which are not present in the first one.</p>

CC BY-SA 4.0
2023-01-27T18:56:13.013Z
2023-01-27T18:56:13.013Z
Paro
<p>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.</p>
<p>Thus, for such transactions, there is a very simple way to verify they are identical ignoring signatures: compare their txid.</p>

CC BY-SA 4.0
2023-01-28T14:56:16.547Z
2023-01-28T17:42:53.113Z
2023-01-28T17:42:53.113Z
Pieter Wuille
<p>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 :</p>
<ul>
<li>create raw_transaction</li>
<li>signing it</li>
<li>compare the hexencoded ( signed raw tx) with raw tx. To see if they are &quot;the same&quot;</li>
</ul>
<p>Thanks</p>

<raw-transaction>
Decode a signing raw transaction
Userbn
# Decode a signing raw transaction

(Asked by: username_0 on 2023-01-27)

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

**Tags:** raw-transaction


---

## 2 answers

### Answer by username_1 on 2023-01-27. Score: 0 | Accepted answer

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](https://developer.bitcoin.org/reference/rpc/index.html).

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.


---

### Answer by username_2 on 2023-01-28. Score: 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.


---

