Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
// Copyright (c) 2010 Satoshi Nakamoto | // Copyright (c) 2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <compat/byteswap.h> | #include <compat/byteswap.h> | ||||
#include <config.h> | #include <config.h> | ||||
#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 <key_io.h> | #include <key_io.h> | ||||
#include <keystore.h> | #include <keystore.h> | ||||
#include <merkleblock.h> | #include <merkleblock.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <rpc/rawtransaction.h> | #include <rpc/rawtransaction.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <rpc/util.h> | |||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <script/script_error.h> | #include <script/script_error.h> | ||||
#include <script/sign.h> | #include <script/sign.h> | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
▲ Show 20 Lines • Show All 800 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < mergedTx.vin.size(); i++) { | ||||
txout.scriptPubKey, sigdata); | txout.scriptPubKey, sigdata); | ||||
UpdateInput(txin, sigdata); | UpdateInput(txin, sigdata); | ||||
} | } | ||||
return EncodeHexTx(CTransaction(mergedTx)); | return EncodeHexTx(CTransaction(mergedTx)); | ||||
} | } | ||||
UniValue SignTransaction(CMutableTransaction &mtx, | UniValue SignTransaction(interfaces::Chain &chain, CMutableTransaction &mtx, | ||||
const UniValue &prevTxsUnival, | const UniValue &prevTxsUnival, | ||||
CBasicKeyStore *keystore, bool is_temp_keystore, | CBasicKeyStore *keystore, bool is_temp_keystore, | ||||
const UniValue &hashType) { | const UniValue &hashType) { | ||||
// Fetch previous transactions (inputs): | // Fetch previous transactions (inputs): | ||||
CCoinsView viewDummy; | CCoinsView viewDummy; | ||||
CCoinsViewCache view(&viewDummy); | CCoinsViewCache view(&viewDummy); | ||||
{ | { | ||||
LOCK2(cs_main, g_mempool.cs); | LOCK2(cs_main, g_mempool.cs); | ||||
▲ Show 20 Lines • Show All 259 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(mtx, request.params[2], &keystore, true, | return SignTransaction(*g_rpc_interfaces->chain, mtx, request.params[2], | ||||
request.params[3]); | &keystore, 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( | throw std::runtime_error( | ||||
"sendrawtransaction \"hexstring\" ( allowhighfees )\n" | "sendrawtransaction \"hexstring\" ( allowhighfees )\n" | ||||
▲ Show 20 Lines • Show All 799 Lines • Show Last 20 Lines |