Perpaps I'm using the wrong syntax for signrawtransaction, but otherwise I might have found a bug.
For example this unsigned transaction gets decoded successfully (remove the line-breaks):
curl --user USERNAME --data-binary '{"id":"t0",
"method": "decoderawtransaction",
"params":
["0100000002d354be7cd5426bfbe70517b934b8764d17ad7f93e2b8db868211851d4404740f010000001976a91423376070c7b24da64b435c71613053800494ab1c88acffffffffe49a65da5abe3edd6e5157327fe794a7c75befecaaf18fefd3154dbb4527d6d6010000001976a91423376070c7b24da64b435c71613053800494ab1c88acffffffff0240420f00000000001976a914c8a73488183dd49f63a11dea0a3b242ae70942d288ac10ae2201000000001976a91423376070c7b24da64b435c71613053800494ab1c88ac0000000001000000"]
}' http://127.0.0.1:8332/
But when I try to sign it, it throws an exception:
curl --user USERNAME --data-binary '{"id":"t0",
"method": "signrawtransaction",
"params":
[
"0100000002d354be7cd5426bfbe70517b934b8764d17ad7f93e2b8db868211851d4404740f010000001976a91423376070c7b24da64b435c71613053800494ab1c88acffffffffe49a65da5abe3edd6e5157327fe794a7c75befecaaf18fefd3154dbb4527d6d6010000001976a91423376070c7b24da64b435c71613053800494ab1c88acffffffff0240420f00000000001976a914c8a73488183dd49f63a11dea0a3b242ae70942d288ac10ae2201000000001976a91423376070c7b24da64b435c71613053800494ab1c88ac0000000001000000",
[],
[]
]
}' http://127.0.0.1:8332/
{"result":null,"error":{"code":-22,"message":"TX decode failed"},"id":"t0"}
Now there might be something wrong with my transaction, but I would except signrawtransaction to at least throw a different error than decoderawtransaction if the latter successfully decodes it.
Looking at the source code, the decode method does this and throws the "TX decode failed" message if it doesn't work:
CTransaction tx;
try {
ssData >> tx;
}
catch (std::exception &e) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
The decode method is similar but performs one extra step. My guess is that that is where the error occurs in my case, but I haven't tested this.
vector<CTransaction> txVariants;
while (!ssData.empty())
{
try {
CTransaction tx;
ssData >> tx;
txVariants.push_back(tx);