Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | if (!hashBlock.IsNull()) { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static UniValue getrawtransaction(const Config &config, | static UniValue getrawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getrawtransaction", | "getrawtransaction", | ||||
"\nBy default this function only works for mempool transactions. When " | "By default this function only works for mempool transactions. When " | ||||
"called with a blockhash\n" | "called with a blockhash\n" | ||||
"argument, getrawtransaction will return the transaction if the " | "argument, getrawtransaction will return the transaction if the " | ||||
"specified block is available and\n" | "specified block is available and\n" | ||||
"the transaction is found in that block. When called without a " | "the transaction is found in that block. When called without a " | ||||
"blockhash argument, getrawtransaction\n" | "blockhash argument, getrawtransaction\n" | ||||
"will return the transaction if it is in the mempool, or if -txindex " | "will return the transaction if it is in the mempool, or if -txindex " | ||||
"is enabled and the transaction\n" | "is enabled and the transaction\n" | ||||
"is in a block in the blockchain.\n" | "is in a block in the blockchain.\n" | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | static UniValue getrawtransaction(const Config &config, | ||||
TxToJSON(*tx, hash_block, result); | TxToJSON(*tx, hash_block, result); | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue gettxoutproof(const Config &config, | static UniValue gettxoutproof(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"gettxoutproof", | "gettxoutproof", | ||||
"\nReturns a hex-encoded proof that \"txid\" was included in a block.\n" | "Returns a hex-encoded proof that \"txid\" was included in a block.\n" | ||||
"\nNOTE: By default this function only works sometimes. " | "\nNOTE: By default this function only works sometimes. " | ||||
"This is when there is an\n" | "This is when there is an\n" | ||||
"unspent output in the utxo for this transaction. To make it always " | "unspent output in the utxo for this transaction. To make it always " | ||||
"work,\n" | "work,\n" | ||||
"you need to maintain a transaction index, using the -txindex command " | "you need to maintain a transaction index, using the -txindex command " | ||||
"line option or\n" | "line option or\n" | ||||
"specify the block in which the transaction is included manually (by " | "specify the block in which the transaction is included manually (by " | ||||
"blockhash).\n", | "blockhash).\n", | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | static UniValue gettxoutproof(const Config &config, | ||||
std::string strHex = HexStr(ssMB.begin(), ssMB.end()); | std::string strHex = HexStr(ssMB.begin(), ssMB.end()); | ||||
return strHex; | return strHex; | ||||
} | } | ||||
static UniValue verifytxoutproof(const Config &config, | static UniValue verifytxoutproof(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"verifytxoutproof", | "verifytxoutproof", | ||||
"\nVerifies that a proof points to a transaction in a block, returning " | "Verifies that a proof points to a transaction in a block, returning " | ||||
"the transaction it commits to\n" | "the transaction it commits to\n" | ||||
"and throwing an RPC error if the block is not in our best chain\n", | "and throwing an RPC error if the block is not in our best chain\n", | ||||
{ | { | ||||
{"proof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"proof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The hex-encoded proof generated by gettxoutproof"}, | "The hex-encoded proof generated by gettxoutproof"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"[\"txid\"] (array, strings) The txid(s) which the proof " | "[\"txid\"] (array, strings) The txid(s) which the proof " | ||||
Show All 33 Lines | static UniValue verifytxoutproof(const Config &config, | ||||
return res; | return res; | ||||
} | } | ||||
static UniValue createrawtransaction(const Config &config, | static UniValue createrawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"createrawtransaction", | "createrawtransaction", | ||||
"\nCreate a transaction spending the given inputs and creating new " | "Create a transaction spending the given inputs and creating new " | ||||
"outputs.\n" | "outputs.\n" | ||||
"Outputs can be addresses or data.\n" | "Outputs can be addresses or data.\n" | ||||
"Returns hex-encoded raw transaction.\n" | "Returns hex-encoded raw transaction.\n" | ||||
"Note that the transaction's inputs are not signed, and\n" | "Note that the transaction's inputs are not signed, and\n" | ||||
"it is not stored in the wallet or transmitted to the network.\n", | "it is not stored in the wallet or transmitted to the network.\n", | ||||
{ | { | ||||
{ | { | ||||
"inputs", | "inputs", | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | static UniValue createrawtransaction(const Config &config, | ||||
return EncodeHexTx(CTransaction(rawTx)); | return EncodeHexTx(CTransaction(rawTx)); | ||||
} | } | ||||
static UniValue decoderawtransaction(const Config &config, | static UniValue decoderawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"decoderawtransaction", | "decoderawtransaction", | ||||
"\nReturn a JSON object representing the serialized, hex-encoded " | "Return a JSON object representing the serialized, hex-encoded " | ||||
"transaction.\n", | "transaction.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The transaction hex string"}, | "The transaction hex string"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | "{\n" | ||||
" \"txid\" : \"id\", (string) The transaction id\n" | " \"txid\" : \"id\", (string) The transaction id\n" | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static UniValue decoderawtransaction(const Config &config, | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue decodescript(const Config &config, | static UniValue decodescript(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"decodescript", | "decodescript", | ||||
"\nDecode a hex-encoded script.\n", | "Decode a hex-encoded script.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hex-encoded script"}, | "the hex-encoded script"}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{"{\n" | ||||
" \"asm\":\"asm\", (string) Script public key\n" | " \"asm\":\"asm\", (string) Script public key\n" | ||||
" \"hex\":\"hex\", (string) hex-encoded public key\n" | " \"hex\":\"hex\", (string) hex-encoded public key\n" | ||||
" \"type\":\"type\", (string) The output type\n" | " \"type\":\"type\", (string) The output type\n" | ||||
Show All 36 Lines | static UniValue decodescript(const Config &config, | ||||
return r; | return r; | ||||
} | } | ||||
static UniValue combinerawtransaction(const Config &config, | static UniValue combinerawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"combinerawtransaction", | "combinerawtransaction", | ||||
"\nCombine multiple partially signed transactions into one " | "Combine multiple partially signed transactions into one " | ||||
"transaction.\n" | "transaction.\n" | ||||
"The combined transaction may be another partially signed transaction " | "The combined transaction may be another partially signed transaction " | ||||
"or a \n" | "or a \n" | ||||
"fully signed transaction.", | "fully signed transaction.", | ||||
{ | { | ||||
{ | { | ||||
"txs", | "txs", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static UniValue combinerawtransaction(const Config &config, | ||||
return EncodeHexTx(CTransaction(mergedTx)); | return EncodeHexTx(CTransaction(mergedTx)); | ||||
} | } | ||||
static UniValue signrawtransactionwithkey(const Config &config, | static UniValue signrawtransactionwithkey(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"signrawtransactionwithkey", | "signrawtransactionwithkey", | ||||
"\nSign inputs for raw transaction (serialized, hex-encoded).\n" | "Sign inputs for raw transaction (serialized, hex-encoded).\n" | ||||
"The second argument is an array of base58-encoded private\n" | "The second argument is an array of base58-encoded private\n" | ||||
"keys that will be the only keys used to sign the transaction.\n" | "keys that will be the only keys used to sign the transaction.\n" | ||||
"The third optional argument (may be null) is an array of previous " | "The third optional argument (may be null) is an array of previous " | ||||
"transaction outputs that\n" | "transaction outputs that\n" | ||||
"this transaction depends on but may not yet be in the block chain.\n", | "this transaction depends on but may not yet be in the block chain.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The transaction hex string"}, | "The transaction hex string"}, | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | static UniValue signrawtransactionwithkey(const Config &config, | ||||
return SignTransaction(mtx, &keystore, coins, request.params[3]); | return SignTransaction(mtx, &keystore, coins, request.params[3]); | ||||
} | } | ||||
static UniValue sendrawtransaction(const Config &config, | static UniValue sendrawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"sendrawtransaction", | "sendrawtransaction", | ||||
"\nSubmits raw transaction (serialized, hex-encoded) to local node and " | "Submits raw transaction (serialized, hex-encoded) to local node and " | ||||
"network.\n" | "network.\n" | ||||
"\nAlso see createrawtransaction and " | "\nAlso see createrawtransaction and " | ||||
"signrawtransactionwithkey calls.\n", | "signrawtransactionwithkey calls.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The hex string of the raw transaction"}, | "The hex string of the raw transaction"}, | ||||
{"maxfeerate", RPCArg::Type::AMOUNT, | {"maxfeerate", RPCArg::Type::AMOUNT, | ||||
/* default */ FormatMoney(DEFAULT_MAX_RAW_TX_FEE), | /* default */ FormatMoney(DEFAULT_MAX_RAW_TX_FEE), | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | static UniValue sendrawtransaction(const Config &config, | ||||
return tx->GetHash().GetHex(); | return tx->GetHash().GetHex(); | ||||
} | } | ||||
static UniValue testmempoolaccept(const Config &config, | static UniValue testmempoolaccept(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"testmempoolaccept", | "testmempoolaccept", | ||||
"\nReturns if raw transaction (serialized, hex-encoded) would be " | "Returns if raw transaction (serialized, hex-encoded) would be " | ||||
"accepted by mempool.\n" | "accepted by mempool.\n" | ||||
"\nThis checks if the transaction violates the consensus or policy " | "\nThis checks if the transaction violates the consensus or policy " | ||||
"rules.\n" | "rules.\n" | ||||
"\nSee sendrawtransaction call.\n", | "\nSee sendrawtransaction call.\n", | ||||
{ | { | ||||
{ | { | ||||
"rawtxs", | "rawtxs", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | static std::string WriteHDKeypath(std::vector<uint32_t> &keypath) { | ||||
} | } | ||||
return keypath_str; | return keypath_str; | ||||
} | } | ||||
static UniValue decodepsbt(const Config &config, | static UniValue decodepsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"decodepsbt", | "decodepsbt", | ||||
"\nReturn a JSON object representing the serialized, base64-encoded " | "Return a JSON object representing the serialized, base64-encoded " | ||||
"partially signed Bitcoin transaction.\n", | "partially signed Bitcoin transaction.\n", | ||||
{ | { | ||||
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The PSBT base64 string"}, | "The PSBT base64 string"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | "{\n" | ||||
" \"tx\" : { (json object) The decoded " | " \"tx\" : { (json object) The decoded " | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | static UniValue decodepsbt(const Config &config, | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue combinepsbt(const Config &config, | static UniValue combinepsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"combinepsbt", | "combinepsbt", | ||||
"\nCombine multiple partially signed Bitcoin transactions into one " | "Combine multiple partially signed Bitcoin transactions into one " | ||||
"transaction.\n" | "transaction.\n" | ||||
"Implements the Combiner role.\n", | "Implements the Combiner role.\n", | ||||
{ | { | ||||
{ | { | ||||
"txs", | "txs", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
RPCArg::Optional::NO, | RPCArg::Optional::NO, | ||||
"A json array of base64 strings of partially signed " | "A json array of base64 strings of partially signed " | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | static UniValue finalizepsbt(const Config &config, | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue createpsbt(const Config &config, | static UniValue createpsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"createpsbt", | "createpsbt", | ||||
"\nCreates a transaction in the Partially Signed Transaction format.\n" | "Creates a transaction in the Partially Signed Transaction format.\n" | ||||
"Implements the Creator role.\n", | "Implements the Creator role.\n", | ||||
{ | { | ||||
{ | { | ||||
"inputs", | "inputs", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
RPCArg::Optional::NO, | RPCArg::Optional::NO, | ||||
"A json array of json objects", | "A json array of json objects", | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | static UniValue createpsbt(const Config &config, | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | ||||
} | } | ||||
static UniValue converttopsbt(const Config &config, | static UniValue converttopsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"converttopsbt", | "converttopsbt", | ||||
"\nConverts a network serialized transaction to a PSBT. " | "Converts a network serialized transaction to a PSBT. " | ||||
"This should be used only with createrawtransaction and " | "This should be used only with createrawtransaction and " | ||||
"fundrawtransaction\n" | "fundrawtransaction\n" | ||||
"createpsbt and walletcreatefundedpsbt should be used for new " | "createpsbt and walletcreatefundedpsbt should be used for new " | ||||
"applications.\n", | "applications.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The hex string of a raw transaction"}, | "The hex string of a raw transaction"}, | ||||
{"permitsigdata", RPCArg::Type::BOOL, /* default */ "false", | {"permitsigdata", RPCArg::Type::BOOL, /* default */ "false", | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | static UniValue converttopsbt(const Config &config, | ||||
ssTx << psbtx; | ssTx << psbtx; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | ||||
} | } | ||||
UniValue utxoupdatepsbt(const Config &config, const JSONRPCRequest &request) { | UniValue utxoupdatepsbt(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"utxoupdatepsbt", | "utxoupdatepsbt", | ||||
"\nUpdates all inputs and outputs in a PSBT with data from output " | "Updates all inputs and outputs in a PSBT with data from output " | ||||
"descriptors, the UTXO set or the mempool.\n", | "descriptors, the UTXO set or the mempool.\n", | ||||
{ | { | ||||
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"A base64 string of a PSBT"}, | "A base64 string of a PSBT"}, | ||||
{"descriptors", | {"descriptors", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
RPCArg::Optional::OMITTED_NAMED_ARG, | RPCArg::Optional::OMITTED_NAMED_ARG, | ||||
"An array of either strings or objects", | "An array of either strings or objects", | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | UniValue utxoupdatepsbt(const Config &config, const JSONRPCRequest &request) { | ||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssTx << psbtx; | ssTx << psbtx; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | ||||
} | } | ||||
UniValue joinpsbts(const Config &config, const JSONRPCRequest &request) { | UniValue joinpsbts(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"joinpsbts", | "joinpsbts", | ||||
"\nJoins multiple distinct PSBTs with different inputs and outputs " | "Joins multiple distinct PSBTs with different inputs and outputs " | ||||
"into one PSBT with inputs and outputs from all of the PSBTs\n" | "into one PSBT with inputs and outputs from all of the PSBTs\n" | ||||
"No input in any of the PSBTs can be in more than one of the PSBTs.\n", | "No input in any of the PSBTs can be in more than one of the PSBTs.\n", | ||||
{{"txs", | {{"txs", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
RPCArg::Optional::NO, | RPCArg::Optional::NO, | ||||
"A json array of base64 strings of partially signed transactions", | "A json array of base64 strings of partially signed transactions", | ||||
{{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | {{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"A base64 string of a PSBT"}}}}, | "A base64 string of a PSBT"}}}}, | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | UniValue joinpsbts(const Config &config, const JSONRPCRequest &request) { | ||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssTx << shuffled_psbt; | ssTx << shuffled_psbt; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | ||||
} | } | ||||
UniValue analyzepsbt(const Config &config, const JSONRPCRequest &request) { | UniValue analyzepsbt(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"analyzepsbt", | "analyzepsbt", | ||||
"\nAnalyzes and provides information about the current status of a " | "Analyzes and provides information about the current status of a " | ||||
"PSBT and its inputs\n", | "PSBT and its inputs\n", | ||||
{{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | {{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"A base64 string of a PSBT"}}, | "A base64 string of a PSBT"}}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | "{\n" | ||||
" \"inputs\" : [ (array of json objects)\n" | " \"inputs\" : [ (array of json objects)\n" | ||||
" {\n" | " {\n" | ||||
" \"has_utxo\" : true|false (boolean) Whether a UTXO is " | " \"has_utxo\" : true|false (boolean) Whether a UTXO is " | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |