Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show All 11 Lines | |||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <core_io.h> | #include <core_io.h> | ||||
#include <index/txindex.h> | #include <index/txindex.h> | ||||
#include <init.h> | #include <init.h> | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <key_io.h> | #include <key_io.h> | ||||
#include <keystore.h> | #include <keystore.h> | ||||
#include <merkleblock.h> | #include <merkleblock.h> | ||||
#include <node/coin.h> | |||||
#include <node/psbt.h> | #include <node/psbt.h> | ||||
#include <node/transaction.h> | #include <node/transaction.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <policy/settings.h> | #include <policy/settings.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <psbt.h> | #include <psbt.h> | ||||
#include <rpc/rawtransaction_util.h> | #include <rpc/rawtransaction_util.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
▲ Show 20 Lines • Show All 859 Lines • ▼ Show 20 Lines | for (size_t idx = 0; idx < keys.size(); ++idx) { | ||||
CKey key = DecodeSecret(k.get_str()); | CKey key = DecodeSecret(k.get_str()); | ||||
if (!key.IsValid()) { | if (!key.IsValid()) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid private key"); | "Invalid private key"); | ||||
} | } | ||||
keystore.AddKey(key); | keystore.AddKey(key); | ||||
} | } | ||||
return SignTransaction(*g_rpc_node->chain, mtx, request.params[2], | // Fetch previous transactions (inputs): | ||||
&keystore, true, request.params[3]); | std::map<COutPoint, Coin> coins; | ||||
for (const CTxIn &txin : mtx.vin) { | |||||
// Create empty map entry keyed by prevout. | |||||
coins[txin.prevout]; | |||||
} | |||||
FindCoins(coins); | |||||
return SignTransaction(mtx, request.params[2], &keystore, coins, true, | |||||
request.params[3]); | |||||
} | } | ||||
static UniValue sendrawtransaction(const Config &config, | static UniValue sendrawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"sendrawtransaction", | "sendrawtransaction", | ||||
▲ Show 20 Lines • Show All 1,085 Lines • Show Last 20 Lines |