<blockquote>
  <p>Could decoding a raw transaction ever have more than one solution?</p>
</blockquote>

<p>Decoding raw transaction is just a human-readable representation of transaction data. So, the answer is "no" and "yes"</p>

<p>There is only one decoding for transaction.</p>

<p>But another client/version may add some other fields for json</p>

CC BY-SA 3.0
2014-10-27T19:33:52.480Z
This doesn't explain the code I posted.
morsecoder
CC BY-SA 3.0
2014-10-27T19:27:56.747Z
2014-10-27T19:27:56.747Z
amaclin
<p>I was looking in <code>rpcrawtransaction.cpp</code> and came across the <code>signrawtransaction</code> rpc method. While reading through this method, I thought these lines seemed strange:</p>

<pre>
    vector&lt;CTransaction> txVariants;
    while (!ssData.empty())
    {
        try {
            CTransaction tx;
            ssData >> tx;
            txVariants.push_back(tx);
        }
        catch (std::exception &e) {
            throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
        }
    }
</pre>

<p>Why is a vector of transaction variants needed here? Could decoding a raw transaction ever have more than one solution? </p>

<p>Maybe this has something to do with unfinished transactions, specifically? </p>

<p>I noticed that <code>sendrawtransaction</code> doesn't have the same loop, but rather just has:</p>

<pre>
    CTransaction tx;

    // deserialize binary data stream
    try {
        ssData >> tx;
    }
    catch (std::exception &e) {
        throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
    }
</pre>

<p>The below seems relevant, too. It happens near the end of <code>signrawtransaction</code>. </p>

<pre>
    // ... and merge in other signatures:
    BOOST_FOREACH(const CTransaction& txv, txVariants)
    {
        txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig);
    }
</pre>

<p>Maybe this has something to do with multisig? </p>

<bitcoin-core-development>
Can there be more than one result of decoding a raw transaction?
morsecoder
# Can there be more than one result of decoding a raw transaction?

(Asked by: username_0 on 2014-10-27)

I was looking in rpcrawtransaction.cpp and came across the signrawtransaction rpc method. While reading through this method, I thought these lines seemed strange:

    vector txVariants;
    while (!ssData.empty())
    {
        try {
            CTransaction tx;
            ssData >> tx;
            txVariants.push_back(tx);
        }
        catch (std::exception &e) {
            throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
        }
    }

Why is a vector of transaction variants needed here? Could decoding a raw transaction ever have more than one solution? 
Maybe this has something to do with unfinished transactions, specifically? 
I noticed that sendrawtransaction doesn't have the same loop, but rather just has:

    CTransaction tx;

    // deserialize binary data stream
    try {
        ssData >> tx;
    }
    catch (std::exception &e) {
        throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
    }

The below seems relevant, too. It happens near the end of signrawtransaction. 

    // ... and merge in other signatures:
    BOOST_FOREACH(const CTransaction& txv, txVariants)
    {
        txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig);
    }

Maybe this has something to do with multisig?

**Tags:** bitcoin-core-development


---

## 1 answers

### Answer by username_1 on 2014-10-27. Score: -2

> Could decoding a raw transaction ever have more than one solution?

Decoding raw transaction is just a human-readable representation of transaction data. So, the answer is "no" and "yes"

There is only one decoding for transaction.

But another client/version may add some other fields for json

> **Comments:**
> **username_0**: This doesn't explain the code I posted.  

---

