58 entry.
pushKV(
"confirmations", 0);
66 throw std::runtime_error(
67 "getrawtransaction \"txid\" ( verbose \"blockhash\" )\n" 69 "\nNOTE: By default this function only works for mempool transactions. If the -txindex option is\n" 70 "enabled, it also works for blockchain transactions. If the block which contains the transaction\n" 71 "is known, its hash can be provided even for nodes without -txindex. Note that if a blockhash is\n" 72 "provided, only that block will be searched and if the transaction is in the mempool or other\n" 73 "blocks, or if this node does not have the given block available, the transaction will not be found.\n" 74 "DEPRECATED: for now, it also works for transactions with unspent outputs.\n" 76 "\nReturn the raw transaction data.\n" 77 "\nIf verbose is 'true', returns an Object with information about 'txid'.\n" 78 "If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.\n" 81 "1. \"txid\" (string, required) The transaction id\n" 82 "2. verbose (bool, optional, default=false) If false, return a string, otherwise return a json object\n" 83 "3. \"blockhash\" (string, optional) The block in which to look for the transaction\n" 85 "\nResult (if verbose is not set or set to false):\n" 86 "\"data\" (string) The serialized, hex-encoded data for 'txid'\n" 88 "\nResult (if verbose is set to true):\n" 90 " \"in_active_chain\": b, (bool) Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)\n" 91 " \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n" 92 " \"txid\" : \"id\", (string) The transaction id (same as provided)\n" 93 " \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n" 94 " \"size\" : n, (numeric) The serialized transaction size\n" 95 " \"vsize\" : n, (numeric) The virtual transaction size (differs from size for witness transactions)\n" 96 " \"weight\" : n, (numeric) The transaction's weight (between vsize*4-3 and vsize*4)\n" 97 " \"version\" : n, (numeric) The version\n" 98 " \"locktime\" : ttt, (numeric) The lock time\n" 99 " \"vin\" : [ (array of json objects)\n" 101 " \"txid\": \"id\", (string) The transaction id\n" 102 " \"vout\": n, (numeric) \n" 103 " \"scriptSig\": { (json object) The script\n" 104 " \"asm\": \"asm\", (string) asm\n" 105 " \"hex\": \"hex\" (string) hex\n" 107 " \"sequence\": n (numeric) The script sequence number\n" 108 " \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n" 112 " \"vout\" : [ (array of json objects)\n" 114 " \"value\" : x.xxx, (numeric) The value in " +
CURRENCY_UNIT +
"\n" 115 " \"n\" : n, (numeric) index\n" 116 " \"scriptPubKey\" : { (json object)\n" 117 " \"asm\" : \"asm\", (string) the asm\n" 118 " \"hex\" : \"hex\", (string) the hex\n" 119 " \"reqSigs\" : n, (numeric) The required sigs\n" 120 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 121 " \"addresses\" : [ (json array of string)\n" 122 " \"address\" (string) bitcoin address\n" 129 " \"blockhash\" : \"hash\", (string) the block hash\n" 130 " \"confirmations\" : n, (numeric) The confirmations\n" 131 " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n" 132 " \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" 139 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" false \"myblockhash\"")
140 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" true \"myblockhash\"")
143 bool in_active_chain =
true;
147 if (hash ==
Params().GenesisBlock().hashMerkleRoot) {
153 bool fVerbose =
false;
169 bool f_txindex_ready =
false;
171 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
182 errmsg =
"No such transaction found in the provided block";
184 errmsg =
"No such mempool transaction. Use -txindex to enable blockchain transaction queries";
185 }
else if (!f_txindex_ready) {
186 errmsg =
"No such mempool transaction. Blockchain transactions are still in the process of being indexed";
188 errmsg =
"No such mempool or blockchain transaction";
198 if (blockindex) result.pushKV(
"in_active_chain", in_active_chain);
199 TxToJSON(*tx, hash_block, result);
206 throw std::runtime_error(
207 "gettxoutproof [\"txid\",...] ( blockhash )\n" 208 "\nReturns a hex-encoded proof that \"txid\" was included in a block.\n" 209 "\nNOTE: By default this function only works sometimes. This is when there is an\n" 210 "unspent output in the utxo for this transaction. To make it always work,\n" 211 "you need to maintain a transaction index, using the -txindex command line option or\n" 212 "specify the block in which the transaction is included manually (by blockhash).\n" 214 "1. \"txids\" (string) A json array of txids to filter\n" 216 " \"txid\" (string) A transaction hash\n" 219 "2. \"blockhash\" (string, optional) If specified, looks for txid in the block with this hash\n" 221 "\"data\" (string) A string that is a serialized, hex-encoded data for the proof.\n" 224 std::set<uint256> setTxids;
227 for (
unsigned int idx = 0; idx < txids.
size(); idx++) {
230 if (setTxids.count(hash))
232 setTxids.insert(hash);
249 for (
const auto& tx : setTxids) {
261 g_txindex->BlockUntilSyncedToCurrentChain();
266 if (pblockindex ==
nullptr)
281 unsigned int ntxFound = 0;
282 for (
const auto& tx : block.
vtx)
283 if (setTxids.count(tx->GetHash()))
285 if (ntxFound != setTxids.size())
291 std::string strHex =
HexStr(ssMB.begin(), ssMB.end());
298 throw std::runtime_error(
299 "verifytxoutproof \"proof\"\n" 300 "\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" 301 "and throwing an RPC error if the block is not in our best chain\n" 303 "1. \"proof\" (string, required) The hex-encoded proof generated by gettxoutproof\n" 305 "[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof can not be validated.\n" 314 std::vector<uint256> vMatch;
315 std::vector<unsigned int> vIndex;
316 if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot)
327 if (pindex->
nTx == merkleBlock.txn.GetNumTransactions()) {
328 for (
const uint256& hash : vMatch) {
329 res.push_back(hash.
GetHex());
342 const bool outputs_is_obj = outputs_in.
isObject();
348 int64_t nLockTime = locktime.
get_int64();
349 if (nLockTime < 0 || nLockTime > std::numeric_limits<uint32_t>::max())
354 bool rbfOptIn = rbf.
isTrue();
356 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
357 const UniValue& input = inputs[idx];
365 int nOutput = vout_v.
get_int();
371 nSequence = MAX_BIP125_RBF_SEQUENCE;
373 nSequence = std::numeric_limits<uint32_t>::max() - 1;
375 nSequence = std::numeric_limits<uint32_t>::max();
380 if (sequenceObj.
isNum()) {
381 int64_t seqNr64 = sequenceObj.
get_int64();
382 if (seqNr64 < 0 || seqNr64 > std::numeric_limits<uint32_t>::max()) {
385 nSequence = (uint32_t)seqNr64;
391 rawTx.
vin.push_back(in);
394 std::set<CTxDestination> destinations;
395 if (!outputs_is_obj) {
398 for (
size_t i = 0; i < outputs.
size(); ++i) {
399 const UniValue& output = outputs[i];
403 if (output.
size() != 1) {
408 outputs = std::move(outputs_dict);
410 for (
const std::string& name_ : outputs.
getKeys()) {
411 if (name_ ==
"data") {
412 std::vector<unsigned char> data =
ParseHexV(outputs[name_].getValStr(),
"Data");
415 rawTx.
vout.push_back(out);
422 if (!destinations.insert(destination).second) {
429 CTxOut out(nAmount, scriptPubKey);
430 rawTx.
vout.push_back(out);
444 throw std::runtime_error(
446 "createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] [{\"address\":amount},{\"data\":\"hex\"},...] ( locktime ) ( replaceable )\n" 447 "\nCreate a transaction spending the given inputs and creating new outputs.\n" 448 "Outputs can be addresses or data.\n" 449 "Returns hex-encoded raw transaction.\n" 450 "Note that the transaction's inputs are not signed, and\n" 451 "it is not stored in the wallet or transmitted to the network.\n" 454 "1. \"inputs\" (array, required) A json array of json objects\n" 457 " \"txid\":\"id\", (string, required) The transaction id\n" 458 " \"vout\":n, (numeric, required) The output number\n" 459 " \"sequence\":n (numeric, optional) The sequence number\n" 463 "2. \"outputs\" (array, required) a json array with outputs (key-value pairs)\n" 466 " \"address\": x.xxx, (obj, optional) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " +
CURRENCY_UNIT +
"\n" 469 " \"data\": \"hex\" (obj, optional) A key-value pair. The key must be \"data\", the value is hex-encoded data\n" 471 " ,... More key-value pairs of the above form. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" 472 " accepted as second parameter.\n" 474 "3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" 475 "4. replaceable (boolean, optional, default=false) Marks this transaction as BIP125-replaceable.\n" 476 " Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.\n" 478 "\"transaction\" (string) hex string of the transaction\n" 481 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
482 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
483 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
484 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
505 throw std::runtime_error(
506 "decoderawtransaction \"hexstring\" ( iswitness )\n" 507 "\nReturn a JSON object representing the serialized, hex-encoded transaction.\n" 510 "1. \"hexstring\" (string, required) The transaction hex string\n" 511 "2. iswitness (boolean, optional) Whether the transaction hex is a serialized witness transaction\n" 512 " If iswitness is not present, heuristic tests will be used in decoding\n" 516 " \"txid\" : \"id\", (string) The transaction id\n" 517 " \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n" 518 " \"size\" : n, (numeric) The transaction size\n" 519 " \"vsize\" : n, (numeric) The virtual transaction size (differs from size for witness transactions)\n" 520 " \"weight\" : n, (numeric) The transaction's weight (between vsize*4 - 3 and vsize*4)\n" 521 " \"version\" : n, (numeric) The version\n" 522 " \"locktime\" : ttt, (numeric) The lock time\n" 523 " \"vin\" : [ (array of json objects)\n" 525 " \"txid\": \"id\", (string) The transaction id\n" 526 " \"vout\": n, (numeric) The output number\n" 527 " \"scriptSig\": { (json object) The script\n" 528 " \"asm\": \"asm\", (string) asm\n" 529 " \"hex\": \"hex\" (string) hex\n" 531 " \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n" 532 " \"sequence\": n (numeric) The script sequence number\n" 536 " \"vout\" : [ (array of json objects)\n" 538 " \"value\" : x.xxx, (numeric) The value in " +
CURRENCY_UNIT +
"\n" 539 " \"n\" : n, (numeric) index\n" 540 " \"scriptPubKey\" : { (json object)\n" 541 " \"asm\" : \"asm\", (string) the asm\n" 542 " \"hex\" : \"hex\", (string) the hex\n" 543 " \"reqSigs\" : n, (numeric) The required sigs\n" 544 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 545 " \"addresses\" : [ (json array of string)\n" 546 " \"12tvKAXCxZjSmdNbao16dKXC8tRWfcF5oc\" (string) bitcoin address\n" 580 throw std::runtime_error(
581 "decodescript \"hexstring\"\n" 582 "\nDecode a hex-encoded script.\n" 584 "1. \"hexstring\" (string) the hex-encoded script\n" 587 " \"asm\":\"asm\", (string) Script public key\n" 588 " \"hex\":\"hex\", (string) hex-encoded public key\n" 589 " \"type\":\"type\", (string) The output type\n" 590 " \"reqSigs\": n, (numeric) The required signatures\n" 591 " \"addresses\": [ (json array of string)\n" 592 " \"address\" (string) bitcoin address\n" 595 " \"p2sh\",\"address\" (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).\n" 607 std::vector<unsigned char> scriptData(
ParseHexV(request.
params[0],
"argument"));
608 script =
CScript(scriptData.begin(), scriptData.end());
624 std::vector<std::vector<unsigned char>> solutions_data;
629 for (
const auto& solution : solutions_data) {
648 r.pushKV(
"segwit", sr);
656 static void TxInErrorToJSON(
const CTxIn& txin,
UniValue& vErrorsRet,
const std::string& strMessage)
665 entry.
pushKV(
"witness", witness);
668 entry.
pushKV(
"error", strMessage);
676 throw std::runtime_error(
677 "combinerawtransaction [\"hexstring\",...]\n" 678 "\nCombine multiple partially signed transactions into one transaction.\n" 679 "The combined transaction may be another partially signed transaction or a \n" 680 "fully signed transaction." 683 "1. \"txs\" (string) A json array of hex strings of partially signed transactions\n" 685 " \"hexstring\" (string) A transaction hash\n" 690 "\"hex\" (string) The hex-encoded raw transaction with signature(s)\n" 693 +
HelpExampleCli(
"combinerawtransaction",
"[\"myhex1\", \"myhex2\", \"myhex3\"]")
698 std::vector<CMutableTransaction> txVariants(txs.
size());
700 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
701 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str(),
true)) {
706 if (txVariants.empty()) {
722 view.SetBackend(viewMempool);
724 for (
const CTxIn& txin : mergedTx.vin) {
728 view.SetBackend(viewDummy);
735 for (
unsigned int i = 0; i < mergedTx.vin.size(); i++) {
736 CTxIn& txin = mergedTx.vin[i];
745 if (txv.vin.size() > i) {
776 if (!prevTxsUnival.
isNull()) {
778 for (
unsigned int idx = 0; idx < prevTxs.
size(); ++idx) {
801 std::vector<unsigned char> pkData(
ParseHexO(prevOut,
"scriptPubKey"));
802 CScript scriptPubKey(pkData.begin(), pkData.end());
807 std::string err(
"Previous output scriptPubKey mismatch:\n");
815 if (prevOut.
exists(
"amount")) {
819 view.
AddCoin(out, std::move(newcoin),
true);
823 if (is_temp_keystore && (scriptPubKey.IsPayToScriptHash() || scriptPubKey.IsPayToWitnessScriptHash())) {
830 std::vector<unsigned char> rsData(
ParseHexV(v,
"redeemScript"));
831 CScript redeemScript(rsData.begin(), rsData.end());
851 for (
unsigned int i = 0; i < mtx.
vin.size(); i++) {
855 TxInErrorToJSON(txin, vErrors,
"Input not found or already spent");
863 if (!fHashSingle || (i < mtx.
vout.size())) {
878 TxInErrorToJSON(txin, vErrors,
"Unable to sign input, invalid stack size (possibly missing key)");
884 bool fComplete = vErrors.
empty();
888 result.
pushKV(
"complete", fComplete);
889 if (!vErrors.
empty()) {
890 result.
pushKV(
"errors", vErrors);
899 throw std::runtime_error(
900 "signrawtransactionwithkey \"hexstring\" [\"privatekey1\",...] ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] sighashtype )\n" 901 "\nSign inputs for raw transaction (serialized, hex-encoded).\n" 902 "The second argument is an array of base58-encoded private\n" 903 "keys that will be the only keys used to sign the transaction.\n" 904 "The third optional argument (may be null) is an array of previous transaction outputs that\n" 905 "this transaction depends on but may not yet be in the block chain.\n" 908 "1. \"hexstring\" (string, required) The transaction hex string\n" 909 "2. \"privkeys\" (string, required) A json array of base58-encoded private keys for signing\n" 910 " [ (json array of strings)\n" 911 " \"privatekey\" (string) private key in base58-encoding\n" 914 "3. \"prevtxs\" (string, optional) An json array of previous dependent transaction outputs\n" 915 " [ (json array of json objects, or 'null' if none provided)\n" 917 " \"txid\":\"id\", (string, required) The transaction id\n" 918 " \"vout\":n, (numeric, required) The output number\n" 919 " \"scriptPubKey\": \"hex\", (string, required) script key\n" 920 " \"redeemScript\": \"hex\", (string, required for P2SH or P2WSH) redeem script\n" 921 " \"amount\": value (numeric, required) The amount spent\n" 925 "4. \"sighashtype\" (string, optional, default=ALL) The signature hash type. Must be one of:\n" 929 " \"ALL|ANYONECANPAY\"\n" 930 " \"NONE|ANYONECANPAY\"\n" 931 " \"SINGLE|ANYONECANPAY\"\n" 935 " \"hex\" : \"value\", (string) The hex-encoded raw transaction with signature(s)\n" 936 " \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n" 937 " \"errors\" : [ (json array of objects) Script verification errors (if there are any)\n" 939 " \"txid\" : \"hash\", (string) The hash of the referenced, previous transaction\n" 940 " \"vout\" : n, (numeric) The index of the output to spent and used as input\n" 941 " \"scriptSig\" : \"hex\", (string) The hex-encoded signature script\n" 942 " \"sequence\" : n, (numeric) Script sequence number\n" 943 " \"error\" : \"text\" (string) Verification or signing error related to the input\n" 954 RPCTypeCheck(request.
params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR},
true);
963 for (
unsigned int idx = 0; idx < keys.
size(); ++idx) {
980 "Clients should transition to using signrawtransactionwithkey and signrawtransactionwithwallet");
986 throw std::runtime_error(
987 "sendrawtransaction \"hexstring\" ( allowhighfees )\n" 988 "\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n" 989 "\nAlso see createrawtransaction and signrawtransactionwithkey calls.\n" 991 "1. \"hexstring\" (string, required) The hex string of the raw transaction)\n" 992 "2. allowhighfees (boolean, optional, default=false) Allow high fees\n" 994 "\"hex\" (string) The transaction hash in hex\n" 996 "\nCreate a transaction\n" 997 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
998 "Sign the transaction, and get back the hex\n" 1000 "\nSend the transaction (signed hex)\n" 1002 "\nAs a JSON-RPC call\n" 1006 std::promise<void> promise;
1015 const uint256& hashTx = tx->GetHash();
1024 bool fHaveChain =
false;
1025 for (
size_t o = 0; !fHaveChain && o < tx->vout.size(); o++) {
1027 fHaveChain = !existingCoin.
IsSpent();
1030 if (!fHaveMempool && !fHaveChain) {
1033 bool fMissingInputs;
1035 nullptr ,
false , nMaxRawTxFee)) {
1039 if (fMissingInputs) {
1051 promise.set_value();
1054 }
else if (fHaveChain) {
1059 promise.set_value();
1064 promise.get_future().wait();
1081 throw std::runtime_error(
1083 "testmempoolaccept [\"rawtxs\"] ( allowhighfees )\n" 1084 "\nReturns if raw transaction (serialized, hex-encoded) would be accepted by mempool.\n" 1085 "\nThis checks if the transaction violates the consensus or policy rules.\n" 1086 "\nSee sendrawtransaction call.\n" 1088 "1. [\"rawtxs\"] (array, required) An array of hex strings of raw transactions.\n" 1089 " Length must be one for now.\n" 1090 "2. allowhighfees (boolean, optional, default=false) Allow high fees\n" 1092 "[ (array) The result of the mempool acceptance test for each raw transaction in the input array.\n" 1093 " Length is exactly one for now.\n" 1095 " \"txid\" (string) The transaction hash in hex\n" 1096 " \"allowed\" (boolean) If the mempool allows this tx to be inserted\n" 1097 " \"reject-reason\" (string) Rejection string (only present when 'allowed' is false)\n" 1101 "\nCreate a transaction\n" 1102 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
1103 "Sign the transaction, and get back the hex\n" 1105 "\nTest acceptance of the transaction (signed hex)\n" 1107 "\nAs a JSON-RPC call\n" 1123 const uint256& tx_hash = tx->GetHash();
1132 result_0.pushKV(
"txid", tx_hash.
GetHex());
1135 bool missing_inputs;
1136 bool test_accept_res;
1140 nullptr ,
false , max_raw_tx_fee,
true);
1142 result_0.pushKV(
"allowed", test_accept_res);
1143 if (!test_accept_res) {
1146 }
else if (missing_inputs) {
1147 result_0.pushKV(
"reject-reason",
"missing-inputs");
1153 result.push_back(std::move(result_0));
1157 static std::string WriteHDKeypath(std::vector<uint32_t>& keypath)
1159 std::string keypath_str =
"m";
1160 for (uint32_t num : keypath) {
1162 bool hardened =
false;
1163 if (num & 0x80000000) {
1168 keypath_str += std::to_string(num);
1179 throw std::runtime_error(
1180 "decodepsbt \"psbt\"\n" 1181 "\nReturn a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.\n" 1184 "1. \"psbt\" (string, required) The PSBT base64 string\n" 1188 " \"tx\" : { (json object) The decoded network-serialized unsigned transaction.\n" 1189 " ... The layout is the same as the output of decoderawtransaction.\n" 1191 " \"unknown\" : { (json object) The unknown global fields\n" 1192 " \"key\" : \"value\" (key-value pair) An unknown key-value pair\n" 1195 " \"inputs\" : [ (array of json objects)\n" 1197 " \"non_witness_utxo\" : { (json object, optional) Decoded network transaction for non-witness UTXOs\n" 1200 " \"witness_utxo\" : { (json object, optional) Transaction output for witness UTXOs\n" 1201 " \"amount\" : x.xxx, (numeric) The value in " +
CURRENCY_UNIT +
"\n" 1202 " \"scriptPubKey\" : { (json object)\n" 1203 " \"asm\" : \"asm\", (string) The asm\n" 1204 " \"hex\" : \"hex\", (string) The hex\n" 1205 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 1206 " \"address\" : \"address\" (string) BSHA3 address if there is one\n" 1209 " \"partial_signatures\" : { (json object, optional)\n" 1210 " \"pubkey\" : \"signature\", (string) The public key and signature that corresponds to it.\n" 1213 " \"sighash\" : \"type\", (string, optional) The sighash type to be used\n" 1214 " \"redeem_script\" : { (json object, optional)\n" 1215 " \"asm\" : \"asm\", (string) The asm\n" 1216 " \"hex\" : \"hex\", (string) The hex\n" 1217 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 1219 " \"witness_script\" : { (json object, optional)\n" 1220 " \"asm\" : \"asm\", (string) The asm\n" 1221 " \"hex\" : \"hex\", (string) The hex\n" 1222 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 1224 " \"bip32_derivs\" : { (json object, optional)\n" 1225 " \"pubkey\" : { (json object, optional) The public key with the derivation path as the value.\n" 1226 " \"master_fingerprint\" : \"fingerprint\" (string) The fingerprint of the master key\n" 1227 " \"path\" : \"path\", (string) The path\n" 1231 " \"final_scriptsig\" : { (json object, optional)\n" 1232 " \"asm\" : \"asm\", (string) The asm\n" 1233 " \"hex\" : \"hex\", (string) The hex\n" 1235 " \"final_scriptwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n" 1236 " \"unknown\" : { (json object) The unknown global fields\n" 1237 " \"key\" : \"value\" (key-value pair) An unknown key-value pair\n" 1243 " \"outputs\" : [ (array of json objects)\n" 1245 " \"redeem_script\" : { (json object, optional)\n" 1246 " \"asm\" : \"asm\", (string) The asm\n" 1247 " \"hex\" : \"hex\", (string) The hex\n" 1248 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 1250 " \"witness_script\" : { (json object, optional)\n" 1251 " \"asm\" : \"asm\", (string) The asm\n" 1252 " \"hex\" : \"hex\", (string) The hex\n" 1253 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 1255 " \"bip32_derivs\" : [ (array of json objects, optional)\n" 1257 " \"pubkey\" : \"pubkey\", (string) The public key this path corresponds to\n" 1258 " \"master_fingerprint\" : \"fingerprint\" (string) The fingerprint of the master key\n" 1259 " \"path\" : \"path\", (string) The path\n" 1264 " \"unknown\" : { (json object) The unknown global fields\n" 1265 " \"key\" : \"value\" (key-value pair) An unknown key-value pair\n" 1271 " \"fee\" : fee (numeric, optional) The transaction fee paid if all UTXOs slots in the PSBT have been filled.\n" 1292 result.
pushKV(
"tx", tx_univ);
1296 for (
auto entry : psbtx.
unknown) {
1299 result.
pushKV(
"unknown", unknowns);
1303 bool have_all_utxos =
true;
1305 for (
unsigned int i = 0; i < psbtx.
inputs.size(); ++i) {
1315 total_in += txout.
nValue;
1319 out.
pushKV(
"scriptPubKey", o);
1320 in.
pushKV(
"witness_utxo", out);
1324 in.
pushKV(
"non_witness_utxo", non_wit);
1327 have_all_utxos =
false;
1336 in.
pushKV(
"partial_signatures", partial_sigs);
1348 in.
pushKV(
"redeem_script", r);
1353 in.
pushKV(
"witness_script", r);
1363 keypath.
pushKV(
"master_fingerprint",
strprintf(
"%08x", ReadBE32(entry.second.fingerprint)));
1364 keypath.
pushKV(
"path", WriteHDKeypath(entry.second.path));
1367 in.
pushKV(
"bip32_derivs", keypaths);
1375 in.
pushKV(
"final_scriptSig", scriptsig);
1382 in.
pushKV(
"final_scriptwitness", txinwitness);
1386 if (input.
unknown.size() > 0) {
1388 for (
auto entry : input.
unknown) {
1391 in.
pushKV(
"unknown", unknowns);
1396 result.
pushKV(
"inputs", inputs);
1401 for (
unsigned int i = 0; i < psbtx.
outputs.size(); ++i) {
1408 out.
pushKV(
"redeem_script", r);
1413 out.
pushKV(
"witness_script", r);
1422 keypath.
pushKV(
"master_fingerprint",
strprintf(
"%08x", ReadBE32(entry.second.fingerprint)));
1423 keypath.
pushKV(
"path", WriteHDKeypath(entry.second.path));
1426 out.
pushKV(
"bip32_derivs", keypaths);
1430 if (output.
unknown.size() > 0) {
1432 for (
auto entry : output.
unknown) {
1435 out.
pushKV(
"unknown", unknowns);
1441 output_value += psbtx.
tx->vout[i].nValue;
1443 result.
pushKV(
"outputs", outputs);
1444 if (have_all_utxos) {
1454 throw std::runtime_error(
1455 "combinepsbt [\"psbt\",...]\n" 1456 "\nCombine multiple partially signed Bitcoin transactions into one transaction.\n" 1457 "Implements the Combiner role.\n" 1459 "1. \"txs\" (string) A json array of base64 strings of partially signed transactions\n" 1461 " \"psbt\" (string) A base64 string of a PSBT\n" 1466 " \"psbt\" (string) The base64-encoded partially signed transaction\n" 1468 +
HelpExampleCli(
"combinepsbt",
"[\"mybase64_1\", \"mybase64_2\", \"mybase64_3\"]")
1474 std::vector<PartiallySignedTransaction> psbtxs;
1476 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1482 psbtxs.push_back(psbtx);
1488 for (
auto it = std::next(psbtxs.begin()); it != psbtxs.end(); ++it) {
1489 if (*it != merged_psbt) {
1492 merged_psbt.
Merge(*it);
1494 if (!merged_psbt.
IsSane()) {
1500 ssTx << merged_psbt;
1507 throw std::runtime_error(
1508 "finalizepsbt \"psbt\" ( extract )\n" 1509 "Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n" 1510 "network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n" 1511 "created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.\n" 1512 "Implements the Finalizer and Extractor roles.\n" 1514 "1. \"psbt\" (string) A base64 string of a PSBT\n" 1515 "2. \"extract\" (boolean, optional, default=true) If true and the transaction is complete, \n" 1516 " extract and return the complete transaction in normal network serialization instead of the PSBT.\n" 1520 " \"psbt\" : \"value\", (string) The base64-encoded partially signed transaction if not extracted\n" 1521 " \"hex\" : \"value\", (string) The hex-encoded network transaction if extracted\n" 1522 " \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n" 1540 bool complete =
true;
1541 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
1552 for (
unsigned int i = 0; i < mtx.
vin.size(); ++i) {
1553 mtx.
vin[i].scriptSig = psbtx.
inputs[i].final_script_sig;
1554 mtx.
vin[i].scriptWitness = psbtx.
inputs[i].final_script_witness;
1562 result.
pushKV(
"complete", complete);
1570 throw std::runtime_error(
1571 "createpsbt [{\"txid\":\"id\",\"vout\":n},...] [{\"address\":amount},{\"data\":\"hex\"},...] ( locktime ) ( replaceable )\n" 1572 "\nCreates a transaction in the Partially Signed Transaction format.\n" 1573 "Implements the Creator role.\n" 1575 "1. \"inputs\" (array, required) A json array of json objects\n" 1578 " \"txid\":\"id\", (string, required) The transaction id\n" 1579 " \"vout\":n, (numeric, required) The output number\n" 1580 " \"sequence\":n (numeric, optional) The sequence number\n" 1584 "2. \"outputs\" (array, required) a json array with outputs (key-value pairs)\n" 1587 " \"address\": x.xxx, (obj, optional) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " +
CURRENCY_UNIT +
"\n" 1590 " \"data\": \"hex\" (obj, optional) A key-value pair. The key must be \"data\", the value is hex-encoded data\n" 1592 " ,... More key-value pairs of the above form. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" 1593 " accepted as second parameter.\n" 1595 "3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" 1596 "4. replaceable (boolean, optional, default=false) Marks this transaction as BIP125 replaceable.\n" 1597 " Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.\n" 1599 " \"psbt\" (string) The resulting raw transaction (base64-encoded string)\n" 1601 +
HelpExampleCli(
"createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
1618 for (
unsigned int i = 0; i < rawTx.
vin.size(); ++i) {
1621 for (
unsigned int i = 0; i < rawTx.
vout.size(); ++i) {
1635 throw std::runtime_error(
1636 "converttopsbt \"hexstring\" ( permitsigdata iswitness )\n" 1637 "\nConverts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n" 1638 "createpsbt and walletcreatefundedpsbt should be used for new applications.\n" 1640 "1. \"hexstring\" (string, required) The hex string of a raw transaction\n" 1641 "2. permitsigdata (boolean, optional, default=false) If true, any signatures in the input will be discarded and conversion.\n" 1642 " will continue. If false, RPC will fail if any signatures are present.\n" 1643 "3. iswitness (boolean, optional) Whether the transaction hex is a serialized witness transaction.\n" 1644 " If iswitness is not present, heuristic tests will be used in decoding. If true, only witness deserializaion\n" 1645 " will be tried. If false, only non-witness deserialization will be tried. Only has an effect if\n" 1646 " permitsigdata is true.\n" 1648 " \"psbt\" (string) The resulting raw transaction (base64-encoded string)\n" 1650 "\nCreate a transaction\n" 1651 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1652 "\nConvert the transaction to a PSBT\n" 1657 RPCTypeCheck(request.
params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL},
true);
1663 bool iswitness = witness_specified ? request.
params[2].
get_bool() :
false;
1664 bool try_witness = permitsigdata ? (witness_specified ? iswitness :
true) :
false;
1665 bool try_no_witness = permitsigdata ? (witness_specified ? !iswitness :
true) :
true;
1682 for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
1685 for (
unsigned int i = 0; i < tx.
vout.size(); ++i) {
1700 {
"rawtransactions",
"getrawtransaction", &getrawtransaction, {
"txid",
"verbose",
"blockhash"} },
1701 {
"rawtransactions",
"createrawtransaction", &createrawtransaction, {
"inputs",
"outputs",
"locktime",
"replaceable"} },
1702 {
"rawtransactions",
"decoderawtransaction", &decoderawtransaction, {
"hexstring",
"iswitness"} },
1703 {
"rawtransactions",
"decodescript", &decodescript, {
"hexstring"} },
1704 {
"rawtransactions",
"sendrawtransaction", &sendrawtransaction, {
"hexstring",
"allowhighfees"} },
1705 {
"rawtransactions",
"combinerawtransaction", &combinerawtransaction, {
"txs"} },
1706 {
"hidden",
"signrawtransaction", &
signrawtransaction, {
"hexstring",
"prevtxs",
"privkeys",
"sighashtype"} },
1707 {
"rawtransactions",
"signrawtransactionwithkey", &signrawtransactionwithkey, {
"hexstring",
"privkeys",
"prevtxs",
"sighashtype"} },
1708 {
"rawtransactions",
"testmempoolaccept", &testmempoolaccept, {
"rawtxs",
"allowhighfees"} },
1709 {
"rawtransactions",
"decodepsbt", &
decodepsbt, {
"psbt"} },
1710 {
"rawtransactions",
"combinepsbt", &
combinepsbt, {
"txs"} },
1711 {
"rawtransactions",
"finalizepsbt", &
finalizepsbt, {
"psbt",
"extract"} },
1712 {
"rawtransactions",
"createpsbt", &
createpsbt, {
"inputs",
"outputs",
"locktime",
"replaceable"} },
1713 {
"rawtransactions",
"converttopsbt", &
converttopsbt, {
"hexstring",
"permitsigdata",
"iswitness"} },
1715 {
"blockchain",
"gettxoutproof", &gettxoutproof, {
"txids",
"blockhash"} },
1716 {
"blockchain",
"verifytxoutproof", &verifytxoutproof, {
"proof"} },
1722 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++)
const Coin & AccessByTxid(const CCoinsViewCache &view, const uint256 &txid)
Utility function to find any unspent output with a given txid.
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
Aliases for backward compatibility.
uint256 ParseHashO(const UniValue &o, std::string strKey)
std::vector< unsigned char > ParseHexO(const UniValue &o, std::string strKey)
void AddCoin(const COutPoint &outpoint, Coin &&coin, bool potential_overwrite)
Add a coin.
bool GetTransaction(const uint256 &hash, CTransactionRef &txOut, const Consensus::Params &consensusParams, uint256 &hashBlock, bool fAllowSlow, CBlockIndex *blockIndex)
Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock...
Bitcoin RPC command dispatcher.
int64_t GetBlockTime() const
enum ScriptError_t ScriptError
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or a pruned one if not found.
void SetBackend(CCoinsView &viewIn)
boost::optional< CMutableTransaction > tx
CAmount maxTxFee
Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendra...
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
CScriptWitness scriptWitness
Only serialized through CTransaction.
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
int Height() const
Return the maximal height in the chain.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CTxOut out
unspent transaction output
UniValue converttopsbt(const JSONRPCRequest &request)
UniValue ValueFromAmount(const CAmount &amount)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
bool AddCScript(const CScript &redeemScript) override
Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki.
std::vector< std::vector< unsigned char > > stack
const std::string & get_str() const
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const UniValue & get_array() const
const std::string CURRENCY_UNIT
txnouttype Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
A version of CTransaction with the PSBT format.
Double ended buffer combining vector and stream-like interfaces.
int64_t get_int64() const
std::string ToString() const
A signature creator for transactions.
bool pushKVs(const UniValue &obj)
const std::vector< std::string > & getKeys() const
std::shared_ptr< const CTransaction > CTransactionRef
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
UniValue finalizepsbt(const JSONRPCRequest &request)
void PushInventory(const CInv &inv)
Invalid, missing or duplicate parameter.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
const UniValue & find_value(const UniValue &obj, const std::string &name)
UniValue decodepsbt(const JSONRPCRequest &request)
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool *pfMissingInputs, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, const CAmount nAbsurdFee, bool test_accept)
(try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions repla...
bool DecodePSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
const char * ScriptErrorString(const ScriptError serror)
std::unique_ptr< CCoinsViewCache > pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
int64_t CAmount
Amount in satoshis (Can be negative)
A structure for PSBTs which contains per output information.
General error during transaction or block submission.
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
std::vector< PSBTOutput > outputs
std::map< CPubKey, KeyOriginInfo > hd_keypaths
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
bool push_back(const UniValue &val)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Abstract view on the open txout dataset.
bool exists(const uint256 &hash) const
int ParseSighashString(const UniValue &sighash)
An input of a transaction.
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
bool exists(const std::string &key) const
bool AddKey(const CKey &key)
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
An encapsulated public key.
std::string GetRejectReason() const
Unexpected type was passed as parameter.
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
std::string SighashToStr(unsigned char sighash_type)
General application defined errors.
bool pushKV(const std::string &key, const UniValue &val)
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
void CallFunctionInValidationInterfaceQueue(std::function< void()> func)
Pushes a function to callback onto the notification queue, guaranteeing any callbacks generated prior...
An output of a transaction.
void MergeSignatureData(SignatureData sigdata)
std::string ToString() const
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
CAmount AmountFromValue(const UniValue &value)
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
std::vector< PSBTInput > inputs
void RegisterRawTransactionRPCCommands(CRPCTable &t)
Register raw transaction RPC commands.
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string strName)
RPC method is deprecated.
Capture information about block/transaction validation.
#define extract(n)
Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits.
CTxDestination DecodeDestination(const std::string &str)
std::vector< CTransactionRef > vtx
std::string FormatStateMessage(const CValidationState &state)
Convert CValidationState to a human-readable message for logging.
const_iterator end() const
UniValue combinepsbt(const JSONRPCRequest &request)
const_iterator begin() const
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn, const CTxOut &txout)
Extract signature data from a transaction input, and insert it.
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
int RPCSerializationFlags()
bool SignalsOptInRBF(const CTransaction &tx)
const UniValue & get_obj() const
void UpdateInput(CTxIn &input, const SignatureData &data)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
std::string GetHex() const
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
UniValue SignTransaction(CMutableTransaction &mtx, const UniValue &prevTxsUnival, CBasicKeyStore *keystore, bool is_temp_keystore, const UniValue &hashType)
Sign a transaction with the given keystore and previous transactions.
std::unique_ptr< CConnman > g_connman
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
bool error(const char *fmt, const Args &... args)
unsigned int GetRejectCode() const
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
A reference to a CScript: the Hash360 of its serialization (see script.h)
std::string EncodeDestination(const CTxDestination &dest)
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, const UniValue &rbf)
Create a transaction from univalue parameters.
A mutable version of CTransaction.
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0)
UniValue signrawtransaction(const JSONRPCRequest &request)
UniValue JSONRPCError(int code, const std::string &message)
No valid connection manager instance found.
An encapsulated private key.
const SigningProvider & DUMMY_SIGNING_PROVIDER
The basic transaction that is broadcasted on the network and contained in blocks. ...
int nHeight
height of the entry in the chain. The genesis block has height 0
Information about a peer.
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
CKey DecodeSecret(const std::string &str)
CCoinsView that adds a memory cache for transactions to another CCoinsView.
void Merge(const PartiallySignedTransaction &psbt)
full block available in blk*.dat
bool SignPSBTInput(const SigningProvider &provider, const CMutableTransaction &tx, PSBTInput &input, int index, int sighash)
Signs a PSBTInput, verifying that all provided data matches what is being signed. ...
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
uint160 Hash360(const T1 pbegin, const T1 pend)
Compute the 160-bit hash an object.
UniValue createpsbt(const JSONRPCRequest &request)
CCoinsView that brings transactions from a mempool into view.
CScript GetScriptForWitness(const CScript &redeemscript)
Generate a pay-to-witness script for the given redeem script.
Basic key store, that keeps keys in an address->secret map.
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
Wrapper for UniValue::VType, which includes typeAny: Used to denote don't care type.
unsigned int nTx
Number of transactions in this block.
Error parsing or validating structure in raw format.
std::string EncodeBase64(const unsigned char *pch, size_t len)
bool IsValid() const
Check whether this private key is valid.
bool IsCompressed() const
Check whether this is a compressed public key.
CBlockIndex * LookupBlockIndex(const uint256 &hash)