43 #include <event2/http.h>
63 int confirms =
wallet.GetTxDepthInMainChain(wtx);
64 entry.pushKV(
"confirmations", confirms);
65 if (wtx.IsCoinBase()) {
66 entry.pushKV(
"generated",
true);
69 entry.pushKV(
"blockhash", wtx.m_confirm.hashBlock.GetHex());
70 entry.pushKV(
"blockheight", wtx.m_confirm.block_height);
71 entry.pushKV(
"blockindex", wtx.m_confirm.nIndex);
75 entry.pushKV(
"blocktime", block_time);
80 entry.pushKV(
"txid", hash.
GetHex());
85 entry.pushKV(
"walletconflicts", conflicts);
86 entry.pushKV(
"time", wtx.GetTxTime());
87 entry.pushKV(
"timereceived", (int64_t)wtx.nTimeReceived);
89 for (
const std::pair<const std::string, std::string> &item : wtx.mapValue) {
90 entry.pushKV(item.first, item.second);
97 "Returns a new Bitcoin address for receiving payments.\n"
98 "If 'label' is specified, it is added to the address book \n"
99 "so payments received with the address will be associated with "
103 "The label name for the address to be linked to. If not provided, "
104 "the default label \"\" is used. It can also be set to the empty "
105 "string \"\" to represent the default label. The label does not "
106 "need to exist, it will be created if there is no label by the "
109 "set by -addresstype",
110 "The address type to use. Options are \"legacy\"."},
117 std::shared_ptr<CWallet>
const wallet =
128 "Error: This wallet has no available keys");
134 if (!request.params[0].isNull()) {
139 if (!request.params[1].isNull()) {
144 request.params[1].get_str()));
161 "getrawchangeaddress",
162 "Returns a new Bitcoin address, for receiving change.\n"
163 "This is for use with raw transactions, NOT normal use.\n",
170 std::shared_ptr<CWallet>
const wallet =
181 "Error: This wallet has no available keys");
186 if (!request.params[0].isNull()) {
191 request.params[0].get_str()));
208 "Sets the label associated with the given address.\n",
211 "The bitcoin address to be associated with a label."},
213 "The label to assign to the address."},
218 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") +
221 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")},
224 std::shared_ptr<CWallet>
const wallet =
234 wallet->GetChainParams());
237 "Invalid Bitcoin address");
242 if (pwallet->
IsMine(dest)) {
254 const UniValue &subtract_fee_outputs,
255 std::vector<CRecipient> &recipients,
257 std::set<CTxDestination> destinations;
259 for (
const std::string &address : address_amounts.
getKeys()) {
263 std::string(
"Invalid Bitcoin address: ") +
267 if (destinations.count(dest)) {
270 std::string(
"Invalid parameter, duplicated address: ") +
273 destinations.insert(dest);
278 bool subtract_fee =
false;
279 for (
unsigned int idx = 0; idx < subtract_fee_outputs.
size(); idx++) {
280 const UniValue &addr = subtract_fee_outputs[idx];
281 if (addr.
get_str() == address) {
286 CRecipient recipient = {script_pub_key, amount, subtract_fee};
287 recipients.push_back(recipient);
292 std::vector<CRecipient> &recipients,
mapValue_t map_value) {
300 int nChangePosRet = -1;
304 *pwallet, recipients, tx, nFeeRequired, nChangePosRet,
error,
311 return tx->GetId().GetHex();
320 "The bitcoin address to send to."},
324 "A comment used to store what the transaction is for.\n"
325 " This is not part of the "
326 "transaction, just kept in your wallet."},
329 "A comment to store the name of the person or organization\n"
330 " to which you're sending the "
331 "transaction. This is not part of the \n"
332 " transaction, just kept in "
336 "The fee will be deducted from the amount being sent.\n"
337 " The recipient will receive "
338 "less bitcoins than you enter in the amount field."},
341 "(only available if avoid_reuse wallet flag is set) Avoid "
342 "spending from dirty addresses; addresses are considered\n"
343 " dirty if they have previously "
344 "been used in a transaction."},
349 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
350 HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
351 "dd\" 100000 \"donation\" \"seans "
354 "Jvaydd\" 100000 \"\" \"\" true") +
356 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
357 "dd\", 100000, \"donation\", \"seans "
361 std::shared_ptr<CWallet>
const wallet =
371 pwallet->BlockUntilSyncedToCurrentChain();
377 if (!request.params[2].isNull() &&
378 !request.params[2].get_str().empty()) {
379 mapValue[
"comment"] = request.params[2].get_str();
381 if (!request.params[3].isNull() &&
382 !request.params[3].get_str().empty()) {
383 mapValue[
"to"] = request.params[3].get_str();
386 bool fSubtractFeeFromAmount =
false;
387 if (!request.params[4].isNull()) {
388 fSubtractFeeFromAmount = request.params[4].get_bool();
401 const std::string address = request.params[0].get_str();
402 address_amounts.
pushKV(address, request.params[1]);
404 if (fSubtractFeeFromAmount) {
405 subtractFeeFromAmount.
push_back(address);
408 std::vector<CRecipient> recipients;
410 wallet->GetChainParams());
412 return SendMoney(pwallet, coin_control, recipients, mapValue);
419 "listaddressgroupings",
420 "Lists groups of addresses which have had their common ownership\n"
421 "made public by common use as inputs or as the resulting change\n"
422 "in past transactions\n",
437 "The bitcoin address"},
449 std::shared_ptr<CWallet>
const wallet =
459 pwallet->BlockUntilSyncedToCurrentChain();
464 std::map<CTxDestination, Amount> balances =
466 for (
const std::set<CTxDestination> &grouping :
472 addressInfo.
push_back(balances[address]);
474 const auto *address_book_entry =
476 if (address_book_entry) {
477 addressInfo.
push_back(address_book_entry->GetLabel());
484 return jsonGroupings;
492 std::set<CTxDestination> address_set;
497 address_set =
wallet.GetLabelAddresses(label);
504 "Invalid Bitcoin address");
507 if (!
wallet.IsMine(script_pub_key)) {
510 address_set.insert(dest);
515 if (!params[1].
isNull()) {
516 min_depth = params[1].get_int();
521 for (
const std::pair<const TxId, CWalletTx> &wtx_pair :
wallet.mapWallet) {
527 for (
const CTxOut &txout : wtx.
tx->vout) {
530 wallet.IsMine(address) && address_set.count(address)) {
541 "getreceivedbyaddress",
542 "Returns the total amount received by the given address in "
543 "transactions with at least minconf confirmations.\n",
546 "The bitcoin address for transactions."},
548 "Only include transactions confirmed at least this many times."},
552 " received at this address."},
554 "\nThe amount from transactions with at least 1 confirmation\n" +
556 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
557 "\nThe amount including unconfirmed transactions, zero "
560 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
561 "\nThe amount with at least 6 confirmations\n" +
563 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
564 "\nAs a JSON-RPC call\n" +
566 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")},
569 std::shared_ptr<CWallet>
const wallet =
579 pwallet->BlockUntilSyncedToCurrentChain();
591 "getreceivedbylabel",
592 "Returns the total amount received by addresses with <label> in "
593 "transactions with at least [minconf] confirmations.\n",
596 "The selected label, may be the default label using \"\"."},
598 "Only include transactions confirmed at least this many times."},
602 " received for this label."},
603 RPCExamples{
"\nAmount received by the default label with at least 1 "
606 "\nAmount received at the tabby label including "
607 "unconfirmed amounts with zero confirmations\n" +
609 "\nThe amount with at least 6 confirmations\n" +
611 "\nAs a JSON-RPC call\n" +
615 std::shared_ptr<CWallet>
const wallet =
625 pwallet->BlockUntilSyncedToCurrentChain();
638 "Returns the total available balance.\n"
639 "The available balance is what the wallet considers currently "
640 "spendable, and is\n"
641 "thus affected by options which limit spendability such as "
642 "-spendzeroconfchange.\n",
645 "Remains for backward compatibility. Must be excluded or set to "
648 "Only include transactions confirmed at least this many times."},
650 "true for watch-only wallets, otherwise false",
651 "Also include balance in watch-only addresses (see "
655 "(only available if avoid_reuse wallet flag is set) Do not "
656 "include balance in dirty outputs; addresses are considered dirty "
657 "if they have previously been used in a transaction."},
661 " received for this wallet."},
663 "\nThe total amount in the wallet with 0 or more confirmations\n" +
665 "\nThe total amount in the wallet with at least 6 confirmations\n" +
666 HelpExampleCli(
"getbalance",
"\"*\" 6") +
"\nAs a JSON-RPC call\n" +
670 std::shared_ptr<CWallet>
const wallet =
680 pwallet->BlockUntilSyncedToCurrentChain();
684 const UniValue &dummy_value = request.params[0];
688 "dummy first argument must be excluded or set to \"*\".");
692 if (!request.params[1].isNull()) {
693 min_depth = request.params[1].get_int();
696 bool include_watchonly =
701 const auto bal =
GetBalance(*pwallet, min_depth, avoid_reuse);
703 return bal.m_mine_trusted + (include_watchonly
704 ? bal.m_watchonly_trusted
712 "getunconfirmedbalance",
713 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
719 std::shared_ptr<CWallet>
const wallet =
729 pwallet->BlockUntilSyncedToCurrentChain();
741 "Send multiple times. Amounts are double-precision "
742 "floating point numbers." +
746 "Must be set to \"\" for backwards compatibility.",
"\"\""},
751 "The addresses and amounts",
754 "The bitcoin address is the key, the numeric amount (can "
760 "Only use the balance confirmed at least this many times."},
768 " The fee will be equally deducted "
769 "from the amount of each selected address.\n"
770 " Those recipients will receive less "
771 "bitcoins than you enter in their corresponding amount field.\n"
772 " If no addresses are specified "
773 "here, the sender pays the fee.",
776 "Subtract fee from this address"},
781 "The transaction id for the send. Only 1 transaction is "
782 "created regardless of the number of addresses."},
784 "\nSend two amounts to two different addresses:\n" +
788 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
790 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
792 "\nSend two amounts to two different addresses setting the "
793 "confirmation and comment:\n" +
797 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
799 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
802 "\nSend two amounts to two different addresses, subtract fee "
807 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
809 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
811 "\"[\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\","
812 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\"]"
814 "\nAs a JSON-RPC call\n" +
818 "{\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\":0.01,"
819 "\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\":0.02}, "
824 std::shared_ptr<CWallet>
const wallet =
834 pwallet->BlockUntilSyncedToCurrentChain();
838 if (!request.params[0].isNull() &&
839 !request.params[0].get_str().empty()) {
841 "Dummy value must be set to \"\"");
846 if (!request.params[3].isNull() &&
847 !request.params[3].get_str().empty()) {
848 mapValue[
"comment"] = request.params[3].
get_str();
852 if (!request.params[4].isNull()) {
853 subtractFeeFromAmount = request.params[4].
get_array();
856 std::vector<CRecipient> recipients;
858 wallet->GetChainParams());
861 return SendMoney(pwallet, coin_control, recipients,
862 std::move(mapValue));
869 "addmultisigaddress",
870 "Add an nrequired-to-sign multisignature address to the wallet. "
871 "Requires a new wallet backup.\n"
872 "Each key is a Bitcoin address or hex-encoded public key.\n"
873 "This functionality is only intended for use with non-watchonly "
875 "See `importaddress` for watchonly p2sh address support.\n"
876 "If 'label' is specified (DEPRECATED), assign address to that label.\n",
879 "The number of required signatures out of the n keys or "
885 "The bitcoin addresses or hex-encoded public keys",
888 "bitcoin address or hex-encoded public key"},
892 "A label to assign the addresses to."},
899 "The value of the new multisig address"},
901 "The string value of the hex-encoded redemption script"},
903 "The descriptor for this multisig"},
906 "\nAdd a multisig address from 2 addresses\n" +
909 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
910 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
911 "\nAs a JSON-RPC call\n" +
914 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
915 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")},
918 std::shared_ptr<CWallet>
const wallet =
931 if (!request.params[2].isNull()) {
935 int required = request.params[0].get_int();
939 std::vector<CPubKey> pubkeys;
940 for (
size_t i = 0; i < keys_or_addrs.
size(); ++i) {
941 if (
IsHex(keys_or_addrs[i].get_str()) &&
942 (keys_or_addrs[i].get_str().length() == 66 ||
943 keys_or_addrs[i].get_str().length() == 130)) {
957 required, pubkeys, output_type, spk_man, inner);
961 std::unique_ptr<Descriptor> descriptor =
967 result.
pushKV(
"descriptor", descriptor->ToString());
975 int nConf{std::numeric_limits<int>::max()};
982 const UniValue ¶ms,
bool by_label)
986 if (!params[0].
isNull()) {
987 nMinDepth = params[0].get_int();
991 bool fIncludeEmpty =
false;
992 if (!params[1].
isNull()) {
993 fIncludeEmpty = params[1].get_bool();
1001 bool has_filtered_address =
false;
1003 if (!by_label && params.size() > 3) {
1005 pwallet->GetChainParams())) {
1007 "address_filter parameter was invalid");
1011 has_filtered_address =
true;
1015 std::map<CTxDestination, tallyitem> mapTally;
1016 for (
const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) {
1023 int nDepth = pwallet->GetTxDepthInMainChain(wtx);
1024 if (nDepth < nMinDepth) {
1028 for (
const CTxOut &txout : wtx.
tx->vout) {
1034 if (has_filtered_address && !(filtered_address == address)) {
1039 if (!(mine & filter)) {
1055 std::map<std::string, tallyitem> label_tally;
1059 auto start = pwallet->m_address_book.begin();
1060 auto end = pwallet->m_address_book.end();
1062 if (has_filtered_address) {
1063 start = pwallet->m_address_book.find(filtered_address);
1065 end = std::next(start);
1069 for (
auto item_it = start; item_it != end; ++item_it) {
1070 if (item_it->second.IsChange()) {
1074 const std::string &label = item_it->second.GetLabel();
1075 std::map<CTxDestination, tallyitem>::iterator it =
1076 mapTally.find(address);
1077 if (it == mapTally.end() && !fIncludeEmpty) {
1082 int nConf = std::numeric_limits<int>::max();
1083 bool fIsWatchonly =
false;
1084 if (it != mapTally.end()) {
1085 nAmount = (*it).second.nAmount;
1086 nConf = (*it).second.nConf;
1087 fIsWatchonly = (*it).second.fIsWatchonly;
1098 obj.
pushKV(
"involvesWatchonly",
true);
1101 obj.
pushKV(
"amount", nAmount);
1102 obj.
pushKV(
"confirmations",
1103 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1104 obj.
pushKV(
"label", label);
1106 if (it != mapTally.end()) {
1107 for (
const uint256 &_item : (*it).second.txids) {
1111 obj.
pushKV(
"txids", transactions);
1117 for (
const auto &entry : label_tally) {
1118 Amount nAmount = entry.second.nAmount;
1119 int nConf = entry.second.nConf;
1121 if (entry.second.fIsWatchonly) {
1122 obj.
pushKV(
"involvesWatchonly",
true);
1124 obj.
pushKV(
"amount", nAmount);
1125 obj.
pushKV(
"confirmations",
1126 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1127 obj.
pushKV(
"label", entry.first);
1137 "listreceivedbyaddress",
1138 "List balances by receiving address.\n",
1141 "The minimum number of confirmations before payments are "
1144 "Whether to include addresses that haven't received any "
1147 "true for watch-only wallets, otherwise false",
1148 "Whether to include watch-only addresses (see 'importaddress')."},
1151 "If present, only return information on this address."},
1163 "Only returns true if imported addresses were involved "
1168 " received by the address"},
1170 "The number of confirmations of the most recent "
1171 "transaction included"},
1173 "The label of the receiving address. The default label "
1180 "The ids of transactions received with the address"},
1189 "listreceivedbyaddress",
1190 "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")},
1193 std::shared_ptr<CWallet>
const wallet =
1203 pwallet->BlockUntilSyncedToCurrentChain();
1207 return ListReceived(config, pwallet, request.params,
false);
1214 "listreceivedbylabel",
1215 "List received transactions by label.\n",
1218 "The minimum number of confirmations before payments are "
1221 "Whether to include labels that haven't received any payments."},
1223 "true for watch-only wallets, otherwise false",
1224 "Whether to include watch-only addresses (see 'importaddress')."},
1236 "Only returns true if imported addresses were involved "
1239 "The total amount received by addresses with this label"},
1241 "The number of confirmations of the most recent "
1242 "transaction included"},
1244 "The label of the receiving address. The default label "
1253 std::shared_ptr<CWallet>
const wallet =
1263 pwallet->BlockUntilSyncedToCurrentChain();
1267 return ListReceived(config, pwallet, request.params,
true);
1291 int nMinDepth,
bool fLong,
UniValue &ret,
1293 const std::string *filter_label)
1296 std::list<COutputEntry> listReceived;
1297 std::list<COutputEntry> listSent;
1305 if (!filter_label) {
1308 if (involvesWatchonly ||
1310 entry.
pushKV(
"involvesWatchonly",
true);
1313 entry.
pushKV(
"category",
"send");
1314 entry.
pushKV(
"amount", -s.amount);
1315 const auto *address_book_entry =
1316 pwallet->FindAddressBookEntry(s.destination);
1317 if (address_book_entry) {
1318 entry.
pushKV(
"label", address_book_entry->GetLabel());
1320 entry.
pushKV(
"vout", s.vout);
1321 entry.
pushKV(
"fee", -1 * nFee);
1325 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1326 ret.push_back(entry);
1331 if (listReceived.size() > 0 &&
1332 pwallet->GetTxDepthInMainChain(wtx) >= nMinDepth) {
1335 const auto *address_book_entry =
1336 pwallet->FindAddressBookEntry(r.destination);
1337 if (address_book_entry) {
1338 label = address_book_entry->GetLabel();
1340 if (filter_label && label != *filter_label) {
1344 if (involvesWatchonly ||
1346 entry.
pushKV(
"involvesWatchonly",
true);
1349 if (wtx.IsCoinBase()) {
1350 if (pwallet->GetTxDepthInMainChain(wtx) < 1) {
1351 entry.
pushKV(
"category",
"orphan");
1352 }
else if (pwallet->IsTxImmatureCoinBase(wtx)) {
1353 entry.
pushKV(
"category",
"immature");
1355 entry.
pushKV(
"category",
"generate");
1358 entry.
pushKV(
"category",
"receive");
1360 entry.
pushKV(
"amount", r.amount);
1361 if (address_book_entry) {
1362 entry.
pushKV(
"label", label);
1364 entry.
pushKV(
"vout", r.vout);
1368 ret.push_back(entry);
1376 "The number of confirmations for the transaction. Negative "
1377 "confirmations means the\n"
1378 "transaction conflicted that many blocks ago."},
1380 "Only present if transaction only input is a coinbase one."},
1382 "Only present if we consider transaction to be trusted and so safe to "
1385 "The block hash containing the transaction."},
1387 "The block height containing the transaction."},
1389 "The index of the transaction in the block that includes it."},
1395 "Conflicting transaction ids.",
1404 "If a comment is associated with the transaction, only present if not "
1413 "If a label name is provided, this will return only incoming "
1414 "transactions paying to addresses with the specified label.\n"
1415 "\nReturns up to 'count' most recent transactions skipping the first "
1416 "'from' transactions.\n",
1420 "If set, should be a valid label name to return only incoming "
1421 "transactions with the specified label, or \"*\" to disable "
1422 "filtering and return all transactions."},
1424 "The number of transactions to return"},
1426 "The number of transactions to skip"},
1428 "true for watch-only wallets, otherwise false",
1429 "Include transactions to watch-only addresses (see "
1430 "'importaddress')"},
1438 Cat(
Cat<std::vector<RPCResult>>(
1441 "Only returns true if imported addresses were "
1442 "involved in transaction."},
1444 "The bitcoin address of the transaction."},
1446 "The transaction category.\n"
1447 "\"send\" Transactions sent.\n"
1448 "\"receive\" Non-coinbase "
1449 "transactions received.\n"
1450 "\"generate\" Coinbase transactions "
1451 "received with more than 100 confirmations.\n"
1452 "\"immature\" Coinbase transactions "
1453 "received with 100 or fewer confirmations.\n"
1454 "\"orphan\" Orphaned coinbase "
1455 "transactions received."},
1457 "The amount in " + ticker +
1458 ". This is negative for the 'send' category, "
1460 "for all other categories"},
1462 "A comment for the address/transaction, if any"},
1465 "The amount of the fee in " + ticker +
1466 ". This is negative and only available for "
1468 "'send' category of transactions."},
1473 "'true' if the transaction has been abandoned "
1474 "(inputs are respendable). Only available for the \n"
1475 "'send' category of transactions."},
1478 RPCExamples{
"\nList the most recent 10 transactions in the systems\n" +
1480 "\nList transactions 100 to 120\n" +
1482 "\nAs a JSON-RPC call\n" +
1486 std::shared_ptr<CWallet>
const wallet =
1496 pwallet->BlockUntilSyncedToCurrentChain();
1498 const std::string *filter_label =
nullptr;
1499 if (!request.params[0].isNull() &&
1500 request.params[0].get_str() !=
"*") {
1501 filter_label = &request.params[0].get_str();
1502 if (filter_label->empty()) {
1505 "Label argument must be a valid label name or \"*\".");
1509 if (!request.params[1].isNull()) {
1510 nCount = request.params[1].get_int();
1514 if (!request.params[2].isNull()) {
1515 nFrom = request.params[2].get_int();
1537 for (CWallet::TxItems::const_reverse_iterator it =
1539 it != txOrdered.rend(); ++it) {
1543 if (
int(ret.
size()) >= (nCount + nFrom)) {
1551 if (nFrom > (
int)ret.
size()) {
1554 if ((nFrom + nCount) > (
int)ret.
size()) {
1555 nCount = ret.
size() - nFrom;
1558 const std::vector<UniValue> &txs = ret.
getValues();
1562 {txs.rend() - nFrom - nCount, txs.rend() - nFrom});
1572 "Get all transactions in blocks since block [blockhash], or all "
1573 "transactions if omitted.\n"
1574 "If \"blockhash\" is no longer a part of the main chain, transactions "
1575 "from the fork point onward are included.\n"
1576 "Additionally, if include_removed is set, transactions affecting the "
1577 "wallet which were removed are returned in the \"removed\" array.\n",
1581 "If set, the block hash to list transactions since, otherwise "
1582 "list all transactions."},
1584 "Return the nth block hash from the main chain. e.g. 1 would mean "
1585 "the best block hash. Note: this is not used as a filter, but "
1586 "only affects [lastblock] in the return value"},
1588 "true for watch-only wallets, otherwise false",
1589 "Include transactions to watch-only addresses (see "
1590 "'importaddress')"},
1592 "Show transactions that were removed due to a reorg in the "
1593 "\"removed\" array\n"
1595 "guaranteed to work on pruned nodes)"},
1607 Cat(
Cat<std::vector<RPCResult>>(
1610 "Only returns true if imported addresses "
1611 "were involved in transaction."},
1613 "The bitcoin address of the transaction."},
1615 "The transaction category.\n"
1616 "\"send\" Transactions "
1618 "\"receive\" Non-coinbase "
1619 "transactions received.\n"
1620 "\"generate\" Coinbase "
1621 "transactions received with more than 100 "
1623 "\"immature\" Coinbase "
1624 "transactions received with 100 or fewer "
1626 "\"orphan\" Orphaned "
1627 "coinbase transactions received."},
1629 "The amount in " + ticker +
1630 ". This is negative for the 'send' "
1631 "category, and is positive\n"
1632 "for all other categories"},
1636 "The amount of the fee in " + ticker +
1637 ". This is negative and only available "
1639 "'send' category of transactions."},
1644 "'true' if the transaction has been abandoned "
1645 "(inputs are respendable). Only available for "
1647 "'send' category of transactions."},
1649 "If a comment is associated with the "
1652 "A comment for the address/transaction, if any"},
1654 "If a comment to is associated with the "
1660 "<structure is the same as \"transactions\" above, only "
1661 "present if include_removed=true>\n"
1662 "Note: transactions that were re-added in the active chain "
1663 "will appear as-is in this array, and may thus have a "
1664 "positive confirmation count.",
1669 "The hash of the block (target_confirmations-1) from the best "
1670 "block on the main chain, or the genesis hash if the "
1671 "referenced block does not exist yet. This is typically used "
1672 "to feed back into listsinceblock the next time you call it. "
1673 "So you would generally use a target_confirmations of say 6, "
1674 "so you will be continually re-notified of transactions until "
1675 "they've reached 6 confirmations plus any new ones"},
1679 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1680 "7d38571037cdb1a57f663ad\" 6") +
1682 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1683 "7d38571037cdb1a57f663ad\", 6")},
1686 std::shared_ptr<CWallet>
const pwallet =
1697 wallet.BlockUntilSyncedToCurrentChain();
1703 std::optional<int> height;
1707 std::optional<int> altheight;
1708 int target_confirms = 1;
1712 if (!request.params[0].isNull() &&
1713 !request.params[0].get_str().empty()) {
1717 if (!
wallet.chain().findCommonAncestor(
1718 blockId,
wallet.GetLastBlockHash(),
1726 if (!request.params[1].isNull()) {
1727 target_confirms = request.params[1].get_int();
1729 if (target_confirms < 1) {
1731 "Invalid parameter");
1739 bool include_removed =
1740 (request.params[3].isNull() || request.params[3].get_bool());
1742 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1746 for (
const std::pair<const TxId, CWalletTx> &pairWtx :
1750 if (depth == -1 ||
wallet.GetTxDepthInMainChain(tx) < depth) {
1759 while (include_removed && altheight && *altheight > *height) {
1761 if (!
wallet.chain().findBlock(blockId,
1765 "Can't read block from disk");
1768 auto it =
wallet.mapWallet.find(tx->GetId());
1769 if (it !=
wallet.mapWallet.end()) {
1784 std::min(target_confirms,
wallet.GetLastBlockHeight() + 1);
1786 wallet.GetLastBlockHash(),
1787 wallet.GetLastBlockHeight() + 1 - target_confirms,
1791 ret.
pushKV(
"transactions", transactions);
1792 if (include_removed) {
1793 ret.
pushKV(
"removed", removed);
1806 "Get detailed information about in-wallet transaction <txid>\n",
1809 "The transaction id"},
1811 "true for watch-only wallets, otherwise false",
1812 "Whether to include watch-only addresses in balance calculation "
1815 "Whether to include a `decoded` field containing the decoded "
1816 "transaction (equivalent to RPC decoderawtransaction)"},
1820 Cat(
Cat<std::vector<RPCResult>>(
1823 "The amount in " + ticker},
1825 "The amount of the fee in " + ticker +
1826 ". This is negative and only available for the\n"
1827 "'send' category of transactions."},
1840 "Only returns true if imported addresses were "
1841 "involved in transaction."},
1843 "The bitcoin address involved in the "
1846 "The transaction category.\n"
1847 "\"send\" Transactions sent.\n"
1848 "\"receive\" Non-coinbase "
1849 "transactions received.\n"
1850 "\"generate\" Coinbase "
1851 "transactions received with more than 100 "
1853 "\"immature\" Coinbase "
1854 "transactions received with 100 or fewer "
1856 "\"orphan\" Orphaned coinbase "
1857 "transactions received."},
1859 "The amount in " + ticker},
1861 "A comment for the address/transaction, if any"},
1864 "The amount of the fee in " + ticker +
1865 ". This is negative and only available for "
1867 "'send' category of transactions."},
1869 "'true' if the transaction has been abandoned "
1870 "(inputs are respendable). Only available for "
1872 "'send' category of transactions."},
1876 "Raw data for transaction"},
1879 "Optional, the decoded transaction (only present when "
1880 "`verbose` is passed)",
1883 "Equivalent to the RPC decoderawtransaction method, "
1884 "or the RPC getrawtransaction method when `verbose` "
1889 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1890 "5cf302fc80e9d5fbf5d48d\"") +
1892 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1893 "5cf302fc80e9d5fbf5d48d\" true") +
1895 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1896 "5cf302fc80e9d5fbf5d48d\" false true") +
1898 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1899 "5cf302fc80e9d5fbf5d48d\"")},
1902 std::shared_ptr<CWallet>
const wallet =
1912 pwallet->BlockUntilSyncedToCurrentChain();
1923 bool verbose = request.params[2].isNull()
1925 : request.params[2].get_bool();
1928 auto it = pwallet->mapWallet.find(txid);
1929 if (it == pwallet->mapWallet.end()) {
1931 "Invalid or non-wallet transaction id");
1937 Amount nNet = nCredit - nDebit;
1939 ? wtx.
tx->GetValueOut() - nDebit
1942 entry.
pushKV(
"amount", nNet - nFee);
1944 entry.
pushKV(
"fee", nFee);
1952 entry.
pushKV(
"details", details);
1954 std::string strHex =
1956 entry.
pushKV(
"hex", strHex);
1961 entry.
pushKV(
"decoded", decoded);
1971 "abandontransaction",
1972 "Mark in-wallet transaction <txid> as abandoned\n"
1973 "This will mark this transaction and all its in-wallet descendants as "
1974 "abandoned which will allow\n"
1975 "for their inputs to be respent. It can be used to replace \"stuck\" "
1976 "or evicted transactions.\n"
1977 "It only works on transactions which are not included in a block and "
1978 "are not currently in the mempool.\n"
1979 "It has no effect on transactions which are already abandoned.\n",
1982 "The transaction id"},
1986 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1987 "5cf302fc80e9d5fbf5d48d\"") +
1989 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1990 "5cf302fc80e9d5fbf5d48d\"")},
1993 std::shared_ptr<CWallet>
const wallet =
2003 pwallet->BlockUntilSyncedToCurrentChain();
2009 if (!pwallet->mapWallet.count(txid)) {
2011 "Invalid or non-wallet transaction id");
2016 "Transaction not eligible for abandonment");
2030 "The new keypool size"},
2037 std::shared_ptr<CWallet>
const wallet =
2048 "Error: Private keys are disabled for this wallet");
2055 unsigned int kpSize = 0;
2056 if (!request.params[0].isNull()) {
2057 if (request.params[0].get_int() < 0) {
2060 "Invalid parameter, expected valid size.");
2062 kpSize = (
unsigned int)request.params[0].get_int();
2070 "Error refreshing keypool.");
2081 "Updates list of temporarily unspendable outputs.\n"
2082 "Temporarily lock (unlock=false) or unlock (unlock=true) specified "
2083 "transaction outputs.\n"
2084 "If no transaction outputs are specified when unlocking then all "
2085 "current locked transaction outputs are unlocked.\n"
2086 "A locked transaction output will not be chosen by automatic coin "
2087 "selection, when spending bitcoins.\n"
2088 "Manually selected coins are automatically unlocked.\n"
2089 "Locks are stored in memory only. Nodes start with zero locked "
2090 "outputs, and the locked output list\n"
2091 "is always cleared (by virtue of process exit) when a node stops or "
2093 "Also see the listunspent call\n",
2096 "Whether to unlock (true) or lock (false) the specified "
2102 "The transaction outputs and within each, txid (string) vout "
2114 "The output number"},
2121 "Whether the command was successful or not"},
2123 "\nList the unspent transactions\n" +
2125 "\nLock an unspent transaction\n" +
2128 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2129 "b764ed838b5655e72f463568df1aadf0\\\""
2130 ",\\\"vout\\\":1}]\"") +
2131 "\nList the locked transactions\n" +
2133 "\nUnlock the transaction again\n" +
2136 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2137 "b764ed838b5655e72f463568df1aadf0\\\""
2138 ",\\\"vout\\\":1}]\"") +
2139 "\nAs a JSON-RPC call\n" +
2142 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2143 "b764ed838b5655e72f463568df1aadf0\\\""
2144 ",\\\"vout\\\":1}]\"")},
2147 std::shared_ptr<CWallet>
const wallet =
2157 pwallet->BlockUntilSyncedToCurrentChain();
2163 bool fUnlock = request.params[0].get_bool();
2165 if (request.params[1].isNull()) {
2174 const UniValue &output_params = request.params[1];
2178 std::vector<COutPoint> outputs;
2181 for (
size_t idx = 0; idx < output_params.
size(); idx++) {
2193 "Invalid parameter, vout cannot be negative");
2197 const auto it = pwallet->mapWallet.find(txid);
2198 if (it == pwallet->mapWallet.end()) {
2201 "Invalid parameter, unknown transaction");
2206 if (output.
GetN() >= trans.
tx->vout.size()) {
2209 "Invalid parameter, vout index out of bounds");
2212 if (pwallet->
IsSpent(output)) {
2215 "Invalid parameter, expected unspent output");
2219 if (fUnlock && !is_locked) {
2222 "Invalid parameter, expected locked output");
2225 if (!fUnlock && is_locked) {
2228 "Invalid parameter, output already locked");
2231 outputs.push_back(output);
2235 for (
const COutPoint &output : outputs) {
2251 "Returns list of temporarily unspendable outputs.\n"
2252 "See the lockunspent call to lock and unlock transactions for "
2264 "The transaction id locked"},
2269 "\nList the unspent transactions\n" +
2271 "\nLock an unspent transaction\n" +
2274 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2275 "b764ed838b5655e72f463568df1aadf0\\\""
2276 ",\\\"vout\\\":1}]\"") +
2277 "\nList the locked transactions\n" +
2279 "\nUnlock the transaction again\n" +
2282 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2283 "b764ed838b5655e72f463568df1aadf0\\\""
2284 ",\\\"vout\\\":1}]\"") +
2285 "\nAs a JSON-RPC call\n" +
HelpExampleRpc(
"listlockunspent",
"")},
2288 std::shared_ptr<CWallet>
const wallet =
2297 std::vector<COutPoint> vOutpts;
2302 for (
const COutPoint &output : vOutpts) {
2305 o.
pushKV(
"txid", output.GetTxId().GetHex());
2306 o.
pushKV(
"vout",
int(output.GetN()));
2318 "Set the transaction fee per kB for this wallet. Overrides the "
2319 "global -paytxfee command line parameter.\n"
2320 "Can be deactivated by passing 0 as the fee. In that case automatic "
2321 "fee selection will be used by default.\n",
2331 std::shared_ptr<CWallet>
const wallet =
2341 CFeeRate tx_fee_rate(nAmount, 1000);
2345 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2348 strprintf(
"txfee cannot be less than min relay tx fee (%s)",
2350 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2353 strprintf(
"txfee cannot be less than wallet min fee (%s)",
2355 }
else if (tx_fee_rate > max_tx_fee_rate) {
2359 "txfee cannot be more than wallet max tx fee (%s)",
2381 "balances from outputs that the wallet can sign",
2384 "trusted balance (outputs created by the wallet or "
2385 "confirmed outputs)"},
2387 "untrusted pending balance (outputs created by "
2388 "others that are in the mempool)"},
2390 "balance from immature coinbase outputs"},
2392 "(only present if avoid_reuse is set) balance from "
2393 "coins sent to addresses that were previously "
2394 "spent from (potentially privacy violating)"},
2398 "watchonly balances (not present if wallet does not "
2402 "trusted balance (outputs created by the wallet or "
2403 "confirmed outputs)"},
2405 "untrusted pending balance (outputs created by "
2406 "others that are in the mempool)"},
2408 "balance from immature coinbase outputs"},
2415 std::shared_ptr<CWallet>
const rpc_wallet =
2425 wallet.BlockUntilSyncedToCurrentChain();
2433 balances_mine.pushKV(
"trusted", bal.m_mine_trusted);
2434 balances_mine.pushKV(
"untrusted_pending",
2435 bal.m_mine_untrusted_pending);
2436 balances_mine.pushKV(
"immature", bal.m_mine_immature);
2442 balances_mine.pushKV(
"used",
2443 full_bal.m_mine_trusted +
2444 full_bal.m_mine_untrusted_pending -
2445 bal.m_mine_trusted -
2446 bal.m_mine_untrusted_pending);
2448 balances.pushKV(
"mine", balances_mine);
2450 auto spk_man =
wallet.GetLegacyScriptPubKeyMan();
2451 if (spk_man && spk_man->HaveWatchOnly()) {
2453 balances_watchonly.pushKV(
"trusted", bal.m_watchonly_trusted);
2454 balances_watchonly.pushKV(
"untrusted_pending",
2455 bal.m_watchonly_untrusted_pending);
2456 balances_watchonly.pushKV(
"immature", bal.m_watchonly_immature);
2457 balances.pushKV(
"watchonly", balances_watchonly);
2467 "Returns an object containing various wallet state info.\n",
2477 "DEPRECATED. Identical to getbalances().mine.trusted"},
2479 "DEPRECATED. Identical to "
2480 "getbalances().mine.untrusted_pending"},
2482 "DEPRECATED. Identical to getbalances().mine.immature"},
2484 "the total number of transactions in the wallet"},
2487 " of the oldest pre-generated key in the key pool. Legacy "
2490 "how many new keys are pre-generated (only counts external "
2493 "how many new keys are pre-generated for internal use (used "
2494 "for change outputs, only appears if the wallet is using this "
2495 "feature, otherwise external keys are used)"},
2499 " until which the wallet is unlocked for transfers, or 0 "
2500 "if the wallet is locked (only present for "
2501 "passphrase-encrypted wallets)"},
2503 "the transaction fee configuration, set in " +
2506 "the Hash160 of the HD seed (only present when HD is "
2509 "false if privatekeys are disabled for this wallet (enforced "
2510 "watch-only wallet)"},
2513 "current scanning details, or false if no scan is in progress",
2516 "elapsed seconds since scan start"},
2518 "scanning progress percentage [0.0, 1.0]"},
2521 "whether this wallet tracks clean/dirty coins in terms of "
2524 "whether this wallet uses descriptors for scriptPubKey "
2532 std::shared_ptr<CWallet>
const wallet =
2542 pwallet->BlockUntilSyncedToCurrentChain();
2553 obj.
pushKV(
"balance", bal.m_mine_trusted);
2554 obj.
pushKV(
"unconfirmed_balance", bal.m_mine_untrusted_pending);
2555 obj.
pushKV(
"immature_balance", bal.m_mine_immature);
2556 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2557 if (kp_oldest > 0) {
2558 obj.
pushKV(
"keypoololdest", kp_oldest);
2560 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2572 obj.
pushKV(
"keypoolsize_hd_internal",
2576 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2580 "private_keys_enabled",
2586 obj.
pushKV(
"scanning", scanning);
2588 obj.
pushKV(
"scanning",
false);
2590 obj.
pushKV(
"avoid_reuse",
2592 obj.
pushKV(
"descriptors",
2602 "Returns a list of wallets in the wallet directory.\n",
2628 wallet.pushKV(
"name", path.u8string());
2633 result.
pushKV(
"wallets", wallets);
2642 "Returns a list of currently loaded wallets.\n"
2643 "For full information on the wallet, use \"getwalletinfo\"\n",
2670 "Loads a wallet from a wallet file or directory."
2671 "\nNote that all wallet command-line options used when starting "
2673 "\napplied to the new wallet (eg -rescan, etc).\n",
2676 "The wallet directory or .dat file."},
2678 "Save wallet name to persistent settings and load on startup. "
2679 "True to add wallet to startup list, false to remove, null to "
2680 "leave unchanged."},
2687 "The wallet name if loaded successfully."},
2689 "Warning message if wallet was not loaded cleanly."},
2696 const std::string
name(request.params[0].get_str());
2698 auto [
wallet, warnings] =
2711 std::string
flags =
"";
2714 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2719 "Change the state of the given wallet flag for a wallet.\n",
2722 "The name of the flag to change. Current available flags: " +
2732 "The name of the flag that was modified"},
2734 "The new state of the flag"},
2736 "Any warnings associated with the change"},
2742 std::shared_ptr<CWallet>
const wallet =
2749 std::string flag_str = request.params[0].get_str();
2751 request.params[1].isNull() || request.params[1].get_bool();
2756 strprintf(
"Unknown wallet flag: %s", flag_str));
2764 strprintf(
"Wallet flag is immutable: %s", flag_str));
2772 strprintf(
"Wallet flag is already set to %s: %s",
2773 value ?
"true" :
"false", flag_str));
2776 res.
pushKV(
"flag_name", flag_str);
2777 res.
pushKV(
"flag_state", value);
2780 pwallet->SetWalletFlag(flag);
2797 "Creates and loads a new wallet.\n",
2800 "The name for the new wallet. If this is a path, the wallet will "
2801 "be created at the path location."},
2803 "Disable the possibility of private keys (only watchonlys are "
2804 "possible in this mode)."},
2806 "Create a blank wallet. A blank wallet has no keys or HD seed. "
2807 "One can be set using sethdseed."},
2809 "Encrypt the wallet with this passphrase."},
2811 "Keep track of coin reuse, and treat dirty and clean coins "
2812 "differently with privacy considerations in mind."},
2814 "Create a native descriptor wallet. The wallet will use "
2815 "descriptors internally to handle address creation"},
2817 "Save wallet name to persistent settings and load on startup. "
2818 "True to add wallet to startup list, false to remove, null to "
2819 "leave unchanged."},
2826 "The wallet name if created successfully. If the wallet "
2827 "was created using a full path, the wallet_name will be "
2830 "Warning message if wallet was not loaded cleanly."},
2836 {
"avoid_reuse",
true},
2837 {
"descriptors",
true},
2838 {
"load_on_startup",
true}}) +
2840 {
"avoid_reuse",
true},
2841 {
"descriptors",
true},
2842 {
"load_on_startup",
true}})},
2847 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2851 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2856 passphrase.reserve(100);
2857 std::vector<bilingual_str> warnings;
2858 if (!request.params[3].isNull()) {
2859 passphrase = request.params[3].get_str().c_str();
2860 if (passphrase.empty()) {
2863 "Empty string given as passphrase, wallet will "
2864 "not be encrypted."));
2868 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2871 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2874 "Wallet is an experimental descriptor wallet"));
2883 std::optional<bool> load_on_start =
2884 request.params[6].isNull()
2886 : std::make_optional<bool>(request.params[6].get_bool());
2887 std::shared_ptr<CWallet>
wallet =
2889 load_on_start, options, status,
error, warnings);
2909 "Unloads the wallet referenced by the request endpoint otherwise "
2910 "unloads the wallet specified in the argument.\n"
2911 "Specifying the wallet name on a wallet endpoint is invalid.",
2914 "the wallet name from the RPC request",
2915 "The name of the wallet to unload."},
2917 "Save wallet name to persistent settings and load on startup. "
2918 "True to add wallet to startup list, false to remove, null to "
2919 "leave unchanged."},
2926 "Warning message if wallet was not unloaded cleanly."},
2932 std::string wallet_name;
2934 if (!request.params[0].isNull()) {
2936 "Cannot unload the requested wallet");
2939 wallet_name = request.params[0].get_str();
2946 "Requested wallet does not exist or is not loaded");
2952 std::vector<bilingual_str> warnings;
2953 std::optional<bool> load_on_start =
2954 request.params[1].isNull()
2956 : std::make_optional<bool>(request.params[1].get_bool());
2959 "Requested wallet already unloaded");
2976 "Returns array of unspent transaction outputs\n"
2977 "with between minconf and maxconf (inclusive) confirmations.\n"
2978 "Optionally filter to only include txouts paid to specified "
2982 "The minimum confirmations to filter"},
2984 "The maximum confirmations to filter"},
2989 "The bitcoin addresses to filter",
2996 "Include outputs that are not safe to spend\n"
2997 " See description of \"safe\" attribute below."},
3001 "JSON with query options",
3004 "Minimum value of each UTXO in " + ticker +
""},
3007 "Maximum value of each UTXO in " + ticker +
""},
3009 "Maximum number of UTXOs"},
3012 "Minimum sum value of all UTXOs in " + ticker +
""},
3029 "The associated label, or \"\" for the default label"},
3032 "the transaction output amount in " + ticker},
3034 "The number of confirmations"},
3037 "DEPRECATED: The number of in-mempool ancestor "
3038 "transactions, including this one (if transaction is in "
3039 "the mempool). Only displayed if the "
3040 "-deprecatedrpc=mempool_ancestors_descendants option is "
3043 "DEPRECATED: The virtual transaction size of in-mempool "
3044 " ancestors, including this one (if transaction is in "
3045 "the mempool). Only displayed if the "
3046 "-deprecatedrpc=mempool_ancestors_descendants option is "
3050 "DEPRECATED: The total fees of in-mempool ancestors "
3051 "(including this one) with fee deltas used for mining "
3054 " (if transaction is in the mempool). Only "
3056 "-deprecatedrpc=mempool_ancestors_descendants option "
3060 "The redeemScript if scriptPubKey is P2SH"},
3062 "Whether we have the private keys to spend this output"},
3064 "Whether we know how to spend this output, ignoring the "
3067 "(only present if avoid_reuse is set) Whether this "
3068 "output is reused/dirty (sent to an address that was "
3069 "previously spent from)"},
3071 "(only when solvable) A descriptor for spending this "
3074 "Whether this output is considered safe to spend. "
3075 "Unconfirmed transactions\n"
3076 "from outside keys and unconfirmed replacement "
3077 "transactions are considered unsafe\n"
3078 "and are not eligible for spending by fundrawtransaction "
3079 "and sendtoaddress."},
3086 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3087 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3090 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3091 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3094 "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") +
3097 "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")},
3100 std::shared_ptr<CWallet>
const wallet =
3108 if (!request.params[0].isNull()) {
3110 nMinDepth = request.params[0].get_int();
3113 int nMaxDepth = 9999999;
3114 if (!request.params[1].isNull()) {
3116 nMaxDepth = request.params[1].get_int();
3119 std::set<CTxDestination> destinations;
3120 if (!request.params[2].isNull()) {
3123 for (
size_t idx = 0; idx < inputs.
size(); idx++) {
3124 const UniValue &input = inputs[idx];
3130 std::string(
"Invalid Bitcoin address: ") +
3133 if (!destinations.insert(dest).second) {
3137 "Invalid parameter, duplicated address: ") +
3143 bool include_unsafe =
true;
3144 if (!request.params[3].isNull()) {
3146 include_unsafe = request.params[3].get_bool();
3152 uint64_t nMaximumCount = 0;
3154 if (!request.params[4].isNull()) {
3167 if (options.
exists(
"minimumAmount")) {
3171 if (options.
exists(
"maximumAmount")) {
3175 if (options.
exists(
"minimumSumAmount")) {
3180 if (options.
exists(
"maximumCount")) {
3181 nMaximumCount = options[
"maximumCount"].
get_int64();
3188 pwallet->BlockUntilSyncedToCurrentChain();
3191 std::vector<COutput> vecOutputs;
3199 nMinimumAmount, nMaximumAmount,
3200 nMinimumSumAmount, nMaximumCount);
3205 const bool avoid_reuse =
3208 for (
const COutput &out : vecOutputs) {
3211 out.tx->tx->vout[out.i].scriptPubKey;
3214 avoid_reuse && pwallet->
IsSpentKey(out.tx->GetId(), out.i);
3216 if (destinations.size() &&
3217 (!fValidAddress || !destinations.count(address))) {
3222 entry.
pushKV(
"txid", out.tx->GetId().GetHex());
3223 entry.
pushKV(
"vout", out.i);
3225 if (fValidAddress) {
3228 const auto *address_book_entry =
3230 if (address_book_entry) {
3231 entry.
pushKV(
"label", address_book_entry->GetLabel());
3234 std::unique_ptr<SigningProvider> provider =
3239 CScriptID(boost::get<ScriptHash>(address));
3241 if (provider->GetCScript(hash, redeemScript)) {
3242 entry.
pushKV(
"redeemScript",
3250 entry.
pushKV(
"amount", out.tx->tx->vout[out.i].nValue);
3251 entry.
pushKV(
"confirmations", out.nDepth);
3256 "mempool_ancestors_descendants")) {
3257 size_t ancestor_count, descendant_count, ancestor_size;
3260 out.tx->GetId(), ancestor_count, descendant_count,
3261 &ancestor_size, &ancestor_fees);
3262 if (ancestor_count) {
3263 entry.
pushKV(
"ancestorcount", uint64_t(ancestor_count));
3264 entry.
pushKV(
"ancestorsize", uint64_t(ancestor_size));
3265 entry.
pushKV(
"ancestorfees", ancestor_fees);
3268 entry.
pushKV(
"spendable", out.fSpendable);
3269 entry.
pushKV(
"solvable", out.fSolvable);
3270 if (out.fSolvable) {
3271 std::unique_ptr<SigningProvider> provider =
3276 entry.
pushKV(
"desc", descriptor->ToString());
3280 entry.
pushKV(
"reused", reused);
3282 entry.
pushKV(
"safe", out.fSafe);
3292 Amount &fee_out,
int &change_position,
3296 pwallet->BlockUntilSyncedToCurrentChain();
3298 change_position = -1;
3299 bool lockUnspents =
false;
3301 std::set<int> setSubtractFeeFromOutputs;
3333 if (options.
exists(
"add_inputs")) {
3337 if (options.
exists(
"changeAddress") ||
3338 options.
exists(
"change_address")) {
3339 const std::string change_address_str =
3340 (options.
exists(
"change_address")
3341 ? options[
"change_address"]
3342 : options[
"changeAddress"])
3350 "Change address must be a valid bitcoin address");
3356 if (options.
exists(
"changePosition") ||
3357 options.
exists(
"change_position")) {
3358 change_position = (options.
exists(
"change_position")
3359 ? options[
"change_position"]
3360 : options[
"changePosition"])
3364 const UniValue include_watching_option =
3365 options.
exists(
"include_watching") ? options[
"include_watching"]
3366 : options[
"includeWatching"];
3370 if (options.
exists(
"lockUnspents") ||
3371 options.
exists(
"lock_unspents")) {
3373 (options.
exists(
"lock_unspents") ? options[
"lock_unspents"]
3374 : options[
"lockUnspents"])
3378 if (options.
exists(
"feeRate") || options.
exists(
"fee_rate")) {
3380 options.
exists(
"fee_rate") ? options[
"fee_rate"]
3381 : options[
"feeRate"]));
3385 if (options.
exists(
"subtractFeeFromOutputs") ||
3386 options.
exists(
"subtract_fee_from_outputs")) {
3387 subtractFeeFromOutputs =
3388 (options.
exists(
"subtract_fee_from_outputs")
3389 ? options[
"subtract_fee_from_outputs"]
3390 : options[
"subtractFeeFromOutputs"])
3400 if (tx.
vout.size() == 0) {
3402 "TX must have at least one output");
3405 if (change_position != -1 &&
3406 (change_position < 0 ||
3407 (
unsigned int)change_position > tx.
vout.size())) {
3409 "changePosition out of bounds");
3412 for (
size_t idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3413 int pos = subtractFeeFromOutputs[idx].
get_int();
3414 if (setSubtractFeeFromOutputs.count(pos)) {
3417 strprintf(
"Invalid parameter, duplicated position: %d", pos));
3422 strprintf(
"Invalid parameter, negative position: %d", pos));
3424 if (pos >=
int(tx.
vout.size())) {
3427 strprintf(
"Invalid parameter, position too large: %d", pos));
3429 setSubtractFeeFromOutputs.insert(pos);
3435 lockUnspents, setSubtractFeeFromOutputs,
3444 "fundrawtransaction",
3445 "If the transaction has no inputs, they will be automatically selected "
3446 "to meet its out value.\n"
3447 "It will add at most one change output to the outputs.\n"
3448 "No existing outputs will be modified unless "
3449 "\"subtractFeeFromOutputs\" is specified.\n"
3450 "Note that inputs which were signed may need to be resigned after "
3451 "completion since in/outputs have been added.\n"
3452 "The inputs added will not be signed, use signrawtransactionwithkey or "
3453 "signrawtransactionwithwallet for that.\n"
3454 "Note that all existing inputs must have their previous output "
3455 "transaction be in the wallet.\n"
3456 "Note that all inputs selected must be of standard form and P2SH "
3458 "in the wallet using importaddress or addmultisigaddress (to calculate "
3460 "You can see whether this is the case by checking the \"solvable\" "
3461 "field in the listunspent output.\n"
3462 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently "
3463 "supported for watch-only\n",
3466 "The hex string of the raw transaction"},
3470 "for backward compatibility: passing in a true instead of an "
3471 "object will result in {\"includeWatching\":true}",
3474 "For a transaction with existing inputs, automatically "
3475 "include more if they are not enough."},
3478 "The bitcoin address to receive the change"},
3480 "The index of the change output"},
3482 "true for watch-only wallets, otherwise false",
3483 "Also select inputs which are watch only.\n"
3484 "Only solvable inputs can be used. Watch-only destinations "
3485 "are solvable if the public key and/or output script was "
3487 "e.g. with 'importpubkey' or 'importmulti' with the "
3488 "'pubkeys' or 'desc' field."},
3490 "Lock selected unspent outputs"},
3492 "not set: makes wallet determine the fee",
3493 "Set a specific fee rate in " + ticker +
"/kB"},
3495 "subtractFeeFromOutputs",
3499 " The fee will be equally "
3500 "deducted from the amount of each specified output.\n"
3501 " Those recipients will "
3502 "receive less bitcoins than you enter in their "
3503 "corresponding amount field.\n"
3504 " If no outputs are "
3505 "specified here, the sender pays the fee.",
3509 "The zero-based output index, before a change output "
3521 "The resulting raw transaction (hex-encoded string)"},
3523 "Fee in " + ticker +
" the resulting transaction pays"},
3525 "The position of the added change output, or -1"},
3528 "\nCreate a transaction with no inputs\n" +
3530 "\"[]\" \"{\\\"myaddress\\\":10000}\"") +
3531 "\nAdd sufficient unsigned inputs to meet the output value\n" +
3533 "\nSign the transaction\n" +
3535 "\"fundedtransactionhex\"") +
3536 "\nSend the transaction\n" +
3537 HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")},
3540 std::shared_ptr<CWallet>
const wallet =
3547 RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType()});
3551 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
3553 "TX decode failed");
3557 int change_position;
3563 request.params[1], coin_control);
3567 result.
pushKV(
"fee", fee);
3568 result.
pushKV(
"changepos", change_position);
3577 "signrawtransactionwithwallet",
3578 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
3579 "The second optional argument (may be null) is an array of previous "
3580 "transaction outputs that\n"
3581 "this transaction depends on but may not yet be in the block chain.\n" +
3585 "The transaction hex string"},
3590 "The previous dependent transaction outputs",
3601 "The output number"},
3613 "The signature hash type. Must be one of\n"
3615 " \"NONE|FORKID\"\n"
3616 " \"SINGLE|FORKID\"\n"
3617 " \"ALL|FORKID|ANYONECANPAY\"\n"
3618 " \"NONE|FORKID|ANYONECANPAY\"\n"
3619 " \"SINGLE|FORKID|ANYONECANPAY\""},
3627 "The hex-encoded raw transaction with signature(s)"},
3629 "If the transaction has a complete set of signatures"},
3633 "Script verification errors (if there are any)",
3640 "The hash of the referenced, previous transaction"},
3642 "The index of the output to spent and used as "
3645 "The hex-encoded signature script"},
3647 "Script sequence number"},
3649 "Verification or signing error related to the "
3659 std::shared_ptr<CWallet>
const wallet =
3667 {UniValue::VSTR, UniValue::VARR, UniValue::VSTR},
3671 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3673 "TX decode failed");
3681 std::map<COutPoint, Coin> coins;
3682 for (
const CTxIn &txin : mtx.
vin) {
3694 "Signature must use SIGHASH_FORKID");
3698 std::map<int, std::string> input_errors;
3713 "Rescan the local blockchain for wallet related transactions.\n"
3714 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3717 "block height where the rescan should start"},
3720 "the last block height that should be scanned"},
3728 "The block height where the rescan started (the requested "
3731 "The height of the last rescanned block. May be null in rare "
3732 "cases if there was a reorg and the call didn't scan any "
3733 "blocks because they were already scanned in the background."},
3739 std::shared_ptr<CWallet>
const wallet =
3749 "Wallet is currently rescanning. Abort "
3750 "existing rescan or wait.");
3753 int start_height = 0;
3754 std::optional<int> stop_height;
3760 if (!request.params[0].isNull()) {
3761 start_height = request.params[0].get_int();
3762 if (start_height < 0 || start_height > tip_height) {
3764 "Invalid start_height");
3768 if (!request.params[1].isNull()) {
3769 stop_height = request.params[1].get_int();
3770 if (*stop_height < 0 || *stop_height > tip_height) {
3772 "Invalid stop_height");
3773 }
else if (*stop_height < start_height) {
3776 "stop_height must be greater than start_height");
3783 start_height, stop_height)) {
3786 "Can't rescan beyond pruned data. Use RPC call "
3787 "getblockchaininfo to determine your pruned height.");
3796 start_block, start_height, stop_height, reserver,
3804 "Rescan failed. Potentially corrupted data files.");
3811 response.pushKV(
"start_height", start_height);
3826 std::vector<std::vector<uint8_t>> solutions_data;
3837 UniValue wallet_detail = boost::apply_visitor(*
this, embedded);
3838 subobj.
pushKVs(wallet_detail);
3843 if (subobj.
exists(
"pubkey")) {
3844 obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3846 obj.
pushKV(
"embedded", std::move(subobj));
3852 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3854 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3855 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3858 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3896 std::unique_ptr<SigningProvider> provider =
nullptr;
3901 ret.
pushKVs(boost::apply_visitor(
3908 const bool verbose) {
3920 "Return information about the given bitcoin address.\n"
3921 "Some of the information will only be present if the address is in the "
3925 "The bitcoin address for which to get information."},
3933 "The bitcoin address validated."},
3935 "The hex-encoded scriptPubKey generated by the address."},
3938 "If the address is watchonly."},
3940 "If we know how to spend coins sent to this address, ignoring "
3941 "the possible lack of private keys."},
3943 "A descriptor for spending coins sent to this address (only "
3947 "If the address was used for change output."},
3949 "The output script type. Only if isscript is true and the "
3950 "redeemscript is known. Possible\n"
3952 "types: nonstandard, pubkey, pubkeyhash, scripthash, "
3953 "multisig, nulldata."},
3955 "The redeemscript for the p2sh address."},
3959 "Array of pubkeys associated with the known redeemscript "
3960 "(only if script is multisig).",
3965 "The number of signatures required to spend multisig output "
3966 "(only if script is multisig)."},
3968 "The hex value of the raw public key for single-key addresses "
3969 "(possibly embedded in P2SH)."},
3973 "Information about the address embedded in P2SH, if "
3974 "relevant and known.",
3977 "Includes all getaddressinfo output fields for the "
3978 "embedded address excluding metadata (timestamp, "
3979 "hdkeypath, hdseedid)\n"
3980 "and relation to the wallet (ismine, iswatchonly)."},
3983 "If the pubkey is compressed."},
3985 "The creation time of the key, if available, expressed in " +
3988 "The HD keypath, if the key is HD and available."},
3990 "The Hash160 of the HD seed."},
3992 true,
"The fingerprint of the master key."},
3995 "Array of labels associated with the address. Currently "
3996 "limited to one label but returned\n"
3997 "as an array to keep the API stable if multiple labels are "
3998 "enabled in the future.",
4001 "Label name (defaults to \"\")."},
4008 std::shared_ptr<CWallet>
const wallet =
4019 wallet->GetChainParams());
4027 ret.
pushKV(
"address", currentAddress);
4032 std::unique_ptr<SigningProvider> provider =
4038 bool solvable = provider &&
IsSolvable(*provider, scriptPubKey);
4039 ret.
pushKV(
"solvable", solvable);
4057 if (
const std::unique_ptr<CKeyMetadata> meta =
4059 ret.
pushKV(
"timestamp", meta->nCreateTime);
4060 if (meta->has_key_origin) {
4063 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
4064 ret.
pushKV(
"hdmasterfingerprint",
4065 HexStr(meta->key_origin.fingerprint));
4076 const auto *address_book_entry =
4078 if (address_book_entry) {
4079 labels.
push_back(address_book_entry->GetLabel());
4081 ret.
pushKV(
"labels", std::move(labels));
4090 "getaddressesbylabel",
4091 "Returns the list of addresses assigned the specified label.\n",
4097 "json object with addresses as keys",
4101 "Information about address",
4104 "Purpose of address (\"send\" for sending address, "
4105 "\"receive\" for receiving address)"},
4112 std::shared_ptr<CWallet>
const wallet =
4125 std::set<std::string> addresses;
4126 for (
const std::pair<const CTxDestination, CAddressBookData> &item :
4127 pwallet->m_address_book) {
4128 if (item.second.IsChange()) {
4131 if (item.second.GetLabel() == label) {
4149 std::string(
"No addresses with label " + label));
4160 "Returns the list of all labels, or labels that are assigned to "
4161 "addresses with a specific purpose.\n",
4164 "Address purpose to list labels for ('send','receive'). An empty "
4165 "string is the same as not providing this argument."},
4174 "\nList labels that have receiving addresses\n" +
4176 "\nList labels that have sending addresses\n" +
4178 "\nAs a JSON-RPC call\n" +
4182 std::shared_ptr<CWallet>
const wallet =
4191 std::string purpose;
4192 if (!request.params[0].isNull()) {
4193 purpose = request.params[0].get_str();
4198 std::set<std::string> label_set;
4199 for (
const std::pair<const CTxDestination, CAddressBookData>
4200 &entry : pwallet->m_address_book) {
4201 if (entry.second.IsChange()) {
4204 if (purpose.empty() || entry.second.purpose == purpose) {
4205 label_set.insert(entry.second.GetLabel());
4210 for (
const std::string &
name : label_set) {
4222 "EXPERIMENTAL warning: this call may be changed in future releases.\n"
4223 "\nSend a transaction.\n",
4229 "A JSON array with outputs (key-value pairs), where none of "
4230 "the keys are duplicated.\n"
4231 "That is, each address can only appear once and there can only "
4232 "be one 'data' object.\n"
4233 "For convenience, a dictionary, which holds the key-value "
4234 "pairs directly, is also accepted.",
4244 "A key-value pair. The key (string) is the "
4245 "bitcoin address, the value (float or string) is "
4258 "A key-value pair. The key must be \"data\", the "
4259 "value is hex-encoded data"},
4270 "If inputs are specified, automatically include more if they "
4273 "When false, returns a serialized transaction which will not "
4274 "be added to the wallet or broadcast"},
4277 "The bitcoin address to receive the change"},
4279 "The index of the change output"},
4281 "not set: makes wallet determine the fee",
4285 "true for watch-only wallets, otherwise false",
4286 "Also select inputs which are watch only.\n"
4287 "Only solvable inputs can be used. Watch-only destinations "
4288 "are solvable if the public key and/or output script was "
4290 "e.g. with 'importpubkey' or 'importmulti' with the "
4291 "'pubkeys' or 'desc' field."},
4296 "Specify inputs instead of adding them automatically. A "
4297 "JSON array of JSON objects",
4300 "The transaction id"},
4302 "The output number"},
4304 "The sequence number"},
4308 "Raw locktime. Non-0 value also locktime-activates inputs"},
4310 "Lock selected unspent outputs"},
4312 "Always return a PSBT, implies add_to_wallet=false."},
4314 "subtract_fee_from_outputs",
4317 "Outputs to subtract the fee from, specified as integer "
4319 "The fee will be equally deducted from the amount of each "
4320 "specified output.\n"
4321 "Those recipients will receive less bitcoins than you "
4322 "enter in their corresponding amount field.\n"
4323 "If no outputs are specified here, the sender pays the "
4328 "The zero-based output index, before a change output "
4340 "If the transaction has a complete set of signatures"},
4342 "The transaction id for the send. Only 1 transaction is created "
4343 "regardless of the number of addresses."},
4345 "If add_to_wallet is false, the hex-encoded raw transaction with "
4348 "If more signatures are needed, or if add_to_wallet is false, "
4349 "the base64-encoded (partially) signed transaction"}}},
4352 "\nSend with a fee rate of 10 XEC/kB\n" +
4354 "\": 100000}' '{\"fee_rate\": 10}'\n") +
4355 "\nCreate a transaction with a specific input, and return "
4356 "result without adding to wallet or broadcasting to the "
4360 "\": 100000}' '{\"add_to_wallet\": "
4361 "false, \"inputs\": "
4363 "\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b565"
4364 "5e72f463568df1aadf0\", \"vout\":1}]}'")},
4369 UniValueType(), UniValue::VOBJ},
4372 std::shared_ptr<CWallet>
const wallet =
4379 UniValue options = request.params[1];
4380 if (options.
exists(
"changeAddress")) {
4383 if (options.
exists(
"changePosition")) {
4385 "Use change_position");
4387 if (options.
exists(
"includeWatching")) {
4389 "Use include_watching");
4391 if (options.
exists(
"lockUnspents")) {
4394 if (options.
exists(
"subtractFeeFromOutputs")) {
4396 "Use subtract_fee_from_outputs");
4398 if (options.
exists(
"feeRate")) {
4402 const bool psbt_opt_in =
4406 int change_position;
4408 wallet->GetChainParams(), options[
"inputs"], request.params[0],
4409 options[
"locktime"]);
4417 bool add_to_wallet =
true;
4418 if (options.
exists(
"add_to_wallet")) {
4419 add_to_wallet = options[
"add_to_wallet"].
get_bool();
4426 bool complete =
true;
4428 psbtx, complete,
SigHashType().withForkId(),
true,
false);
4438 if (psbt_opt_in || !complete || !add_to_wallet) {
4446 std::string err_string;
4449 result.
pushKV(
"txid", tx->GetHash().GetHex());
4450 if (add_to_wallet && !psbt_opt_in) {
4453 result.
pushKV(
"hex", hex);
4456 result.
pushKV(
"complete", complete);
4465 "Set or generate a new HD wallet seed. Non-HD wallets will not be "
4466 "upgraded to being a HD wallet. Wallets that are already\n"
4467 "HD will have a new HD seed set so that new keys added to the keypool "
4468 "will be derived from this new seed.\n"
4469 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after "
4470 "setting the HD wallet seed.\n" +
4474 "Whether to flush old unused addresses, including change "
4475 "addresses, from the keypool and regenerate it.\n"
4476 " If true, the next address from "
4477 "getnewaddress and change address from getrawchangeaddress will "
4478 "be from this new seed.\n"
4479 " If false, addresses (including "
4480 "change addresses if the wallet already had HD Chain Split "
4481 "enabled) from the existing\n"
4482 " keypool will be used until it has "
4485 "The WIF private key to use as the new HD seed.\n"
4486 " The seed value can be retrieved "
4487 "using the dumpwallet command. It is the private key marked "
4497 std::shared_ptr<CWallet>
const wallet =
4509 "Cannot set a HD seed to a wallet with "
4510 "private keys disabled");
4519 "Cannot set a HD seed on a non-HD wallet. Use the "
4520 "upgradewallet RPC in order to upgrade a non-HD wallet "
4526 bool flush_key_pool =
true;
4527 if (!request.params[0].isNull()) {
4528 flush_key_pool = request.params[0].get_bool();
4532 if (request.params[1].isNull()) {
4538 "Invalid private key");
4544 "Already have this key (either as an HD seed or "
4545 "as a loose private key)");
4552 if (flush_key_pool) {
4563 "walletprocesspsbt",
4564 "Update a PSBT with input information from our wallet and then sign "
4565 "inputs that we can sign for." +
4569 "The transaction base64 string"},
4571 "Also sign the transaction when updating"},
4573 "The signature hash type to sign with if not specified by "
4574 "the PSBT. Must be one of\n"
4576 " \"NONE|FORKID\"\n"
4577 " \"SINGLE|FORKID\"\n"
4578 " \"ALL|FORKID|ANYONECANPAY\"\n"
4579 " \"NONE|FORKID|ANYONECANPAY\"\n"
4580 " \"SINGLE|FORKID|ANYONECANPAY\""},
4582 "Includes the BIP 32 derivation paths for public keys if we know "
4590 "The base64-encoded partially signed transaction"},
4592 "If the transaction has a complete set of signatures"},
4597 std::shared_ptr<CWallet>
const wallet =
4605 {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4619 "Signature must use SIGHASH_FORKID");
4623 bool sign = request.params[1].isNull()
4625 : request.params[1].get_bool();
4626 bool bip32derivs = request.params[3].isNull()
4628 : request.params[3].get_bool();
4629 bool complete =
true;
4631 psbtx, complete, nHashType, sign, bip32derivs);
4640 result.
pushKV(
"complete", complete);
4650 "walletcreatefundedpsbt",
4651 "Creates and funds a transaction in the Partially Signed Transaction "
4653 "Implements the Creator and Updater roles.\n",
4659 "Leave empty to add inputs automatically. See add_inputs "
4671 "The output number"},
4674 "depends on the value of the 'locktime' and "
4675 "'options.replaceable' arguments",
4676 "The sequence number"},
4685 "The outputs (key-value pairs), where none of "
4686 "the keys are duplicated.\n"
4687 "That is, each address can only appear once and there can only "
4688 "be one 'data' object.\n"
4689 "For compatibility reasons, a dictionary, which holds the "
4690 "key-value pairs directly, is also\n"
4691 " accepted as second parameter.",
4701 "A key-value pair. The key (string) is the "
4702 "bitcoin address, the value (float or string) is "
4715 "A key-value pair. The key must be \"data\", the "
4716 "value is hex-encoded data"},
4722 "Raw locktime. Non-0 value also locktime-activates inputs\n"
4723 " Allows this transaction to be "
4724 "replaced by a transaction with higher fees. If provided, it is "
4725 "an error if explicit sequence numbers are incompatible."},
4732 "If inputs are specified, automatically include more if they "
4736 "The bitcoin address to receive the change"},
4738 "random",
"The index of the change output"},
4740 "true for watch-only wallets, otherwise false",
4741 "Also select inputs which are watch only"},
4743 "Lock selected unspent outputs"},
4745 "not set: makes wallet determine the fee",
4746 "Set a specific fee rate in " + ticker +
"/kB"},
4748 "subtractFeeFromOutputs",
4751 "The outputs to subtract the fee from.\n"
4752 " The fee will be equally "
4753 "deducted from the amount of each specified output.\n"
4754 " Those recipients will "
4755 "receive less bitcoins than you enter in their "
4756 "corresponding amount field.\n"
4757 " If no outputs are "
4758 "specified here, the sender pays the fee.",
4762 "The zero-based output index, before a change output "
4769 "Includes the BIP 32 derivation paths for public keys if we know "
4777 "The resulting raw transaction (base64-encoded string)"},
4779 "Fee in " + ticker +
" the resulting transaction pays"},
4781 "The position of the added change output, or -1"},
4784 "\nCreate a transaction with no inputs\n" +
4786 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" "
4787 "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
4790 std::shared_ptr<CWallet>
const wallet =
4800 UniValue::VNUM, UniValue::VOBJ},
4804 int change_position;
4806 wallet->GetChainParams(), request.params[0], request.params[1],
4813 request.params[3], coin_control);
4819 bool bip32derivs = request.params[4].isNull()
4821 : request.params[4].get_bool();
4822 bool complete =
true;
4825 false, bip32derivs);
4836 result.
pushKV(
"fee", fee);
4837 result.
pushKV(
"changepos", change_position);
4846 "Upgrade the wallet. Upgrades to the latest version if no "
4847 "version number is specified\n"
4848 "New keys may be generated and a new wallet backup will need to "
4852 "The version number to upgrade to. Default is the latest "
4859 std::shared_ptr<CWallet>
const wallet =
4871 if (!request.params[0].isNull()) {
4872 version = request.params[0].get_int();
4878 return error.original;
4919 {
"wallet",
send, },
static constexpr Amount MAX_MONEY
No amount larger than this (in satoshi) is valid.
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
#define CHECK_NONFATAL(condition)
Identity function.
const std::string & GetLabel() const
std::vector< CTransactionRef > vtx
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
int m_max_depth
Maximum chain depth value for coin availability.
bool fAllowWatchOnly
Includes watch only addresses which are solvable.
int m_min_depth
Minimum chain depth value for coin availability.
std::optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
bool fOverrideFeeRate
Override automatic min/max checks on fee, m_feerate must be set if true.
bool m_add_inputs
If false, only selected inputs are used.
CTxDestination destChange
bool m_avoid_address_reuse
Forbids inclusion of dirty (previously used) addresses.
bool m_avoid_partial_spends
Avoid partial use of funds sent to a given address.
Double ended buffer combining vector and stream-like interfaces.
Fee rate in satoshis per kilobyte: Amount / kB.
std::string ToString() const
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
CKeyID seed_id
seed hash160
An encapsulated secp256k1 private key.
const uint8_t * begin() const
bool IsValid() const
Check whether this private key is valid.
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
CPubKey GetPubKey() const
Compute the public key from a private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
const uint8_t * end() const
A reference to a CKey: the Hash160 of its serialized public key.
A mutable version of CTransaction.
std::vector< CTxOut > vout
An outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
bool IsCompressed() const
Check whether this is a compressed public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Serialized script, used inside transaction inputs and outputs.
bool IsPayToScriptHash() const
A reference to a CScript: the Hash160 of its serialization (see script.h)
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
An output of a transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
BlockHash GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
double ScanningProgress() const
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
bool IsLegacy() const
Determine if we are a legacy wallet.
interfaces::Chain & chain() const
Interface for accessing chain state.
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
OutputType m_default_address_type
int64_t ScanningDuration() const
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we are allowed to upgrade (or already support) to the named feature
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Amount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
std::multimap< int64_t, CWalletTx * > TxItems
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
A transaction with a bunch of additional info that only the owner cares about.
const SigningProvider *const provider
UniValue operator()(const PKHash &pkhash) const
UniValue operator()(const ScriptHash &scripthash) const
void ProcessSubScript(const CScript &subscript, UniValue &obj) const
DescribeWalletAddressVisitor(const SigningProvider *_provider)
UniValue operator()(const CNoDestination &dest) const
RecursiveMutex cs_KeyStore
const CHDChain & GetHDChain() const
void SetHDSeed(const CPubKey &key)
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
CPubKey GenerateNewSeed()
CPubKey DeriveNewSeed(const CKey &key)
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
virtual std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const
Signature hash type wrapper class.
An interface to be implemented by keystores that support signing.
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
A Span is an object that can refer to a contiguous sequence of objects.
const std::string & get_str() const
int64_t get_int64() const
const UniValue & get_obj() const
void __pushKV(const std::string &key, const UniValue &val)
const std::vector< UniValue > & getValues() const
const std::vector< std::string > & getKeys() const
bool pushKVs(const UniValue &obj)
bool push_back(const UniValue &val)
const UniValue & get_array() const
bool exists(const std::string &key) const
bool pushKV(const std::string &key, const UniValue &val)
RAII object to check and reserve a wallet rescan.
std::string GetHex() const
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual int rpcSerializationFlags()=0
Current RPC serialization flags.
virtual bool findBlock(const BlockHash &hash, const FoundBlock &block={})=0
Return wheth