diff options
Diffstat (limited to 'src/rpcrawtransaction.cpp')
| -rw-r--r-- | src/rpcrawtransaction.cpp | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 837aee7ea..50734a5c1 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -400,12 +400,11 @@ Value decoderawtransaction(const Array& params, bool fHelp) "\nReturn a JSON object representing the serialized, hex-encoded transaction.\n" "\nArguments:\n" - "1. \"txid\" (string, required) The transaction hex string\n" + "1. \"hex\" (string, required) The transaction hex string\n" "\nResult:\n" "{\n" - " \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n" - " \"txid\" : \"id\", (string) The transaction id (same as provided)\n" + " \"txid\" : \"id\", (string) The transaction id\n" " \"version\" : n, (numeric) The version\n" " \"locktime\" : ttt, (numeric) The lock time\n" " \"vin\" : [ (array of json objects)\n" @@ -437,10 +436,6 @@ Value decoderawtransaction(const Array& params, bool fHelp) " }\n" " ,...\n" " ],\n" - " \"blockhash\" : \"hash\", (string) the block hash\n" - " \"confirmations\" : n, (numeric) The confirmations\n" - " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n" - " \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" "}\n" "\nExamples:\n" @@ -536,7 +531,7 @@ Value signrawtransaction(const Array& params, bool fHelp) " \"privatekey\" (string) private key in base58-encoding\n" " ,...\n" " ]\n" - "4. \"sighashtype\" (string, optional, default=ALL) The signature has type. Must be one of\n" + "4. \"sighashtype\" (string, optional, default=ALL) The signature hash type. Must be one of\n" " \"ALL\"\n" " \"NONE\"\n" " \"SINGLE\"\n" @@ -722,7 +717,7 @@ Value signrawtransaction(const Array& params, bool fHelp) { txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig); } - if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, 0)) + if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, STANDARD_SCRIPT_VERIFY_FLAGS, 0)) fComplete = false; } @@ -777,25 +772,23 @@ Value sendrawtransaction(const Array& params, bool fHelp) } uint256 hashTx = tx.GetHash(); - bool fHave = false; CCoinsViewCache &view = *pcoinsTip; CCoins existingCoins; - { - fHave = view.GetCoins(hashTx, existingCoins); - if (!fHave) { - // push to local node - CValidationState state; - if (!AcceptToMemoryPool(mempool, state, tx, false, NULL, !fOverrideFees)) - throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX rejected"); // TODO: report validation state + bool fHaveMempool = mempool.exists(hashTx); + bool fHaveChain = view.GetCoins(hashTx, existingCoins) && existingCoins.nHeight < 1000000000; + if (!fHaveMempool && !fHaveChain) { + // push to local node and sync with wallets + CValidationState state; + if (AcceptToMemoryPool(mempool, state, tx, false, NULL, !fOverrideFees)) + SyncWithWallets(hashTx, tx, NULL); + else { + if(state.IsInvalid()) + throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason())); + else + throw JSONRPCError(RPC_TRANSACTION_ERROR, state.GetRejectReason()); } - } - if (fHave) { - if (existingCoins.nHeight < 1000000000) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "transaction already in block chain"); - // Not in block, but already in the memory pool; will drop - // through to re-relay it. - } else { - SyncWithWallets(hashTx, tx, NULL); + } else if (fHaveChain) { + throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain"); } RelayTransaction(tx, hashTx); |