6 #include <chainparams.h>
43 #include <event2/http.h>
64 int confirms =
wallet.GetTxDepthInMainChain(wtx);
65 entry.pushKV(
"confirmations", confirms);
66 if (wtx.IsCoinBase()) {
67 entry.pushKV(
"generated",
true);
70 entry.pushKV(
"blockhash", wtx.m_confirm.hashBlock.GetHex());
71 entry.pushKV(
"blockheight", wtx.m_confirm.block_height);
72 entry.pushKV(
"blockindex", wtx.m_confirm.nIndex);
76 entry.pushKV(
"blocktime", block_time);
81 entry.pushKV(
"txid", hash.
GetHex());
86 entry.pushKV(
"walletconflicts", conflicts);
87 entry.pushKV(
"time", wtx.GetTxTime());
88 entry.pushKV(
"timereceived", int64_t{wtx.nTimeReceived});
90 for (
const std::pair<const std::string, std::string> &item : wtx.mapValue) {
91 entry.pushKV(item.first, item.second);
98 "Returns a new Bitcoin address for receiving payments.\n"
99 "If 'label' is specified, it is added to the address book \n"
100 "so payments received with the address will be associated with "
104 "The label name for the address to be linked to. If not provided, "
105 "the default label \"\" is used. It can also be set to the empty "
106 "string \"\" to represent the default label. The label does not "
107 "need to exist, it will be created if there is no label by the "
111 "The address type to use. Options are \"legacy\"."},
118 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,
293 bool broadcast =
true) {
301 int nChangePosRet = -1;
305 *pwallet, recipients, tx, nFeeRequired, nChangePosRet,
error,
313 return tx->GetId().GetHex();
322 "The bitcoin address to send to."},
326 "A comment used to store what the transaction is for.\n"
327 " This is not part of the "
328 "transaction, just kept in your wallet."},
331 "A comment to store the name of the person or organization\n"
332 " to which you're sending the "
333 "transaction. This is not part of the \n"
334 " transaction, just kept in "
338 "The fee will be deducted from the amount being sent.\n"
339 " The recipient will receive "
340 "less bitcoins than you enter in the amount field."},
342 "(only available if avoid_reuse wallet flag is set) Avoid "
343 "spending from dirty addresses; addresses are considered\n"
344 " dirty if they have previously "
345 "been used in a transaction."},
350 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
351 HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
352 "dd\" 100000 \"donation\" \"seans "
355 "Jvaydd\" 100000 \"\" \"\" true") +
357 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
358 "dd\", 100000, \"donation\", \"seans "
362 std::shared_ptr<CWallet>
const wallet =
372 pwallet->BlockUntilSyncedToCurrentChain();
378 if (!request.params[2].isNull() &&
379 !request.params[2].get_str().empty()) {
380 mapValue[
"comment"] = request.params[2].get_str();
382 if (!request.params[3].isNull() &&
383 !request.params[3].get_str().empty()) {
384 mapValue[
"to"] = request.params[3].get_str();
387 bool fSubtractFeeFromAmount =
false;
388 if (!request.params[4].isNull()) {
389 fSubtractFeeFromAmount = request.params[4].get_bool();
402 const std::string address = request.params[0].get_str();
403 address_amounts.
pushKV(address, request.params[1]);
405 if (fSubtractFeeFromAmount) {
406 subtractFeeFromAmount.
push_back(address);
409 std::vector<CRecipient> recipients;
411 wallet->GetChainParams());
413 return SendMoney(pwallet, coin_control, recipients, mapValue);
420 "listaddressgroupings",
421 "Lists groups of addresses which have had their common ownership\n"
422 "made public by common use as inputs or as the resulting change\n"
423 "in past transactions\n",
438 "The bitcoin address"},
450 std::shared_ptr<CWallet>
const wallet =
460 pwallet->BlockUntilSyncedToCurrentChain();
465 std::map<CTxDestination, Amount> balances =
467 for (
const std::set<CTxDestination> &grouping :
473 addressInfo.
push_back(balances[address]);
475 const auto *address_book_entry =
477 if (address_book_entry) {
478 addressInfo.
push_back(address_book_entry->GetLabel());
485 return jsonGroupings;
493 std::set<CTxDestination> address_set;
498 address_set =
wallet.GetLabelAddresses(label);
505 "Invalid Bitcoin address");
508 if (!
wallet.IsMine(script_pub_key)) {
511 address_set.insert(dest);
516 if (!params[1].
isNull()) {
517 min_depth = params[1].getInt<
int>();
522 for (
const std::pair<const TxId, CWalletTx> &wtx_pair :
wallet.mapWallet) {
528 for (
const CTxOut &txout : wtx.
tx->vout) {
531 wallet.IsMine(address) && address_set.count(address)) {
542 "getreceivedbyaddress",
543 "Returns the total amount received by the given address in "
544 "transactions with at least minconf confirmations.\n",
547 "The bitcoin address for transactions."},
549 "Only include transactions confirmed at least this many times."},
553 " received at this address."},
555 "\nThe amount from transactions with at least 1 confirmation\n" +
557 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
558 "\nThe amount including unconfirmed transactions, zero "
561 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
562 "\nThe amount with at least 6 confirmations\n" +
564 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
565 "\nAs a JSON-RPC call\n" +
567 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")},
570 std::shared_ptr<CWallet>
const wallet =
580 pwallet->BlockUntilSyncedToCurrentChain();
592 "getreceivedbylabel",
593 "Returns the total amount received by addresses with <label> in "
594 "transactions with at least [minconf] confirmations.\n",
597 "The selected label, may be the default label using \"\"."},
599 "Only include transactions confirmed at least this many times."},
603 " received for this label."},
604 RPCExamples{
"\nAmount received by the default label with at least 1 "
607 "\nAmount received at the tabby label including "
608 "unconfirmed amounts with zero confirmations\n" +
610 "\nThe amount with at least 6 confirmations\n" +
612 "\nAs a JSON-RPC call\n" +
616 std::shared_ptr<CWallet>
const wallet =
626 pwallet->BlockUntilSyncedToCurrentChain();
639 "Returns the total available balance.\n"
640 "The available balance is what the wallet considers currently "
641 "spendable, and is\n"
642 "thus affected by options which limit spendability such as "
643 "-spendzeroconfchange.\n",
646 "Remains for backward compatibility. Must be excluded or set to "
649 "Only include transactions confirmed at least this many times."},
652 "true for watch-only wallets, otherwise false"},
653 "Also include balance in watch-only addresses (see "
656 "(only available if avoid_reuse wallet flag is set) Do not "
657 "include balance in dirty outputs; addresses are considered dirty "
658 "if they have previously been used in a transaction."},
662 " received for this wallet."},
664 "\nThe total amount in the wallet with 0 or more confirmations\n" +
666 "\nThe total amount in the wallet with at least 6 confirmations\n" +
667 HelpExampleCli(
"getbalance",
"\"*\" 6") +
"\nAs a JSON-RPC call\n" +
671 std::shared_ptr<CWallet>
const wallet =
681 pwallet->BlockUntilSyncedToCurrentChain();
685 const UniValue &dummy_value = request.params[0];
689 "dummy first argument must be excluded or set to \"*\".");
693 if (!request.params[1].isNull()) {
694 min_depth = request.params[1].getInt<
int>();
697 bool include_watchonly =
702 const auto bal =
GetBalance(*pwallet, min_depth, avoid_reuse);
704 return bal.m_mine_trusted + (include_watchonly
705 ? bal.m_watchonly_trusted
713 "getunconfirmedbalance",
714 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
720 std::shared_ptr<CWallet>
const wallet =
730 pwallet->BlockUntilSyncedToCurrentChain();
742 "Send multiple times. Amounts are double-precision "
743 "floating point numbers." +
747 "Must be set to \"\" for backwards compatibility.",
749 .oneline_description =
"\"\""}},
754 "The addresses and amounts",
757 "The bitcoin address is the key, the numeric amount (can "
763 "Only use the balance confirmed at least this many times."},
771 " The fee will be equally deducted "
772 "from the amount of each selected address.\n"
773 " Those recipients will receive less "
774 "bitcoins than you enter in their corresponding amount field.\n"
775 " If no addresses are specified "
776 "here, the sender pays the fee.",
779 "Subtract fee from this address"},
784 "The transaction id for the send. Only 1 transaction is "
785 "created regardless of the number of addresses."},
787 "\nSend two amounts to two different addresses:\n" +
791 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
793 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
795 "\nSend two amounts to two different addresses setting the "
796 "confirmation and comment:\n" +
800 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
802 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
805 "\nSend two amounts to two different addresses, subtract fee "
810 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
812 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
814 "\"[\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\","
815 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\"]"
817 "\nAs a JSON-RPC call\n" +
821 "{\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\":0.01,"
822 "\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\":0.02}, "
827 std::shared_ptr<CWallet>
const wallet =
837 pwallet->BlockUntilSyncedToCurrentChain();
841 if (!request.params[0].isNull() &&
842 !request.params[0].get_str().empty()) {
844 "Dummy value must be set to \"\"");
849 if (!request.params[3].isNull() &&
850 !request.params[3].get_str().empty()) {
851 mapValue[
"comment"] = request.params[3].
get_str();
855 if (!request.params[4].isNull()) {
856 subtractFeeFromAmount = request.params[4].
get_array();
859 std::vector<CRecipient> recipients;
861 wallet->GetChainParams());
864 return SendMoney(pwallet, coin_control, recipients,
865 std::move(mapValue));
872 "addmultisigaddress",
873 "Add an nrequired-to-sign multisignature address to the wallet. "
874 "Requires a new wallet backup.\n"
875 "Each key is a Bitcoin address or hex-encoded public key.\n"
876 "This functionality is only intended for use with non-watchonly "
878 "See `importaddress` for watchonly p2sh address support.\n"
879 "If 'label' is specified (DEPRECATED), assign address to that label.\n",
882 "The number of required signatures out of the n keys or "
888 "The bitcoin addresses or hex-encoded public keys",
891 "bitcoin address or hex-encoded public key"},
895 "A label to assign the addresses to."},
902 "The value of the new multisig address"},
904 "The string value of the hex-encoded redemption script"},
906 "The descriptor for this multisig"},
909 "\nAdd a multisig address from 2 addresses\n" +
912 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
913 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
914 "\nAs a JSON-RPC call\n" +
917 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
918 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")},
921 std::shared_ptr<CWallet>
const wallet =
934 if (!request.params[2].isNull()) {
938 int required = request.params[0].getInt<
int>();
942 std::vector<CPubKey> pubkeys;
943 for (
size_t i = 0; i < keys_or_addrs.size(); ++i) {
944 if (
IsHex(keys_or_addrs[i].get_str()) &&
945 (keys_or_addrs[i].get_str().length() == 66 ||
946 keys_or_addrs[i].get_str().length() == 130)) {
951 keys_or_addrs[i].get_str()));
960 required, pubkeys, output_type, spk_man, inner);
964 std::unique_ptr<Descriptor> descriptor =
970 result.
pushKV(
"descriptor", descriptor->ToString());
978 int nConf{std::numeric_limits<int>::max()};
985 const UniValue ¶ms,
bool by_label)
989 if (!params[0].
isNull()) {
990 nMinDepth = params[0].getInt<
int>();
994 bool fIncludeEmpty =
false;
995 if (!params[1].
isNull()) {
996 fIncludeEmpty = params[1].get_bool();
1004 bool has_filtered_address =
false;
1006 if (!by_label && params.size() > 3) {
1008 pwallet->GetChainParams())) {
1010 "address_filter parameter was invalid");
1014 has_filtered_address =
true;
1018 std::map<CTxDestination, tallyitem> mapTally;
1019 for (
const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) {
1026 int nDepth = pwallet->GetTxDepthInMainChain(wtx);
1027 if (nDepth < nMinDepth) {
1031 for (
const CTxOut &txout : wtx.
tx->vout) {
1037 if (has_filtered_address && !(filtered_address == address)) {
1042 if (!(mine & filter)) {
1058 std::map<std::string, tallyitem> label_tally;
1062 auto start = pwallet->m_address_book.begin();
1063 auto end = pwallet->m_address_book.end();
1065 if (has_filtered_address) {
1066 start = pwallet->m_address_book.find(filtered_address);
1068 end = std::next(start);
1072 for (
auto item_it = start; item_it != end; ++item_it) {
1073 if (item_it->second.IsChange()) {
1077 const std::string &label = item_it->second.GetLabel();
1078 std::map<CTxDestination, tallyitem>::iterator it =
1079 mapTally.find(address);
1080 if (it == mapTally.end() && !fIncludeEmpty) {
1085 int nConf = std::numeric_limits<int>::max();
1086 bool fIsWatchonly =
false;
1087 if (it != mapTally.end()) {
1088 nAmount = (*it).second.nAmount;
1089 nConf = (*it).second.nConf;
1090 fIsWatchonly = (*it).second.fIsWatchonly;
1101 obj.
pushKV(
"involvesWatchonly",
true);
1104 obj.
pushKV(
"amount", nAmount);
1105 obj.
pushKV(
"confirmations",
1106 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1107 obj.
pushKV(
"label", label);
1109 if (it != mapTally.end()) {
1110 for (
const uint256 &_item : (*it).second.txids) {
1114 obj.
pushKV(
"txids", transactions);
1120 for (
const auto &entry : label_tally) {
1121 Amount nAmount = entry.second.nAmount;
1122 int nConf = entry.second.nConf;
1124 if (entry.second.fIsWatchonly) {
1125 obj.
pushKV(
"involvesWatchonly",
true);
1127 obj.
pushKV(
"amount", nAmount);
1128 obj.
pushKV(
"confirmations",
1129 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1130 obj.
pushKV(
"label", entry.first);
1140 "listreceivedbyaddress",
1141 "List balances by receiving address.\n",
1144 "The minimum number of confirmations before payments are "
1147 "Whether to include addresses that haven't received any "
1151 "true for watch-only wallets, otherwise false"},
1152 "Whether to include watch-only addresses (see 'importaddress')."},
1155 "If present, only return information on this address."},
1167 "Only returns true if imported addresses were involved "
1172 " received by the address"},
1174 "The number of confirmations of the most recent "
1175 "transaction included"},
1177 "The label of the receiving address. The default label "
1184 "The ids of transactions received with the address"},
1193 "listreceivedbyaddress",
1194 "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")},
1197 std::shared_ptr<CWallet>
const wallet =
1207 pwallet->BlockUntilSyncedToCurrentChain();
1211 return ListReceived(config, pwallet, request.params,
false);
1218 "listreceivedbylabel",
1219 "List received transactions by label.\n",
1222 "The minimum number of confirmations before payments are "
1225 "Whether to include labels that haven't received any payments."},
1228 "true for watch-only wallets, otherwise false"},
1229 "Whether to include watch-only addresses (see 'importaddress')."},
1241 "Only returns true if imported addresses were involved "
1244 "The total amount received by addresses with this label"},
1246 "The number of confirmations of the most recent "
1247 "transaction included"},
1249 "The label of the receiving address. The default label "
1258 std::shared_ptr<CWallet>
const wallet =
1268 pwallet->BlockUntilSyncedToCurrentChain();
1272 return ListReceived(config, pwallet, request.params,
true);
1295 template <
class Vec>
1297 int nMinDepth,
bool fLong, Vec &ret,
1299 const std::string *filter_label)
1302 std::list<COutputEntry> listReceived;
1303 std::list<COutputEntry> listSent;
1311 if (!filter_label) {
1314 if (involvesWatchonly ||
1316 entry.
pushKV(
"involvesWatchonly",
true);
1319 entry.
pushKV(
"category",
"send");
1320 entry.
pushKV(
"amount", -s.amount);
1321 const auto *address_book_entry =
1322 pwallet->FindAddressBookEntry(s.destination);
1323 if (address_book_entry) {
1324 entry.
pushKV(
"label", address_book_entry->GetLabel());
1326 entry.
pushKV(
"vout", s.vout);
1327 entry.
pushKV(
"fee", -1 * nFee);
1331 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1332 ret.push_back(entry);
1337 if (listReceived.size() > 0 &&
1338 pwallet->GetTxDepthInMainChain(wtx) >= nMinDepth) {
1341 const auto *address_book_entry =
1342 pwallet->FindAddressBookEntry(r.destination);
1343 if (address_book_entry) {
1344 label = address_book_entry->GetLabel();
1346 if (filter_label && label != *filter_label) {
1350 if (involvesWatchonly ||
1352 entry.
pushKV(
"involvesWatchonly",
true);
1355 if (wtx.IsCoinBase()) {
1356 if (pwallet->GetTxDepthInMainChain(wtx) < 1) {
1357 entry.
pushKV(
"category",
"orphan");
1358 }
else if (pwallet->IsTxImmatureCoinBase(wtx)) {
1359 entry.
pushKV(
"category",
"immature");
1361 entry.
pushKV(
"category",
"generate");
1364 entry.
pushKV(
"category",
"receive");
1366 entry.
pushKV(
"amount", r.amount);
1367 if (address_book_entry) {
1368 entry.
pushKV(
"label", label);
1370 entry.
pushKV(
"vout", r.vout);
1374 ret.push_back(entry);
1382 "The number of confirmations for the transaction. Negative "
1383 "confirmations means the\n"
1384 "transaction conflicted that many blocks ago."},
1386 "Only present if transaction only input is a coinbase one."},
1388 "Only present if we consider transaction to be trusted and so safe to "
1391 "The block hash containing the transaction."},
1393 "The block height containing the transaction."},
1395 "The index of the transaction in the block that includes it."},
1401 "Conflicting transaction ids.",
1410 "If a comment is associated with the transaction, only present if not "
1419 "If a label name is provided, this will return only incoming "
1420 "transactions paying to addresses with the specified label.\n"
1421 "\nReturns up to 'count' most recent transactions skipping the first "
1422 "'from' transactions.\n",
1426 "If set, should be a valid label name to return only incoming "
1427 "transactions with the specified label, or \"*\" to disable "
1428 "filtering and return all transactions."},
1430 "The number of transactions to return"},
1432 "The number of transactions to skip"},
1435 "true for watch-only wallets, otherwise false"},
1436 "Include transactions to watch-only addresses (see "
1437 "'importaddress')"},
1445 Cat(
Cat<std::vector<RPCResult>>(
1448 "Only returns true if imported addresses were "
1449 "involved in transaction."},
1451 "The bitcoin address of the transaction."},
1453 "The transaction category.\n"
1454 "\"send\" Transactions sent.\n"
1455 "\"receive\" Non-coinbase "
1456 "transactions received.\n"
1457 "\"generate\" Coinbase transactions "
1458 "received with more than 100 confirmations.\n"
1459 "\"immature\" Coinbase transactions "
1460 "received with 100 or fewer confirmations.\n"
1461 "\"orphan\" Orphaned coinbase "
1462 "transactions received."},
1464 "The amount in " + ticker +
1465 ". This is negative for the 'send' category, "
1467 "for all other categories"},
1469 "A comment for the address/transaction, if any"},
1472 "The amount of the fee in " + ticker +
1473 ". This is negative and only available for "
1475 "'send' category of transactions."},
1480 "'true' if the transaction has been abandoned "
1481 "(inputs are respendable). Only available for the \n"
1482 "'send' category of transactions."},
1485 RPCExamples{
"\nList the most recent 10 transactions in the systems\n" +
1487 "\nList transactions 100 to 120\n" +
1489 "\nAs a JSON-RPC call\n" +
1493 std::shared_ptr<CWallet>
const wallet =
1503 pwallet->BlockUntilSyncedToCurrentChain();
1505 const std::string *filter_label =
nullptr;
1506 if (!request.params[0].isNull() &&
1507 request.params[0].get_str() !=
"*") {
1508 filter_label = &request.params[0].get_str();
1509 if (filter_label->empty()) {
1512 "Label argument must be a valid label name or \"*\".");
1516 if (!request.params[1].isNull()) {
1517 nCount = request.params[1].getInt<
int>();
1521 if (!request.params[2].isNull()) {
1522 nFrom = request.params[2].getInt<
int>();
1537 std::vector<UniValue> ret;
1544 for (CWallet::TxItems::const_reverse_iterator it =
1546 it != txOrdered.rend(); ++it) {
1550 if (
int(ret.size()) >= (nCount + nFrom)) {
1558 if (nFrom > (
int)ret.size()) {
1561 if ((nFrom + nCount) > (
int)ret.size()) {
1562 nCount = ret.size() - nFrom;
1565 auto txs_rev_it{std::make_move_iterator(ret.rend())};
1568 result.push_backV(txs_rev_it - nFrom - nCount, txs_rev_it - nFrom);
1578 "Get all transactions in blocks since block [blockhash], or all "
1579 "transactions if omitted.\n"
1580 "If \"blockhash\" is no longer a part of the main chain, transactions "
1581 "from the fork point onward are included.\n"
1582 "Additionally, if include_removed is set, transactions affecting the "
1583 "wallet which were removed are returned in the \"removed\" array.\n",
1587 "If set, the block hash to list transactions since, otherwise "
1588 "list all transactions."},
1590 "Return the nth block hash from the main chain. e.g. 1 would mean "
1591 "the best block hash. Note: this is not used as a filter, but "
1592 "only affects [lastblock] in the return value"},
1595 "true for watch-only wallets, otherwise false"},
1596 "Include transactions to watch-only addresses (see "
1597 "'importaddress')"},
1599 "Show transactions that were removed due to a reorg in the "
1600 "\"removed\" array\n"
1602 "guaranteed to work on pruned nodes)"},
1614 Cat(
Cat<std::vector<RPCResult>>(
1617 "Only returns true if imported addresses "
1618 "were involved in transaction."},
1620 "The bitcoin address of the transaction."},
1622 "The transaction category.\n"
1623 "\"send\" Transactions "
1625 "\"receive\" Non-coinbase "
1626 "transactions received.\n"
1627 "\"generate\" Coinbase "
1628 "transactions received with more than 100 "
1630 "\"immature\" Coinbase "
1631 "transactions received with 100 or fewer "
1633 "\"orphan\" Orphaned "
1634 "coinbase transactions received."},
1636 "The amount in " + ticker +
1637 ". This is negative for the 'send' "
1638 "category, and is positive\n"
1639 "for all other categories"},
1643 "The amount of the fee in " + ticker +
1644 ". This is negative and only available "
1646 "'send' category of transactions."},
1651 "'true' if the transaction has been abandoned "
1652 "(inputs are respendable). Only available for "
1654 "'send' category of transactions."},
1656 "If a comment is associated with the "
1659 "A comment for the address/transaction, if any"},
1661 "If a comment to is associated with the "
1667 "<structure is the same as \"transactions\" above, only "
1668 "present if include_removed=true>\n"
1669 "Note: transactions that were re-added in the active chain "
1670 "will appear as-is in this array, and may thus have a "
1671 "positive confirmation count.",
1676 "The hash of the block (target_confirmations-1) from the best "
1677 "block on the main chain, or the genesis hash if the "
1678 "referenced block does not exist yet. This is typically used "
1679 "to feed back into listsinceblock the next time you call it. "
1680 "So you would generally use a target_confirmations of say 6, "
1681 "so you will be continually re-notified of transactions until "
1682 "they've reached 6 confirmations plus any new ones"},
1686 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1687 "7d38571037cdb1a57f663ad\" 6") +
1689 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1690 "7d38571037cdb1a57f663ad\", 6")},
1693 std::shared_ptr<CWallet>
const pwallet =
1704 wallet.BlockUntilSyncedToCurrentChain();
1710 std::optional<int> height;
1714 std::optional<int> altheight;
1715 int target_confirms = 1;
1719 if (!request.params[0].isNull() &&
1720 !request.params[0].get_str().empty()) {
1724 if (!
wallet.chain().findCommonAncestor(
1725 blockId,
wallet.GetLastBlockHash(),
1733 if (!request.params[1].isNull()) {
1734 target_confirms = request.params[1].getInt<
int>();
1736 if (target_confirms < 1) {
1738 "Invalid parameter");
1746 bool include_removed =
1747 (request.params[3].isNull() || request.params[3].get_bool());
1749 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1753 for (
const std::pair<const TxId, CWalletTx> &pairWtx :
1757 if (depth == -1 ||
wallet.GetTxDepthInMainChain(tx) < depth) {
1766 while (include_removed && altheight && *altheight > *height) {
1768 if (!
wallet.chain().findBlock(blockId,
1772 "Can't read block from disk");
1775 auto it =
wallet.mapWallet.find(tx->GetId());
1776 if (it !=
wallet.mapWallet.end()) {
1791 std::min(target_confirms,
wallet.GetLastBlockHeight() + 1);
1793 wallet.GetLastBlockHash(),
1794 wallet.GetLastBlockHeight() + 1 - target_confirms,
1798 ret.
pushKV(
"transactions", transactions);
1799 if (include_removed) {
1800 ret.
pushKV(
"removed", removed);
1813 "Get detailed information about in-wallet transaction <txid>\n",
1816 "The transaction id"},
1819 "true for watch-only wallets, otherwise false"},
1820 "Whether to include watch-only addresses in balance calculation "
1823 "Whether to include a `decoded` field containing the decoded "
1824 "transaction (equivalent to RPC decoderawtransaction)"},
1828 Cat(
Cat<std::vector<RPCResult>>(
1831 "The amount in " + ticker},
1833 "The amount of the fee in " + ticker +
1834 ". This is negative and only available for the\n"
1835 "'send' category of transactions."},
1848 "Only returns true if imported addresses were "
1849 "involved in transaction."},
1851 "The bitcoin address involved in the "
1854 "The transaction category.\n"
1855 "\"send\" Transactions sent.\n"
1856 "\"receive\" Non-coinbase "
1857 "transactions received.\n"
1858 "\"generate\" Coinbase "
1859 "transactions received with more than 100 "
1861 "\"immature\" Coinbase "
1862 "transactions received with 100 or fewer "
1864 "\"orphan\" Orphaned coinbase "
1865 "transactions received."},
1867 "The amount in " + ticker},
1869 "A comment for the address/transaction, if any"},
1872 "The amount of the fee in " + ticker +
1873 ". This is negative and only available for "
1875 "'send' category of transactions."},
1877 "'true' if the transaction has been abandoned "
1878 "(inputs are respendable). Only available for "
1880 "'send' category of transactions."},
1884 "Raw data for transaction"},
1887 "Optional, the decoded transaction (only present when "
1888 "`verbose` is passed)",
1891 "Equivalent to the RPC decoderawtransaction method, "
1892 "or the RPC getrawtransaction method when `verbose` "
1897 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1898 "5cf302fc80e9d5fbf5d48d\"") +
1900 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1901 "5cf302fc80e9d5fbf5d48d\" true") +
1903 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1904 "5cf302fc80e9d5fbf5d48d\" false true") +
1906 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1907 "5cf302fc80e9d5fbf5d48d\"")},
1910 std::shared_ptr<CWallet>
const wallet =
1920 pwallet->BlockUntilSyncedToCurrentChain();
1931 bool verbose = request.params[2].isNull()
1933 : request.params[2].get_bool();
1936 auto it = pwallet->mapWallet.find(txid);
1937 if (it == pwallet->mapWallet.end()) {
1939 "Invalid or non-wallet transaction id");
1945 Amount nNet = nCredit - nDebit;
1947 ? wtx.
tx->GetValueOut() - nDebit
1950 entry.
pushKV(
"amount", nNet - nFee);
1952 entry.
pushKV(
"fee", nFee);
1960 entry.
pushKV(
"details", details);
1962 std::string strHex =
1964 entry.
pushKV(
"hex", strHex);
1969 entry.
pushKV(
"decoded", decoded);
1979 "abandontransaction",
1980 "Mark in-wallet transaction <txid> as abandoned\n"
1981 "This will mark this transaction and all its in-wallet descendants as "
1982 "abandoned which will allow\n"
1983 "for their inputs to be respent. It can be used to replace \"stuck\" "
1984 "or evicted transactions.\n"
1985 "It only works on transactions which are not included in a block and "
1986 "are not currently in the mempool.\n"
1987 "It has no effect on transactions which are already abandoned.\n",
1990 "The transaction id"},
1994 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1995 "5cf302fc80e9d5fbf5d48d\"") +
1997 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1998 "5cf302fc80e9d5fbf5d48d\"")},
2001 std::shared_ptr<CWallet>
const wallet =
2011 pwallet->BlockUntilSyncedToCurrentChain();
2017 if (!pwallet->mapWallet.count(txid)) {
2019 "Invalid or non-wallet transaction id");
2024 "Transaction not eligible for abandonment");
2038 "The new keypool size"},
2045 std::shared_ptr<CWallet>
const wallet =
2056 "Error: Private keys are disabled for this wallet");
2063 unsigned int kpSize = 0;
2064 if (!request.params[0].isNull()) {
2065 if (request.params[0].getInt<
int>() < 0) {
2068 "Invalid parameter, expected valid size.");
2070 kpSize = (
unsigned int)request.params[0].getInt<
int>();
2078 "Error refreshing keypool.");
2089 "Updates list of temporarily unspendable outputs.\n"
2090 "Temporarily lock (unlock=false) or unlock (unlock=true) specified "
2091 "transaction outputs.\n"
2092 "If no transaction outputs are specified when unlocking then all "
2093 "current locked transaction outputs are unlocked.\n"
2094 "A locked transaction output will not be chosen by automatic coin "
2095 "selection, when spending bitcoins.\n"
2096 "Manually selected coins are automatically unlocked.\n"
2097 "Locks are stored in memory only. Nodes start with zero locked "
2098 "outputs, and the locked output list\n"
2099 "is always cleared (by virtue of process exit) when a node stops or "
2101 "Also see the listunspent call\n",
2104 "Whether to unlock (true) or lock (false) the specified "
2110 "The transaction outputs and within each, txid (string) vout "
2122 "The output number"},
2129 "Whether the command was successful or not"},
2131 "\nList the unspent transactions\n" +
2133 "\nLock an unspent transaction\n" +
2136 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2137 "b764ed838b5655e72f463568df1aadf0\\\""
2138 ",\\\"vout\\\":1}]\"") +
2139 "\nList the locked transactions\n" +
2141 "\nUnlock the transaction again\n" +
2144 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2145 "b764ed838b5655e72f463568df1aadf0\\\""
2146 ",\\\"vout\\\":1}]\"") +
2147 "\nAs a JSON-RPC call\n" +
2150 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2151 "b764ed838b5655e72f463568df1aadf0\\\""
2152 ",\\\"vout\\\":1}]\"")},
2155 std::shared_ptr<CWallet>
const wallet =
2165 pwallet->BlockUntilSyncedToCurrentChain();
2169 bool fUnlock = request.params[0].get_bool();
2171 if (request.params[1].isNull()) {
2182 std::vector<COutPoint> outputs;
2185 for (
size_t idx = 0; idx < output_params.
size(); idx++) {
2197 "Invalid parameter, vout cannot be negative");
2201 const auto it = pwallet->mapWallet.find(txid);
2202 if (it == pwallet->mapWallet.end()) {
2205 "Invalid parameter, unknown transaction");
2210 if (output.
GetN() >= trans.
tx->vout.size()) {
2213 "Invalid parameter, vout index out of bounds");
2216 if (pwallet->
IsSpent(output)) {
2219 "Invalid parameter, expected unspent output");
2223 if (fUnlock && !is_locked) {
2226 "Invalid parameter, expected locked output");
2229 if (!fUnlock && is_locked) {
2232 "Invalid parameter, output already locked");
2235 outputs.push_back(output);
2239 for (
const COutPoint &output : outputs) {
2255 "Returns list of temporarily unspendable outputs.\n"
2256 "See the lockunspent call to lock and unlock transactions for "
2268 "The transaction id locked"},
2273 "\nList the unspent transactions\n" +
2275 "\nLock an unspent transaction\n" +
2278 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2279 "b764ed838b5655e72f463568df1aadf0\\\""
2280 ",\\\"vout\\\":1}]\"") +
2281 "\nList the locked transactions\n" +
2283 "\nUnlock the transaction again\n" +
2286 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2287 "b764ed838b5655e72f463568df1aadf0\\\""
2288 ",\\\"vout\\\":1}]\"") +
2289 "\nAs a JSON-RPC call\n" +
HelpExampleRpc(
"listlockunspent",
"")},
2292 std::shared_ptr<CWallet>
const wallet =
2301 std::vector<COutPoint> vOutpts;
2306 for (
const COutPoint &output : vOutpts) {
2309 o.
pushKV(
"txid", output.GetTxId().GetHex());
2310 o.
pushKV(
"vout",
int(output.GetN()));
2322 "Set the transaction fee per kB for this wallet. Overrides the "
2323 "global -paytxfee command line parameter.\n"
2324 "Can be deactivated by passing 0 as the fee. In that case automatic "
2325 "fee selection will be used by default.\n",
2335 std::shared_ptr<CWallet>
const wallet =
2345 CFeeRate tx_fee_rate(nAmount, 1000);
2349 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2352 strprintf(
"txfee cannot be less than min relay tx fee (%s)",
2354 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2357 strprintf(
"txfee cannot be less than wallet min fee (%s)",
2359 }
else if (tx_fee_rate > max_tx_fee_rate) {
2363 "txfee cannot be more than wallet max tx fee (%s)",
2385 "balances from outputs that the wallet can sign",
2388 "trusted balance (outputs created by the wallet or "
2389 "confirmed outputs)"},
2391 "untrusted pending balance (outputs created by "
2392 "others that are in the mempool)"},
2394 "balance from immature coinbase outputs"},
2396 "(only present if avoid_reuse is set) balance from "
2397 "coins sent to addresses that were previously "
2398 "spent from (potentially privacy violating)"},
2402 "watchonly balances (not present if wallet does not "
2406 "trusted balance (outputs created by the wallet or "
2407 "confirmed outputs)"},
2409 "untrusted pending balance (outputs created by "
2410 "others that are in the mempool)"},
2412 "balance from immature coinbase outputs"},
2419 std::shared_ptr<CWallet>
const rpc_wallet =
2429 wallet.BlockUntilSyncedToCurrentChain();
2437 balances_mine.pushKV(
"trusted", bal.m_mine_trusted);
2438 balances_mine.pushKV(
"untrusted_pending",
2439 bal.m_mine_untrusted_pending);
2440 balances_mine.pushKV(
"immature", bal.m_mine_immature);
2446 balances_mine.pushKV(
"used",
2447 full_bal.m_mine_trusted +
2448 full_bal.m_mine_untrusted_pending -
2449 bal.m_mine_trusted -
2450 bal.m_mine_untrusted_pending);
2452 balances.pushKV(
"mine", balances_mine);
2454 auto spk_man =
wallet.GetLegacyScriptPubKeyMan();
2455 if (spk_man && spk_man->HaveWatchOnly()) {
2457 balances_watchonly.pushKV(
"trusted", bal.m_watchonly_trusted);
2458 balances_watchonly.pushKV(
"untrusted_pending",
2459 bal.m_watchonly_untrusted_pending);
2460 balances_watchonly.pushKV(
"immature", bal.m_watchonly_immature);
2461 balances.pushKV(
"watchonly", balances_watchonly);
2471 "Returns an object containing various wallet state info.\n",
2481 "DEPRECATED. Identical to getbalances().mine.trusted"},
2483 "DEPRECATED. Identical to "
2484 "getbalances().mine.untrusted_pending"},
2486 "DEPRECATED. Identical to getbalances().mine.immature"},
2488 "the total number of transactions in the wallet"},
2491 " of the oldest pre-generated key in the key pool. "
2492 "Legacy wallets only."},
2494 "how many new keys are pre-generated (only counts external "
2497 "how many new keys are pre-generated for internal use (used "
2498 "for change outputs, only appears if the wallet is using "
2499 "this feature, otherwise external keys are used)"},
2503 " until which the wallet is unlocked for transfers, or 0 "
2504 "if the wallet is locked (only present for "
2505 "passphrase-encrypted wallets)"},
2507 "the transaction fee configuration, set in " +
2510 "the Hash160 of the HD seed (only present when HD is "
2513 "false if privatekeys are disabled for this wallet (enforced "
2514 "watch-only wallet)"},
2517 "current scanning details, or false if no scan is in "
2521 "elapsed seconds since scan start"},
2523 "scanning progress percentage [0.0, 1.0]"},
2527 "whether this wallet tracks clean/dirty coins in terms of "
2530 "whether this wallet uses descriptors for scriptPubKey "
2538 std::shared_ptr<CWallet>
const wallet =
2548 pwallet->BlockUntilSyncedToCurrentChain();
2559 obj.
pushKV(
"balance", bal.m_mine_trusted);
2560 obj.
pushKV(
"unconfirmed_balance", bal.m_mine_untrusted_pending);
2561 obj.
pushKV(
"immature_balance", bal.m_mine_immature);
2562 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2563 if (kp_oldest > 0) {
2564 obj.
pushKV(
"keypoololdest", kp_oldest);
2566 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2578 obj.
pushKV(
"keypoolsize_hd_internal",
2582 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2586 "private_keys_enabled",
2592 obj.
pushKV(
"scanning", scanning);
2594 obj.
pushKV(
"scanning",
false);
2596 obj.
pushKV(
"avoid_reuse",
2598 obj.
pushKV(
"descriptors",
2608 "Returns a list of wallets in the wallet directory.\n",
2634 wallet.pushKV(
"name", path.u8string());
2639 result.
pushKV(
"wallets", wallets);
2648 "Returns a list of currently loaded wallets.\n"
2649 "For full information on the wallet, use \"getwalletinfo\"\n",
2676 "Loads a wallet from a wallet file or directory."
2677 "\nNote that all wallet command-line options used when starting "
2679 "\napplied to the new wallet (eg -rescan, etc).\n",
2682 "The wallet directory or .dat file."},
2685 "Save wallet name to persistent settings and load on startup. "
2686 "True to add wallet to startup list, false to remove, null to "
2687 "leave unchanged."},
2694 "The wallet name if loaded successfully."},
2696 "Warning message if wallet was not loaded cleanly."},
2703 const std::string
name(request.params[0].get_str());
2705 auto [
wallet, warnings] =
2718 std::string
flags =
"";
2721 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2726 "Change the state of the given wallet flag for a wallet.\n",
2729 "The name of the flag to change. Current available flags: " +
2739 "The name of the flag that was modified"},
2741 "The new state of the flag"},
2743 "Any warnings associated with the change"},
2749 std::shared_ptr<CWallet>
const wallet =
2756 std::string flag_str = request.params[0].get_str();
2758 request.params[1].isNull() || request.params[1].get_bool();
2763 strprintf(
"Unknown wallet flag: %s", flag_str));
2771 strprintf(
"Wallet flag is immutable: %s", flag_str));
2779 strprintf(
"Wallet flag is already set to %s: %s",
2780 value ?
"true" :
"false", flag_str));
2783 res.
pushKV(
"flag_name", flag_str);
2784 res.
pushKV(
"flag_state", value);
2787 pwallet->SetWalletFlag(flag);
2804 "Creates and loads a new wallet.\n",
2807 "The name for the new wallet. If this is a path, the wallet will "
2808 "be created at the path location."},
2810 "Disable the possibility of private keys (only watchonlys are "
2811 "possible in this mode)."},
2813 "Create a blank wallet. A blank wallet has no keys or HD seed. "
2814 "One can be set using sethdseed."},
2816 "Encrypt the wallet with this passphrase."},
2818 "Keep track of coin reuse, and treat dirty and clean coins "
2819 "differently with privacy considerations in mind."},
2821 "Create a native descriptor wallet. The wallet will use "
2822 "descriptors internally to handle address creation"},
2825 "Save wallet name to persistent settings and load on startup. "
2826 "True to add wallet to startup list, false to remove, null to "
2827 "leave unchanged."},
2834 "The wallet name if created successfully. If the wallet "
2835 "was created using a full path, the wallet_name will be "
2838 "Warning message if wallet was not loaded cleanly."},
2844 {
"avoid_reuse",
true},
2845 {
"descriptors",
true},
2846 {
"load_on_startup",
true}}) +
2848 {
"avoid_reuse",
true},
2849 {
"descriptors",
true},
2850 {
"load_on_startup",
true}})},
2855 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2859 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2864 passphrase.reserve(100);
2865 std::vector<bilingual_str> warnings;
2866 if (!request.params[3].isNull()) {
2867 passphrase = request.params[3].get_str().c_str();
2868 if (passphrase.empty()) {
2871 "Empty string given as passphrase, wallet will "
2872 "not be encrypted."));
2876 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2879 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2882 "Wallet is an experimental descriptor wallet"));
2891 std::optional<bool> load_on_start =
2892 request.params[6].isNull()
2894 : std::make_optional<bool>(request.params[6].get_bool());
2895 std::shared_ptr<CWallet>
wallet =
2897 load_on_start, options, status,
error, warnings);
2917 "Unloads the wallet referenced by the request endpoint otherwise "
2918 "unloads the wallet specified in the argument.\n"
2919 "Specifying the wallet name on a wallet endpoint is invalid.",
2923 "The name of the wallet to unload."},
2926 "Save wallet name to persistent settings and load on startup. "
2927 "True to add wallet to startup list, false to remove, null to "
2928 "leave unchanged."},
2935 "Warning message if wallet was not unloaded cleanly."},
2941 std::string wallet_name;
2943 if (!request.params[0].isNull()) {
2945 "Cannot unload the requested wallet");
2948 wallet_name = request.params[0].get_str();
2955 "Requested wallet does not exist or is not loaded");
2961 std::vector<bilingual_str> warnings;
2962 std::optional<bool> load_on_start =
2963 request.params[1].isNull()
2965 : std::make_optional<bool>(request.params[1].get_bool());
2968 "Requested wallet already unloaded");
2985 "Returns array of unspent transaction outputs\n"
2986 "with between minconf and maxconf (inclusive) confirmations.\n"
2987 "Optionally filter to only include txouts paid to specified "
2991 "The minimum confirmations to filter"},
2993 "The maximum confirmations to filter"},
2998 "The bitcoin addresses to filter",
3005 "Include outputs that are not safe to spend\n"
3006 " See description of \"safe\" attribute below."},
3010 "JSON with query options",
3014 "Minimum value of each UTXO in " + ticker +
""},
3017 "Maximum value of each UTXO in " + ticker +
""},
3022 "Minimum sum value of all UTXOs in " + ticker +
""},
3039 "The associated label, or \"\" for the default label"},
3042 "the transaction output amount in " + ticker},
3044 "The number of confirmations"},
3047 "DEPRECATED: The number of in-mempool ancestor "
3048 "transactions, including this one (if transaction is in "
3049 "the mempool). Only displayed if the "
3050 "-deprecatedrpc=mempool_ancestors_descendants option is "
3053 "DEPRECATED: The virtual transaction size of in-mempool "
3054 " ancestors, including this one (if transaction is in "
3055 "the mempool). Only displayed if the "
3056 "-deprecatedrpc=mempool_ancestors_descendants option is "
3060 "DEPRECATED: The total fees of in-mempool ancestors "
3061 "(including this one) with fee deltas used for mining "
3064 " (if transaction is in the mempool). Only "
3066 "-deprecatedrpc=mempool_ancestors_descendants option "
3070 "The redeemScript if scriptPubKey is P2SH"},
3072 "Whether we have the private keys to spend this output"},
3074 "Whether we know how to spend this output, ignoring the "
3077 "(only present if avoid_reuse is set) Whether this "
3078 "output is reused/dirty (sent to an address that was "
3079 "previously spent from)"},
3081 "(only when solvable) A descriptor for spending this "
3084 "Whether this output is considered safe to spend. "
3085 "Unconfirmed transactions\n"
3086 "from outside keys are considered unsafe\n"
3087 "and are not eligible for spending by fundrawtransaction "
3088 "and sendtoaddress."},
3095 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3096 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3099 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3100 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3103 "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") +
3106 "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")},
3109 std::shared_ptr<CWallet>
const wallet =
3117 if (!request.params[0].isNull()) {
3118 nMinDepth = request.params[0].getInt<
int>();
3121 int nMaxDepth = 9999999;
3122 if (!request.params[1].isNull()) {
3123 nMaxDepth = request.params[1].getInt<
int>();
3126 std::set<CTxDestination> destinations;
3127 if (!request.params[2].isNull()) {
3129 for (
size_t idx = 0; idx < inputs.
size(); idx++) {
3130 const UniValue &input = inputs[idx];
3136 std::string(
"Invalid Bitcoin address: ") +
3139 if (!destinations.insert(dest).second) {
3143 "Invalid parameter, duplicated address: ") +
3149 bool include_unsafe =
true;
3150 if (!request.params[3].isNull()) {
3151 include_unsafe = request.params[3].get_bool();
3157 uint64_t nMaximumCount = 0;
3159 if (!request.params[4].isNull()) {
3172 if (options.
exists(
"minimumAmount")) {
3176 if (options.
exists(
"maximumAmount")) {
3180 if (options.
exists(
"minimumSumAmount")) {
3185 if (options.
exists(
"maximumCount")) {
3186 nMaximumCount = options[
"maximumCount"].
getInt<int64_t>();
3193 pwallet->BlockUntilSyncedToCurrentChain();
3196 std::vector<COutput> vecOutputs;
3205 nMaximumAmount, nMinimumSumAmount,
3211 const bool avoid_reuse =
3214 for (
const COutput &out : vecOutputs) {
3217 out.tx->tx->vout[out.i].scriptPubKey;
3220 avoid_reuse && pwallet->
IsSpentKey(out.tx->GetId(), out.i);
3222 if (destinations.size() &&
3223 (!fValidAddress || !destinations.count(address))) {
3228 entry.
pushKV(
"txid", out.tx->GetId().GetHex());
3229 entry.
pushKV(
"vout", out.i);
3231 if (fValidAddress) {
3234 const auto *address_book_entry =
3236 if (address_book_entry) {
3237 entry.
pushKV(
"label", address_book_entry->GetLabel());
3240 std::unique_ptr<SigningProvider> provider =
3245 CScriptID(std::get<ScriptHash>(address));
3247 if (provider->GetCScript(hash, redeemScript)) {
3248 entry.
pushKV(
"redeemScript",
3256 entry.
pushKV(
"amount", out.tx->tx->vout[out.i].nValue);
3257 entry.
pushKV(
"confirmations", out.nDepth);
3258 entry.
pushKV(
"spendable", out.fSpendable);
3259 entry.
pushKV(
"solvable", out.fSolvable);
3260 if (out.fSolvable) {
3261 std::unique_ptr<SigningProvider> provider =
3266 entry.
pushKV(
"desc", descriptor->ToString());
3270 entry.
pushKV(
"reused", reused);
3272 entry.
pushKV(
"safe", out.fSafe);
3282 Amount &fee_out,
int &change_position,
3286 pwallet->BlockUntilSyncedToCurrentChain();
3288 change_position = -1;
3289 bool lockUnspents =
false;
3291 std::set<int> setSubtractFeeFromOutputs;
3323 if (options.
exists(
"add_inputs")) {
3327 if (options.
exists(
"changeAddress") ||
3328 options.
exists(
"change_address")) {
3329 const std::string change_address_str =
3330 (options.
exists(
"change_address")
3331 ? options[
"change_address"]
3332 : options[
"changeAddress"])
3340 "Change address must be a valid bitcoin address");
3346 if (options.
exists(
"changePosition") ||
3347 options.
exists(
"change_position")) {
3348 change_position = (options.
exists(
"change_position")
3349 ? options[
"change_position"]
3350 : options[
"changePosition"])
3354 const UniValue include_watching_option =
3355 options.
exists(
"include_watching") ? options[
"include_watching"]
3356 : options[
"includeWatching"];
3360 if (options.
exists(
"lockUnspents") ||
3361 options.
exists(
"lock_unspents")) {
3363 (options.
exists(
"lock_unspents") ? options[
"lock_unspents"]
3364 : options[
"lockUnspents"])
3368 if (options.
exists(
"include_unsafe")) {
3370 options[
"include_unsafe"].
get_bool();
3373 if (options.
exists(
"feeRate") || options.
exists(
"fee_rate")) {
3375 options.
exists(
"fee_rate") ? options[
"fee_rate"]
3376 : options[
"feeRate"]));
3380 if (options.
exists(
"subtractFeeFromOutputs") ||
3381 options.
exists(
"subtract_fee_from_outputs")) {
3382 subtractFeeFromOutputs =
3383 (options.
exists(
"subtract_fee_from_outputs")
3384 ? options[
"subtract_fee_from_outputs"]
3385 : options[
"subtractFeeFromOutputs"])
3395 if (tx.
vout.size() == 0) {
3397 "TX must have at least one output");
3400 if (change_position != -1 &&
3401 (change_position < 0 ||
3402 (
unsigned int)change_position > tx.
vout.size())) {
3404 "changePosition out of bounds");
3407 for (
size_t idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3408 int pos = subtractFeeFromOutputs[idx].
getInt<
int>();
3409 if (setSubtractFeeFromOutputs.count(pos)) {
3412 strprintf(
"Invalid parameter, duplicated position: %d", pos));
3417 strprintf(
"Invalid parameter, negative position: %d", pos));
3419 if (pos >=
int(tx.
vout.size())) {
3422 strprintf(
"Invalid parameter, position too large: %d", pos));
3424 setSubtractFeeFromOutputs.insert(pos);
3430 lockUnspents, setSubtractFeeFromOutputs,
3439 "fundrawtransaction",
3440 "If the transaction has no inputs, they will be automatically selected "
3441 "to meet its out value.\n"
3442 "It will add at most one change output to the outputs.\n"
3443 "No existing outputs will be modified unless "
3444 "\"subtractFeeFromOutputs\" is specified.\n"
3445 "Note that inputs which were signed may need to be resigned after "
3446 "completion since in/outputs have been added.\n"
3447 "The inputs added will not be signed, use signrawtransactionwithkey or "
3448 "signrawtransactionwithwallet for that.\n"
3449 "Note that all existing inputs must have their previous output "
3450 "transaction be in the wallet.\n"
3451 "Note that all inputs selected must be of standard form and P2SH "
3453 "in the wallet using importaddress or addmultisigaddress (to calculate "
3455 "You can see whether this is the case by checking the \"solvable\" "
3456 "field in the listunspent output.\n"
3457 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently "
3458 "supported for watch-only\n",
3461 "The hex string of the raw transaction"},
3465 "For backward compatibility: passing in a true instead of an "
3466 "object will result in {\"includeWatching\":true}",
3469 "For a transaction with existing inputs, automatically "
3470 "include more if they are not enough."},
3472 "Include inputs that are not safe to spend (unconfirmed "
3473 "transactions from outside keys).\n"
3474 "Warning: the resulting transaction may become invalid if "
3475 "one of the unsafe inputs disappears.\n"
3476 "If that happens, you will need to fund the transaction with "
3477 "different inputs and republish it."},
3480 "The bitcoin address to receive the change"},
3483 "The index of the change output"},
3486 "true for watch-only wallets, otherwise false"},
3487 "Also select inputs which are watch only.\n"
3488 "Only solvable inputs can be used. Watch-only destinations "
3489 "are solvable if the public key and/or output script was "
3491 "e.g. with 'importpubkey' or 'importmulti' with the "
3492 "'pubkeys' or 'desc' field."},
3494 "Lock selected unspent outputs"},
3497 "not set: makes wallet determine the fee"},
3498 "Set a specific fee rate in " + ticker +
"/kB",
3501 "subtractFeeFromOutputs",
3505 " The fee will be equally "
3506 "deducted from the amount of each specified output.\n"
3507 " Those recipients will "
3508 "receive less bitcoins than you enter in their "
3509 "corresponding amount field.\n"
3510 " If no outputs are "
3511 "specified here, the sender pays the fee.",
3515 "The zero-based output index, before a change output "
3521 .oneline_description =
"options"}},
3528 "The resulting raw transaction (hex-encoded string)"},
3530 "Fee in " + ticker +
" the resulting transaction pays"},
3532 "The position of the added change output, or -1"},
3535 "\nCreate a transaction with no inputs\n" +
3537 "\"[]\" \"{\\\"myaddress\\\":10000}\"") +
3538 "\nAdd sufficient unsigned inputs to meet the output value\n" +
3540 "\nSign the transaction\n" +
3542 "\"fundedtransactionhex\"") +
3543 "\nSend the transaction\n" +
3544 HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")},
3547 std::shared_ptr<CWallet>
const wallet =
3556 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
3558 "TX decode failed");
3562 int change_position;
3568 request.params[1], coin_control);
3572 result.
pushKV(
"fee", fee);
3573 result.
pushKV(
"changepos", change_position);
3582 "signrawtransactionwithwallet",
3583 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
3584 "The second optional argument (may be null) is an array of previous "
3585 "transaction outputs that\n"
3586 "this transaction depends on but may not yet be in the block chain.\n" +
3590 "The transaction hex string"},
3595 "The previous dependent transaction outputs",
3606 "The output number"},
3618 "The signature hash type. Must be one of\n"
3620 " \"NONE|FORKID\"\n"
3621 " \"SINGLE|FORKID\"\n"
3622 " \"ALL|FORKID|ANYONECANPAY\"\n"
3623 " \"NONE|FORKID|ANYONECANPAY\"\n"
3624 " \"SINGLE|FORKID|ANYONECANPAY\""},
3632 "The hex-encoded raw transaction with signature(s)"},
3634 "If the transaction has a complete set of signatures"},
3638 "Script verification errors (if there are any)",
3645 "The hash of the referenced, previous transaction"},
3647 "The index of the output to spent and used as "
3650 "The hex-encoded signature script"},
3652 "Script sequence number"},
3654 "Verification or signing error related to the "
3664 std::shared_ptr<CWallet>
const wallet =
3672 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3674 "TX decode failed");
3682 std::map<COutPoint, Coin> coins;
3683 for (
const CTxIn &txin : mtx.
vin) {
3695 "Signature must use SIGHASH_FORKID");
3699 std::map<int, std::string> input_errors;
3714 "Rescan the local blockchain for wallet related transactions.\n"
3715 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3718 "block height where the rescan should start"},
3721 "the last block height that should be scanned"},
3729 "The block height where the rescan started (the requested "
3732 "The height of the last rescanned block. May be null in rare "
3733 "cases if there was a reorg and the call didn't scan any "
3734 "blocks because they were already scanned in the background."},
3740 std::shared_ptr<CWallet>
const wallet =
3750 "Wallet is currently rescanning. Abort "
3751 "existing rescan or wait.");
3754 int start_height = 0;
3755 std::optional<int> stop_height;
3761 if (!request.params[0].isNull()) {
3762 start_height = request.params[0].getInt<
int>();
3763 if (start_height < 0 || start_height > tip_height) {
3765 "Invalid start_height");
3769 if (!request.params[1].isNull()) {
3770 stop_height = request.params[1].getInt<
int>();
3771 if (*stop_height < 0 || *stop_height > tip_height) {
3773 "Invalid stop_height");
3774 }
else if (*stop_height < start_height) {
3777 "stop_height must be greater than start_height");
3784 start_height, stop_height)) {
3787 "Can't rescan beyond pruned data. Use RPC call "
3788 "getblockchaininfo to determine your pruned height.");
3797 start_block, start_height, stop_height, reserver,
3805 "Rescan failed. Potentially corrupted data files.");
3812 response.pushKV(
"start_height", start_height);
3827 std::vector<std::vector<uint8_t>> solutions_data;
3838 UniValue wallet_detail = std::visit(*
this, embedded);
3839 subobj.
pushKVs(wallet_detail);
3844 if (subobj.
exists(
"pubkey")) {
3845 obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3847 obj.
pushKV(
"embedded", std::move(subobj));
3853 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3855 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3856 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3859 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3897 std::unique_ptr<SigningProvider> provider =
nullptr;
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",
4228 "A JSON array with outputs (key-value pairs), where none of "
4229 "the keys are duplicated.\n"
4230 "That is, each address can only appear once and there can only "
4231 "be one 'data' object.\n"
4232 "For convenience, a dictionary, which holds the key-value "
4233 "pairs directly, is also accepted.",
4242 "A key-value pair. The key (string) is the "
4243 "bitcoin address, the value (float or string) is "
4255 "A key-value pair. The key must be \"data\", the "
4256 "value is hex-encoded data"},
4267 "If inputs are specified, automatically include more if they "
4270 "Include inputs that are not safe to spend (unconfirmed "
4271 "transactions from outside keys).\n"
4272 "Warning: the resulting transaction may become invalid if "
4273 "one of the unsafe inputs disappears.\n"
4274 "If that happens, you will need to fund the transaction with "
4275 "different inputs and republish it."},
4277 "When false, returns a serialized transaction which will not "
4278 "be added to the wallet or broadcast"},
4281 "The bitcoin address to receive the change"},
4284 "The index of the change output"},
4287 "not set: makes wallet determine the fee"},
4293 "true for watch-only wallets, otherwise false"},
4294 "Also select inputs which are watch only.\n"
4295 "Only solvable inputs can be used. Watch-only destinations "
4296 "are solvable if the public key and/or output script was "
4298 "e.g. with 'importpubkey' or 'importmulti' with the "
4299 "'pubkeys' or 'desc' field."},
4304 "Specify inputs instead of adding them automatically. A "
4305 "JSON array of JSON objects",
4308 "The transaction id"},
4310 "The output number"},
4312 "The sequence number"},
4316 "Raw locktime. Non-0 value also locktime-activates inputs"},
4318 "Lock selected unspent outputs"},
4320 "Always return a PSBT, implies add_to_wallet=false."},
4322 "subtract_fee_from_outputs",
4325 "Outputs to subtract the fee from, specified as integer "
4327 "The fee will be equally deducted from the amount of each "
4328 "specified output.\n"
4329 "Those recipients will receive less bitcoins than you "
4330 "enter in their corresponding amount field.\n"
4331 "If no outputs are specified here, the sender pays the "
4336 "The zero-based output index, before a change output "
4348 "If the transaction has a complete set of signatures"},
4350 "The transaction id for the send. Only 1 transaction is created "
4351 "regardless of the number of addresses."},
4353 "If add_to_wallet is false, the hex-encoded raw transaction with "
4356 "If more signatures are needed, or if add_to_wallet is false, "
4357 "the base64-encoded (partially) signed transaction"}}},
4360 "\nSend with a fee rate of 10 XEC/kB\n" +
4362 "\": 100000}' '{\"fee_rate\": 10}'\n") +
4363 "\nCreate a transaction with a specific input, and return "
4364 "result without adding to wallet or broadcasting to the "
4368 "\": 100000}' '{\"add_to_wallet\": "
4369 "false, \"inputs\": "
4371 "\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b565"
4372 "5e72f463568df1aadf0\", \"vout\":1}]}'")},
4375 std::shared_ptr<CWallet>
const wallet =
4382 UniValue options = request.params[1];
4383 if (options.
exists(
"changeAddress")) {
4386 if (options.
exists(
"changePosition")) {
4388 "Use change_position");
4390 if (options.
exists(
"includeWatching")) {
4392 "Use include_watching");
4394 if (options.
exists(
"lockUnspents")) {
4397 if (options.
exists(
"subtractFeeFromOutputs")) {
4399 "Use subtract_fee_from_outputs");
4401 if (options.
exists(
"feeRate")) {
4405 const bool psbt_opt_in =
4409 int change_position;
4411 wallet->GetChainParams(), options[
"inputs"], request.params[0],
4412 options[
"locktime"]);
4420 bool add_to_wallet =
true;
4421 if (options.
exists(
"add_to_wallet")) {
4422 add_to_wallet = options[
"add_to_wallet"].
get_bool();
4429 bool complete =
true;
4431 psbtx, complete,
SigHashType().withForkId(),
true,
false);
4441 if (psbt_opt_in || !complete || !add_to_wallet) {
4449 std::string err_string;
4452 result.
pushKV(
"txid", tx->GetHash().GetHex());
4453 if (add_to_wallet && !psbt_opt_in) {
4456 result.
pushKV(
"hex", hex);
4459 result.
pushKV(
"complete", complete);
4468 "Set or generate a new HD wallet seed. Non-HD wallets will not be "
4469 "upgraded to being a HD wallet. Wallets that are already\n"
4470 "HD will have a new HD seed set so that new keys added to the keypool "
4471 "will be derived from this new seed.\n"
4472 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after "
4473 "setting the HD wallet seed.\n" +
4477 "Whether to flush old unused addresses, including change "
4478 "addresses, from the keypool and regenerate it.\n"
4479 " If true, the next address from "
4480 "getnewaddress and change address from getrawchangeaddress will "
4481 "be from this new seed.\n"
4482 " If false, addresses (including "
4483 "change addresses if the wallet already had HD Chain Split "
4484 "enabled) from the existing\n"
4485 " keypool will be used until it has "
4488 "The WIF private key to use as the new HD seed.\n"
4489 " The seed value can be retrieved "
4490 "using the dumpwallet command. It is the private key marked "
4500 std::shared_ptr<CWallet>
const wallet =
4512 "Cannot set a HD seed to a wallet with "
4513 "private keys disabled");
4522 "Cannot set a HD seed on a non-HD wallet. Use the "
4523 "upgradewallet RPC in order to upgrade a non-HD wallet "
4529 bool flush_key_pool =
true;
4530 if (!request.params[0].isNull()) {
4531 flush_key_pool = request.params[0].get_bool();
4535 if (request.params[1].isNull()) {
4541 "Invalid private key");
4547 "Already have this key (either as an HD seed or "
4548 "as a loose private key)");
4555 if (flush_key_pool) {
4566 "walletprocesspsbt",
4567 "Update a PSBT with input information from our wallet and then sign "
4568 "inputs that we can sign for." +
4572 "The transaction base64 string"},
4574 "Also sign the transaction when updating"},
4576 "The signature hash type to sign with if not specified by "
4577 "the PSBT. Must be one of\n"
4579 " \"NONE|FORKID\"\n"
4580 " \"SINGLE|FORKID\"\n"
4581 " \"ALL|FORKID|ANYONECANPAY\"\n"
4582 " \"NONE|FORKID|ANYONECANPAY\"\n"
4583 " \"SINGLE|FORKID|ANYONECANPAY\""},
4585 "Includes the BIP 32 derivation paths for public keys if we know "
4593 "The base64-encoded partially signed transaction"},
4595 "If the transaction has a complete set of signatures"},
4600 std::shared_ptr<CWallet>
const wallet =
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"},
4684 "The outputs (key-value pairs), where none of "
4685 "the keys are duplicated.\n"
4686 "That is, each address can only appear once and there can only "
4687 "be one 'data' object.\n"
4688 "For compatibility reasons, a dictionary, which holds the "
4689 "key-value pairs directly, is also\n"
4690 " accepted as second parameter.",
4699 "A key-value pair. The key (string) is the "
4700 "bitcoin address, the value (float or string) is "
4712 "A key-value pair. The key must be \"data\", the "
4713 "value is hex-encoded data"},
4719 "Raw locktime. Non-0 value also locktime-activates inputs\n"
4720 " Allows this transaction to be "
4721 "replaced by a transaction with higher fees. If provided, it is "
4722 "an error if explicit sequence numbers are incompatible."},
4729 "If inputs are specified, automatically include more if they "
4732 "Include inputs that are not safe to spend (unconfirmed "
4733 "transactions from outside keys).\n"
4734 "Warning: the resulting transaction may become invalid if "
4735 "one of the unsafe inputs disappears.\n"
4736 "If that happens, you will need to fund the transaction with "
4737 "different inputs and republish it."},
4740 "The bitcoin address to receive the change"},
4743 "The index of the change output"},
4746 "true for watch-only wallets, otherwise false"},
4747 "Also select inputs which are watch only"},
4749 "Lock selected unspent outputs"},
4752 "not set: makes wallet determine the fee"},
4753 "Set a specific fee rate in " + ticker +
"/kB",
4756 "subtractFeeFromOutputs",
4759 "The outputs to subtract the fee from.\n"
4760 " The fee will be equally "
4761 "deducted from the amount of each specified output.\n"
4762 " Those recipients will "
4763 "receive less bitcoins than you enter in their "
4764 "corresponding amount field.\n"
4765 " If no outputs are "
4766 "specified here, the sender pays the fee.",
4770 "The zero-based output index, before a change output "
4777 "Includes the BIP 32 derivation paths for public keys if we know "
4785 "The resulting raw transaction (base64-encoded string)"},
4787 "Fee in " + ticker +
" the resulting transaction pays"},
4789 "The position of the added change output, or -1"},
4792 "\nCreate a transaction with no inputs\n" +
4794 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" "
4795 "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
4798 std::shared_ptr<CWallet>
const wallet =
4806 int change_position;
4808 wallet->GetChainParams(), request.params[0], request.params[1],
4815 request.params[3], coin_control);
4821 bool bip32derivs = request.params[4].isNull()
4823 : request.params[4].get_bool();
4824 bool complete =
true;
4827 false, bip32derivs);
4838 result.
pushKV(
"fee", fee);
4839 result.
pushKV(
"changepos", change_position);
4848 "Upgrade the wallet. Upgrades to the latest version if no "
4849 "version number is specified\n"
4850 "New keys may be generated and a new wallet backup will need to "
4853 "The version number to upgrade to. Default is the latest "
4860 std::shared_ptr<CWallet>
const wallet =
4870 if (!request.params[0].isNull()) {
4871 version = request.params[0].getInt<
int>();
4877 return error.original;
4886 "createwallettransaction",
4887 "Create a transaction sending an amount to a given address.\n" +
4891 "The bitcoin address to send to."},
4898 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
4900 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 100000")},
4903 std::shared_ptr<CWallet>
const wallet =
4913 pwallet->BlockUntilSyncedToCurrentChain();
4920 const std::string address = request.params[0].get_str();
4921 address_amounts.
pushKV(address, request.params[1]);
4924 std::vector<CRecipient> recipients;
4926 wallet->GetChainParams());
4929 return SendMoney(pwallet, coin_control, recipients, {},
false);
4968 {
"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_include_unsafe_inputs
If false, only safe inputs will be used (confirmed or self transfers)
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.
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const UniValue & get_obj() const
void pushKVs(UniValue obj)
const std::vector< std::string > & getKeys() const
void pushKVEnd(std::string key, UniValue val)
const UniValue & get_array() const
bool exists(const std::string &key) const
void pushKV(std::string key, 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 whether node has the block and optionally return block metadata or contents.
virtual void findCoins(std::map< COutPoint, Coin > &coins)=0
Look up unspent output information.
virtual bool hasBlocks(const BlockHash &block_hash, int min_height=0, std::optional< int > max_height={})=0
Return true if data is available for all blocks in the specified range of blocks.
virtual bool findAncestorByHeight(const BlockHash &block_hash, int ancestor_height, const FoundBlock &ancestor_out={})=0
Find ancestor of block at specified height and optionally return ancestor information.
virtual CFeeRate relayMinFee()=0
Relay current minimum fee (from -minrelaytxfee settings).
virtual const CChainParams & params() const =0
This Chain's parameters.
Helper for findBlock to selectively return pieces of block data.
const Config & GetConfig()
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
SigHashType ParseSighashString(const UniValue &sighash)
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string >> orderForm, bool broadcast=true)
Add the transaction to the wallet and maybe attempt to broadcast it.
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsLockedCoin(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool TopUpKeyPool(unsigned int kpSize=0)
TransactionError FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=true) const
Fills out a PSBT with information from the wallet.
int64_t GetOldestKeyPoolTime() const
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool CanGetAddresses(bool internal=false) const
Returns true if the wallet can give out new addresses.
ScanResult ScanForWalletTransactions(const BlockHash &start_block, int start_height, std::optional< int > max_height, const WalletRescanReserver &reserver, bool fUpdate)
Scan the block chain (starting in start_block) for transactions from or to us.
bool IsSpentKey(const TxId &txid, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const CChainParams & GetChainParams() const override
bool IsSpent(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction, spends it:
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
bool IsWalletFlagSet(uint64_t flag) const override
Check if a certain wallet flag is set.
bool AbandonTransaction(const TxId &txid)
Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent.
isminetype
IsMine() return codes.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
CKey DecodeSecret(const std::string &str)
bool error(const char *fmt, const Args &...args)
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
static bool isNull(const AnyVoteItem &item)
bool ParseOutputType(const std::string &type, OutputType &output_type)
static CTransactionRef MakeTransactionRef()
std::shared_ptr< const CTransaction > CTransactionRef
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
void SignTransactionResultToJSON(CMutableTransaction &mtx, bool complete, const std::map< COutPoint, Coin > &coins, const std::map< int, std::string > &input_errors, UniValue &result)
CMutableTransaction ConstructTransaction(const CChainParams ¶ms, const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime)
Create a transaction from univalue parameters.
void ParsePrevouts(const UniValue &prevTxsUnival, FillableSigningProvider *keystore, std::map< COutPoint, Coin > &coins)
Parse a prevtxs UniValue array and get the map of coins from it.
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Amount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
std::map< CTxDestination, Amount > GetAddressBalances(const CWallet &wallet)
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, Amount &nFee, const isminefilter &filter)
Amount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< TxId > &trusted_parents)
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
UniValue JSONRPCError(int code, const std::string &message)
RPCErrorCode
Bitcoin RPC error codes.
@ RPC_WALLET_INVALID_LABEL_NAME
Invalid label name.
@ RPC_MISC_ERROR
General application defined errors std::exception thrown in command handling.
@ RPC_WALLET_INSUFFICIENT_FUNDS
Not enough funds in wallet or account.
@ RPC_WALLET_ENCRYPTION_FAILED
Failed to encrypt the wallet.
@ RPC_METHOD_DEPRECATED
RPC method is deprecated.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_WALLET_ERROR
Wallet errors Unspecified problem with wallet (key not found etc.)
@ RPC_WALLET_NOT_FOUND
Invalid wallet specified.
@ RPC_WALLET_KEYPOOL_RAN_OUT
Keypool ran out, call keypoolrefill first.
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector< CPubKey > &pubkeys, OutputType type, FillableSigningProvider &keystore, CScript &script_out)
std::string HelpExampleRpcNamed(const std::string &methodname, const RPCArgList &args)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
Amount AmountFromValue(const UniValue &value)
const std::string EXAMPLE_ADDRESS
Example CashAddr address used in multiple RPCExamples.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
CPubKey HexToPubKey(const std::string &hex_in)
CPubKey AddrToPubKey(const CChainParams &chainparams, const FillableSigningProvider &keystore, const std::string &addr_in)
uint256 ParseHashO(const UniValue &o, std::string strKey)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
Check for expected keys/value types in an Object.
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
UniValue DescribeAddress(const CTxDestination &dest)
static RPCHelpMan createwallet()
static RPCHelpMan getnewaddress()
static RPCHelpMan sethdseed()
static RPCHelpMan listreceivedbylabel()
static RPCHelpMan sendtoaddress()
static RPCHelpMan listunspent()
static RPCHelpMan getrawchangeaddress()
static RPCHelpMan walletprocesspsbt()
static void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx, int nMinDepth, bool fLong, Vec &ret, const isminefilter &filter_ismine, const std::string *filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
List transactions based on the given criteria.
static RPCHelpMan fundrawtransaction()
static RPCHelpMan gettransaction()
static UniValue ListReceived(const Config &config, const CWallet *const pwallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static UniValue AddressBookDataToJSON(const CAddressBookData &data, const bool verbose)
Convert CAddressBookData to JSON record.
static RPCHelpMan listaddressgroupings()
static void WalletTxToJSON(const CWallet &wallet, const CWalletTx &wtx, UniValue &entry) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan addmultisigaddress()
RPCHelpMan getaddressesbylabel()
static RPCHelpMan listlockunspent()
static Amount GetReceived(const CWallet &wallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan getunconfirmedbalance()
static RPCHelpMan listwallets()
RPCHelpMan rescanblockchain()
static RPCHelpMan upgradewallet()
static RPCHelpMan unloadwallet()
static RPCHelpMan walletcreatefundedpsbt()
static RPCHelpMan getbalances()
static RPCHelpMan listwalletdir()
static RPCHelpMan keypoolrefill()
bool HaveKey(const SigningProvider &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
RPCHelpMan getaddressinfo()
static RPCHelpMan getwalletinfo()
static RPCHelpMan lockunspent()
Span< const CRPCCommand > GetWalletRPCCommands()
UniValue SendMoney(CWallet *const pwallet, const CCoinControl &coin_control, std::vector< CRecipient > &recipients, mapValue_t map_value, bool broadcast=true)
static RPCHelpMan setwalletflag()
RPCHelpMan signrawtransactionwithwallet()
static RPCHelpMan createwallettransaction()
static RPCHelpMan setlabel()
static RPCHelpMan getreceivedbyaddress()
static RPCHelpMan getreceivedbylabel()
static void MaybePushAddress(UniValue &entry, const CTxDestination &dest)
static RPCHelpMan getbalance()
static const std::vector< RPCResult > TransactionDescriptionString()
static RPCHelpMan loadwallet()
static RPCHelpMan listsinceblock()
static RPCHelpMan settxfee()
static RPCHelpMan listreceivedbyaddress()
static RPCHelpMan sendmany()
RPCHelpMan listtransactions()
static UniValue DescribeWalletAddress(const CWallet *const pwallet, const CTxDestination &dest)
void ParseRecipients(const UniValue &address_amounts, const UniValue &subtract_fee_outputs, std::vector< CRecipient > &recipients, const CChainParams &chainParams)
void FundTransaction(CWallet *const pwallet, CMutableTransaction &tx, Amount &fee_out, int &change_position, const UniValue &options, CCoinControl &coinControl)
static RPCHelpMan abandontransaction()
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
bool IsSolvable(const SigningProvider &provider, const CScript &script)
Check whether we know how to sign for an output like this, assuming we have all private keys.
bool CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, CTransactionRef &tx, Amount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, bool sign)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
void AvailableCoins(const CWallet &wallet, std::vector< COutput > &vCoins, const CCoinControl *coinControl, const Amount nMinimumAmount, const Amount nMaximumAmount, const Amount nMinimumSumAmount, const uint64_t nMaximumCount)
populate vCoins with vector of available COutputs.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< uint8_t >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
CKeyID ToKeyID(const PKHash &key_hash)
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeBase64(Span< const uint8_t > input)
bool IsHex(const std::string &str)
Returns true if each character in str is a hex character, and has an even number of hex digits.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
static constexpr Amount zero() noexcept
Amount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
A BlockHash is a unqiue identifier for a block.
std::optional< int > last_scanned_height
enum CWallet::ScanResult::@20 status
static const Currency & get()
SecureString create_passphrase
A version of CTransaction with the PSBT format.
@ STR_HEX
Special type that is a STR with only hex chars.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
@ OBJ_NAMED_PARAMS
Special type that behaves almost exactly like OBJ, defining an options object with a list of pre-defi...
std::string DefaultHint
Hint for default value.
@ OMITTED
The arg is optional for one of two reasons:
std::string oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
bool also_positional
If set allows a named-parameter field in an OBJ_NAMED_PARAM options object to have the same name as a...
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ ARR_FIXED
Special array that has a fixed number of entries.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
A TxId is the identifier of a transaction.
Wrapper for UniValue::VType, which includes typeAny: used to denote don't care type.
WalletContext struct containing references to state shared between CWallet instances,...
interfaces::Chain * chain
std::vector< uint256 > txids
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
const UniValue NullUniValue
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
static const int PROTOCOL_VERSION
network protocol versioning
void EnsureWalletIsUnlocked(const CWallet *pwallet)
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
WalletContext & EnsureWalletContext(const std::any &context)
bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
std::tuple< std::shared_ptr< CWallet >, std::vector< bilingual_str > > LoadWalletHelper(WalletContext &context, UniValue load_on_start_param, const std::string wallet_name)
bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &pwallet)
Used by RPC commands that have an include_watchonly parameter.
const std::string HELP_REQUIRING_PASSPHRASE
std::string LabelFromValue(const UniValue &value)
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
std::map< std::string, std::string > mapValue_t
static constexpr uint64_t MUTABLE_WALLET_FLAGS
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
std::shared_ptr< CWallet > GetWallet(const std::string &name)
std::shared_ptr< CWallet > CreateWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
std::vector< std::shared_ptr< CWallet > > GetWallets()
std::vector< fs::path > ListWalletDir()
Get wallets in wallet directory.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...