3

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<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");
        }
    }

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?

-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

  • This doesn't explain the code I posted. – morsecoder Oct 27 '14 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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