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].get_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].get_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].get_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)) {
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].get_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);
1296 int nMinDepth,
bool fLong,
UniValue &ret,
1298 const std::string *filter_label)
1301 std::list<COutputEntry> listReceived;
1302 std::list<COutputEntry> listSent;
1310 if (!filter_label) {
1313 if (involvesWatchonly ||
1315 entry.
pushKV(
"involvesWatchonly",
true);
1318 entry.
pushKV(
"category",
"send");
1319 entry.
pushKV(
"amount", -s.amount);
1320 const auto *address_book_entry =
1321 pwallet->FindAddressBookEntry(s.destination);
1322 if (address_book_entry) {
1323 entry.
pushKV(
"label", address_book_entry->GetLabel());
1325 entry.
pushKV(
"vout", s.vout);
1326 entry.
pushKV(
"fee", -1 * nFee);
1330 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1331 ret.push_back(entry);
1336 if (listReceived.size() > 0 &&
1337 pwallet->GetTxDepthInMainChain(wtx) >= nMinDepth) {
1340 const auto *address_book_entry =
1341 pwallet->FindAddressBookEntry(r.destination);
1342 if (address_book_entry) {
1343 label = address_book_entry->GetLabel();
1345 if (filter_label && label != *filter_label) {
1349 if (involvesWatchonly ||
1351 entry.
pushKV(
"involvesWatchonly",
true);
1354 if (wtx.IsCoinBase()) {
1355 if (pwallet->GetTxDepthInMainChain(wtx) < 1) {
1356 entry.
pushKV(
"category",
"orphan");
1357 }
else if (pwallet->IsTxImmatureCoinBase(wtx)) {
1358 entry.
pushKV(
"category",
"immature");
1360 entry.
pushKV(
"category",
"generate");
1363 entry.
pushKV(
"category",
"receive");
1365 entry.
pushKV(
"amount", r.amount);
1366 if (address_book_entry) {
1367 entry.
pushKV(
"label", label);
1369 entry.
pushKV(
"vout", r.vout);
1373 ret.push_back(entry);
1381 "The number of confirmations for the transaction. Negative "
1382 "confirmations means the\n"
1383 "transaction conflicted that many blocks ago."},
1385 "Only present if transaction only input is a coinbase one."},
1387 "Only present if we consider transaction to be trusted and so safe to "
1390 "The block hash containing the transaction."},
1392 "The block height containing the transaction."},
1394 "The index of the transaction in the block that includes it."},
1400 "Conflicting transaction ids.",
1409 "If a comment is associated with the transaction, only present if not "
1418 "If a label name is provided, this will return only incoming "
1419 "transactions paying to addresses with the specified label.\n"
1420 "\nReturns up to 'count' most recent transactions skipping the first "
1421 "'from' transactions.\n",
1425 "If set, should be a valid label name to return only incoming "
1426 "transactions with the specified label, or \"*\" to disable "
1427 "filtering and return all transactions."},
1429 "The number of transactions to return"},
1431 "The number of transactions to skip"},
1434 "true for watch-only wallets, otherwise false"},
1435 "Include transactions to watch-only addresses (see "
1436 "'importaddress')"},
1444 Cat(
Cat<std::vector<RPCResult>>(
1447 "Only returns true if imported addresses were "
1448 "involved in transaction."},
1450 "The bitcoin address of the transaction."},
1452 "The transaction category.\n"
1453 "\"send\" Transactions sent.\n"
1454 "\"receive\" Non-coinbase "
1455 "transactions received.\n"
1456 "\"generate\" Coinbase transactions "
1457 "received with more than 100 confirmations.\n"
1458 "\"immature\" Coinbase transactions "
1459 "received with 100 or fewer confirmations.\n"
1460 "\"orphan\" Orphaned coinbase "
1461 "transactions received."},
1463 "The amount in " + ticker +
1464 ". This is negative for the 'send' category, "
1466 "for all other categories"},
1468 "A comment for the address/transaction, if any"},
1471 "The amount of the fee in " + ticker +
1472 ". This is negative and only available for "
1474 "'send' category of transactions."},
1479 "'true' if the transaction has been abandoned "
1480 "(inputs are respendable). Only available for the \n"
1481 "'send' category of transactions."},
1484 RPCExamples{
"\nList the most recent 10 transactions in the systems\n" +
1486 "\nList transactions 100 to 120\n" +
1488 "\nAs a JSON-RPC call\n" +
1492 std::shared_ptr<CWallet>
const wallet =
1502 pwallet->BlockUntilSyncedToCurrentChain();
1504 const std::string *filter_label =
nullptr;
1505 if (!request.params[0].isNull() &&
1506 request.params[0].get_str() !=
"*") {
1507 filter_label = &request.params[0].get_str();
1508 if (filter_label->empty()) {
1511 "Label argument must be a valid label name or \"*\".");
1515 if (!request.params[1].isNull()) {
1516 nCount = request.params[1].get_int();
1520 if (!request.params[2].isNull()) {
1521 nFrom = request.params[2].get_int();
1543 for (CWallet::TxItems::const_reverse_iterator it =
1545 it != txOrdered.rend(); ++it) {
1549 if (
int(ret.
size()) >= (nCount + nFrom)) {
1557 if (nFrom > (
int)ret.
size()) {
1560 if ((nFrom + nCount) > (
int)ret.
size()) {
1561 nCount = ret.
size() - nFrom;
1564 const std::vector<UniValue> &txs = ret.
getValues();
1568 {txs.rend() - nFrom - nCount, txs.rend() - 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].get_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].get_int() < 0) {
2068 "Invalid parameter, expected valid size.");
2070 kpSize = (
unsigned int)request.params[0].get_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();
2171 bool fUnlock = request.params[0].get_bool();
2173 if (request.params[1].isNull()) {
2182 const UniValue &output_params = request.params[1];
2186 std::vector<COutPoint> outputs;
2189 for (
size_t idx = 0; idx < output_params.
size(); idx++) {
2201 "Invalid parameter, vout cannot be negative");
2205 const auto it = pwallet->mapWallet.find(txid);
2206 if (it == pwallet->mapWallet.end()) {
2209 "Invalid parameter, unknown transaction");
2214 if (output.
GetN() >= trans.
tx->vout.size()) {
2217 "Invalid parameter, vout index out of bounds");
2220 if (pwallet->
IsSpent(output)) {
2223 "Invalid parameter, expected unspent output");
2227 if (fUnlock && !is_locked) {
2230 "Invalid parameter, expected locked output");
2233 if (!fUnlock && is_locked) {
2236 "Invalid parameter, output already locked");
2239 outputs.push_back(output);
2243 for (
const COutPoint &output : outputs) {
2259 "Returns list of temporarily unspendable outputs.\n"
2260 "See the lockunspent call to lock and unlock transactions for "
2272 "The transaction id locked"},
2277 "\nList the unspent transactions\n" +
2279 "\nLock an unspent transaction\n" +
2282 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2283 "b764ed838b5655e72f463568df1aadf0\\\""
2284 ",\\\"vout\\\":1}]\"") +
2285 "\nList the locked transactions\n" +
2287 "\nUnlock the transaction again\n" +
2290 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2291 "b764ed838b5655e72f463568df1aadf0\\\""
2292 ",\\\"vout\\\":1}]\"") +
2293 "\nAs a JSON-RPC call\n" +
HelpExampleRpc(
"listlockunspent",
"")},
2296 std::shared_ptr<CWallet>
const wallet =
2305 std::vector<COutPoint> vOutpts;
2310 for (
const COutPoint &output : vOutpts) {
2313 o.
pushKV(
"txid", output.GetTxId().GetHex());
2314 o.
pushKV(
"vout",
int(output.GetN()));
2326 "Set the transaction fee per kB for this wallet. Overrides the "
2327 "global -paytxfee command line parameter.\n"
2328 "Can be deactivated by passing 0 as the fee. In that case automatic "
2329 "fee selection will be used by default.\n",
2339 std::shared_ptr<CWallet>
const wallet =
2349 CFeeRate tx_fee_rate(nAmount, 1000);
2353 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2356 strprintf(
"txfee cannot be less than min relay tx fee (%s)",
2358 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2361 strprintf(
"txfee cannot be less than wallet min fee (%s)",
2363 }
else if (tx_fee_rate > max_tx_fee_rate) {
2367 "txfee cannot be more than wallet max tx fee (%s)",
2389 "balances from outputs that the wallet can sign",
2392 "trusted balance (outputs created by the wallet or "
2393 "confirmed outputs)"},
2395 "untrusted pending balance (outputs created by "
2396 "others that are in the mempool)"},
2398 "balance from immature coinbase outputs"},
2400 "(only present if avoid_reuse is set) balance from "
2401 "coins sent to addresses that were previously "
2402 "spent from (potentially privacy violating)"},
2406 "watchonly balances (not present if wallet does not "
2410 "trusted balance (outputs created by the wallet or "
2411 "confirmed outputs)"},
2413 "untrusted pending balance (outputs created by "
2414 "others that are in the mempool)"},
2416 "balance from immature coinbase outputs"},
2423 std::shared_ptr<CWallet>
const rpc_wallet =
2433 wallet.BlockUntilSyncedToCurrentChain();
2441 balances_mine.pushKV(
"trusted", bal.m_mine_trusted);
2442 balances_mine.pushKV(
"untrusted_pending",
2443 bal.m_mine_untrusted_pending);
2444 balances_mine.pushKV(
"immature", bal.m_mine_immature);
2450 balances_mine.pushKV(
"used",
2451 full_bal.m_mine_trusted +
2452 full_bal.m_mine_untrusted_pending -
2453 bal.m_mine_trusted -
2454 bal.m_mine_untrusted_pending);
2456 balances.pushKV(
"mine", balances_mine);
2458 auto spk_man =
wallet.GetLegacyScriptPubKeyMan();
2459 if (spk_man && spk_man->HaveWatchOnly()) {
2461 balances_watchonly.pushKV(
"trusted", bal.m_watchonly_trusted);
2462 balances_watchonly.pushKV(
"untrusted_pending",
2463 bal.m_watchonly_untrusted_pending);
2464 balances_watchonly.pushKV(
"immature", bal.m_watchonly_immature);
2465 balances.pushKV(
"watchonly", balances_watchonly);
2475 "Returns an object containing various wallet state info.\n",
2485 "DEPRECATED. Identical to getbalances().mine.trusted"},
2487 "DEPRECATED. Identical to "
2488 "getbalances().mine.untrusted_pending"},
2490 "DEPRECATED. Identical to getbalances().mine.immature"},
2492 "the total number of transactions in the wallet"},
2495 " of the oldest pre-generated key in the key pool. "
2496 "Legacy wallets only."},
2498 "how many new keys are pre-generated (only counts external "
2501 "how many new keys are pre-generated for internal use (used "
2502 "for change outputs, only appears if the wallet is using "
2503 "this feature, otherwise external keys are used)"},
2507 " until which the wallet is unlocked for transfers, or 0 "
2508 "if the wallet is locked (only present for "
2509 "passphrase-encrypted wallets)"},
2511 "the transaction fee configuration, set in " +
2514 "the Hash160 of the HD seed (only present when HD is "
2517 "false if privatekeys are disabled for this wallet (enforced "
2518 "watch-only wallet)"},
2521 "current scanning details, or false if no scan is in "
2525 "elapsed seconds since scan start"},
2527 "scanning progress percentage [0.0, 1.0]"},
2531 "whether this wallet tracks clean/dirty coins in terms of "
2534 "whether this wallet uses descriptors for scriptPubKey "
2542 std::shared_ptr<CWallet>
const wallet =
2552 pwallet->BlockUntilSyncedToCurrentChain();
2563 obj.
pushKV(
"balance", bal.m_mine_trusted);
2564 obj.
pushKV(
"unconfirmed_balance", bal.m_mine_untrusted_pending);
2565 obj.
pushKV(
"immature_balance", bal.m_mine_immature);
2566 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2567 if (kp_oldest > 0) {
2568 obj.
pushKV(
"keypoololdest", kp_oldest);
2570 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2582 obj.
pushKV(
"keypoolsize_hd_internal",
2586 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2590 "private_keys_enabled",
2596 obj.
pushKV(
"scanning", scanning);
2598 obj.
pushKV(
"scanning",
false);
2600 obj.
pushKV(
"avoid_reuse",
2602 obj.
pushKV(
"descriptors",
2612 "Returns a list of wallets in the wallet directory.\n",
2638 wallet.pushKV(
"name", path.u8string());
2643 result.
pushKV(
"wallets", wallets);
2652 "Returns a list of currently loaded wallets.\n"
2653 "For full information on the wallet, use \"getwalletinfo\"\n",
2680 "Loads a wallet from a wallet file or directory."
2681 "\nNote that all wallet command-line options used when starting "
2683 "\napplied to the new wallet (eg -rescan, etc).\n",
2686 "The wallet directory or .dat file."},
2689 "Save wallet name to persistent settings and load on startup. "
2690 "True to add wallet to startup list, false to remove, null to "
2691 "leave unchanged."},
2698 "The wallet name if loaded successfully."},
2700 "Warning message if wallet was not loaded cleanly."},
2707 const std::string
name(request.params[0].get_str());
2709 auto [
wallet, warnings] =
2722 std::string
flags =
"";
2725 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2730 "Change the state of the given wallet flag for a wallet.\n",
2733 "The name of the flag to change. Current available flags: " +
2743 "The name of the flag that was modified"},
2745 "The new state of the flag"},
2747 "Any warnings associated with the change"},
2753 std::shared_ptr<CWallet>
const wallet =
2760 std::string flag_str = request.params[0].get_str();
2762 request.params[1].isNull() || request.params[1].get_bool();
2767 strprintf(
"Unknown wallet flag: %s", flag_str));
2775 strprintf(
"Wallet flag is immutable: %s", flag_str));
2783 strprintf(
"Wallet flag is already set to %s: %s",
2784 value ?
"true" :
"false", flag_str));
2787 res.
pushKV(
"flag_name", flag_str);
2788 res.
pushKV(
"flag_state", value);
2791 pwallet->SetWalletFlag(flag);
2808 "Creates and loads a new wallet.\n",
2811 "The name for the new wallet. If this is a path, the wallet will "
2812 "be created at the path location."},
2814 "Disable the possibility of private keys (only watchonlys are "
2815 "possible in this mode)."},
2817 "Create a blank wallet. A blank wallet has no keys or HD seed. "
2818 "One can be set using sethdseed."},
2820 "Encrypt the wallet with this passphrase."},
2822 "Keep track of coin reuse, and treat dirty and clean coins "
2823 "differently with privacy considerations in mind."},
2825 "Create a native descriptor wallet. The wallet will use "
2826 "descriptors internally to handle address creation"},
2829 "Save wallet name to persistent settings and load on startup. "
2830 "True to add wallet to startup list, false to remove, null to "
2831 "leave unchanged."},
2838 "The wallet name if created successfully. If the wallet "
2839 "was created using a full path, the wallet_name will be "
2842 "Warning message if wallet was not loaded cleanly."},
2848 {
"avoid_reuse",
true},
2849 {
"descriptors",
true},
2850 {
"load_on_startup",
true}}) +
2852 {
"avoid_reuse",
true},
2853 {
"descriptors",
true},
2854 {
"load_on_startup",
true}})},
2859 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2863 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2868 passphrase.reserve(100);
2869 std::vector<bilingual_str> warnings;
2870 if (!request.params[3].isNull()) {
2871 passphrase = request.params[3].get_str().c_str();
2872 if (passphrase.empty()) {
2875 "Empty string given as passphrase, wallet will "
2876 "not be encrypted."));
2880 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2883 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2886 "Wallet is an experimental descriptor wallet"));
2895 std::optional<bool> load_on_start =
2896 request.params[6].isNull()
2898 : std::make_optional<bool>(request.params[6].get_bool());
2899 std::shared_ptr<CWallet>
wallet =
2901 load_on_start, options, status,
error, warnings);
2921 "Unloads the wallet referenced by the request endpoint otherwise "
2922 "unloads the wallet specified in the argument.\n"
2923 "Specifying the wallet name on a wallet endpoint is invalid.",
2927 "The name of the wallet to unload."},
2930 "Save wallet name to persistent settings and load on startup. "
2931 "True to add wallet to startup list, false to remove, null to "
2932 "leave unchanged."},
2939 "Warning message if wallet was not unloaded cleanly."},
2945 std::string wallet_name;
2947 if (!request.params[0].isNull()) {
2949 "Cannot unload the requested wallet");
2952 wallet_name = request.params[0].get_str();
2959 "Requested wallet does not exist or is not loaded");
2965 std::vector<bilingual_str> warnings;
2966 std::optional<bool> load_on_start =
2967 request.params[1].isNull()
2969 : std::make_optional<bool>(request.params[1].get_bool());
2972 "Requested wallet already unloaded");
2989 "Returns array of unspent transaction outputs\n"
2990 "with between minconf and maxconf (inclusive) confirmations.\n"
2991 "Optionally filter to only include txouts paid to specified "
2995 "The minimum confirmations to filter"},
2997 "The maximum confirmations to filter"},
3002 "The bitcoin addresses to filter",
3009 "Include outputs that are not safe to spend\n"
3010 " See description of \"safe\" attribute below."},
3014 "JSON with query options",
3018 "Minimum value of each UTXO in " + ticker +
""},
3021 "Maximum value of each UTXO in " + ticker +
""},
3026 "Minimum sum value of all UTXOs in " + ticker +
""},
3043 "The associated label, or \"\" for the default label"},
3046 "the transaction output amount in " + ticker},
3048 "The number of confirmations"},
3051 "DEPRECATED: The number of in-mempool ancestor "
3052 "transactions, including this one (if transaction is in "
3053 "the mempool). Only displayed if the "
3054 "-deprecatedrpc=mempool_ancestors_descendants option is "
3057 "DEPRECATED: The virtual transaction size of in-mempool "
3058 " ancestors, including this one (if transaction is in "
3059 "the mempool). Only displayed if the "
3060 "-deprecatedrpc=mempool_ancestors_descendants option is "
3064 "DEPRECATED: The total fees of in-mempool ancestors "
3065 "(including this one) with fee deltas used for mining "
3068 " (if transaction is in the mempool). Only "
3070 "-deprecatedrpc=mempool_ancestors_descendants option "
3074 "The redeemScript if scriptPubKey is P2SH"},
3076 "Whether we have the private keys to spend this output"},
3078 "Whether we know how to spend this output, ignoring the "
3081 "(only present if avoid_reuse is set) Whether this "
3082 "output is reused/dirty (sent to an address that was "
3083 "previously spent from)"},
3085 "(only when solvable) A descriptor for spending this "
3088 "Whether this output is considered safe to spend. "
3089 "Unconfirmed transactions\n"
3090 "from outside keys are considered unsafe\n"
3091 "and are not eligible for spending by fundrawtransaction "
3092 "and sendtoaddress."},
3099 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3100 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3103 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3104 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3107 "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") +
3110 "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")},
3113 std::shared_ptr<CWallet>
const wallet =
3121 if (!request.params[0].isNull()) {
3123 nMinDepth = request.params[0].get_int();
3126 int nMaxDepth = 9999999;
3127 if (!request.params[1].isNull()) {
3129 nMaxDepth = request.params[1].get_int();
3132 std::set<CTxDestination> destinations;
3133 if (!request.params[2].isNull()) {
3136 for (
size_t idx = 0; idx < inputs.
size(); idx++) {
3137 const UniValue &input = inputs[idx];
3143 std::string(
"Invalid Bitcoin address: ") +
3146 if (!destinations.insert(dest).second) {
3150 "Invalid parameter, duplicated address: ") +
3156 bool include_unsafe =
true;
3157 if (!request.params[3].isNull()) {
3159 include_unsafe = request.params[3].get_bool();
3165 uint64_t nMaximumCount = 0;
3167 if (!request.params[4].isNull()) {
3180 if (options.
exists(
"minimumAmount")) {
3184 if (options.
exists(
"maximumAmount")) {
3188 if (options.
exists(
"minimumSumAmount")) {
3193 if (options.
exists(
"maximumCount")) {
3194 nMaximumCount = options[
"maximumCount"].
get_int64();
3201 pwallet->BlockUntilSyncedToCurrentChain();
3204 std::vector<COutput> vecOutputs;
3213 nMaximumAmount, nMinimumSumAmount,
3219 const bool avoid_reuse =
3222 for (
const COutput &out : vecOutputs) {
3225 out.tx->tx->vout[out.i].scriptPubKey;
3228 avoid_reuse && pwallet->
IsSpentKey(out.tx->GetId(), out.i);
3230 if (destinations.size() &&
3231 (!fValidAddress || !destinations.count(address))) {
3236 entry.
pushKV(
"txid", out.tx->GetId().GetHex());
3237 entry.
pushKV(
"vout", out.i);
3239 if (fValidAddress) {
3242 const auto *address_book_entry =
3244 if (address_book_entry) {
3245 entry.
pushKV(
"label", address_book_entry->GetLabel());
3248 std::unique_ptr<SigningProvider> provider =
3253 CScriptID(std::get<ScriptHash>(address));
3255 if (provider->GetCScript(hash, redeemScript)) {
3256 entry.
pushKV(
"redeemScript",
3264 entry.
pushKV(
"amount", out.tx->tx->vout[out.i].nValue);
3265 entry.
pushKV(
"confirmations", out.nDepth);
3266 entry.
pushKV(
"spendable", out.fSpendable);
3267 entry.
pushKV(
"solvable", out.fSolvable);
3268 if (out.fSolvable) {
3269 std::unique_ptr<SigningProvider> provider =
3274 entry.
pushKV(
"desc", descriptor->ToString());
3278 entry.
pushKV(
"reused", reused);
3280 entry.
pushKV(
"safe", out.fSafe);
3290 Amount &fee_out,
int &change_position,
3294 pwallet->BlockUntilSyncedToCurrentChain();
3296 change_position = -1;
3297 bool lockUnspents =
false;
3299 std::set<int> setSubtractFeeFromOutputs;
3332 if (options.
exists(
"add_inputs")) {
3336 if (options.
exists(
"changeAddress") ||
3337 options.
exists(
"change_address")) {
3338 const std::string change_address_str =
3339 (options.
exists(
"change_address")
3340 ? options[
"change_address"]
3341 : options[
"changeAddress"])
3349 "Change address must be a valid bitcoin address");
3355 if (options.
exists(
"changePosition") ||
3356 options.
exists(
"change_position")) {
3357 change_position = (options.
exists(
"change_position")
3358 ? options[
"change_position"]
3359 : options[
"changePosition"])
3363 const UniValue include_watching_option =
3364 options.
exists(
"include_watching") ? options[
"include_watching"]
3365 : options[
"includeWatching"];
3369 if (options.
exists(
"lockUnspents") ||
3370 options.
exists(
"lock_unspents")) {
3372 (options.
exists(
"lock_unspents") ? options[
"lock_unspents"]
3373 : options[
"lockUnspents"])
3377 if (options.
exists(
"include_unsafe")) {
3379 options[
"include_unsafe"].
get_bool();
3382 if (options.
exists(
"feeRate") || options.
exists(
"fee_rate")) {
3384 options.
exists(
"fee_rate") ? options[
"fee_rate"]
3385 : options[
"feeRate"]));
3389 if (options.
exists(
"subtractFeeFromOutputs") ||
3390 options.
exists(
"subtract_fee_from_outputs")) {
3391 subtractFeeFromOutputs =
3392 (options.
exists(
"subtract_fee_from_outputs")
3393 ? options[
"subtract_fee_from_outputs"]
3394 : options[
"subtractFeeFromOutputs"])
3404 if (tx.
vout.size() == 0) {
3406 "TX must have at least one output");
3409 if (change_position != -1 &&
3410 (change_position < 0 ||
3411 (
unsigned int)change_position > tx.
vout.size())) {
3413 "changePosition out of bounds");
3416 for (
size_t idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3417 int pos = subtractFeeFromOutputs[idx].
get_int();
3418 if (setSubtractFeeFromOutputs.count(pos)) {
3421 strprintf(
"Invalid parameter, duplicated position: %d", pos));
3426 strprintf(
"Invalid parameter, negative position: %d", pos));
3428 if (pos >=
int(tx.
vout.size())) {
3431 strprintf(
"Invalid parameter, position too large: %d", pos));
3433 setSubtractFeeFromOutputs.insert(pos);
3439 lockUnspents, setSubtractFeeFromOutputs,
3448 "fundrawtransaction",
3449 "If the transaction has no inputs, they will be automatically selected "
3450 "to meet its out value.\n"
3451 "It will add at most one change output to the outputs.\n"
3452 "No existing outputs will be modified unless "
3453 "\"subtractFeeFromOutputs\" is specified.\n"
3454 "Note that inputs which were signed may need to be resigned after "
3455 "completion since in/outputs have been added.\n"
3456 "The inputs added will not be signed, use signrawtransactionwithkey or "
3457 "signrawtransactionwithwallet for that.\n"
3458 "Note that all existing inputs must have their previous output "
3459 "transaction be in the wallet.\n"
3460 "Note that all inputs selected must be of standard form and P2SH "
3462 "in the wallet using importaddress or addmultisigaddress (to calculate "
3464 "You can see whether this is the case by checking the \"solvable\" "
3465 "field in the listunspent output.\n"
3466 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently "
3467 "supported for watch-only\n",
3470 "The hex string of the raw transaction"},
3474 "for backward compatibility: passing in a true instead of an "
3475 "object will result in {\"includeWatching\":true}",
3478 "For a transaction with existing inputs, automatically "
3479 "include more if they are not enough."},
3481 "Include inputs that are not safe to spend (unconfirmed "
3482 "transactions from outside keys).\n"
3483 "Warning: the resulting transaction may become invalid if "
3484 "one of the unsafe inputs disappears.\n"
3485 "If that happens, you will need to fund the transaction with "
3486 "different inputs and republish it."},
3489 "The bitcoin address to receive the change"},
3492 "The index of the change output"},
3495 "true for watch-only wallets, otherwise false"},
3496 "Also select inputs which are watch only.\n"
3497 "Only solvable inputs can be used. Watch-only destinations "
3498 "are solvable if the public key and/or output script was "
3500 "e.g. with 'importpubkey' or 'importmulti' with the "
3501 "'pubkeys' or 'desc' field."},
3503 "Lock selected unspent outputs"},
3506 "not set: makes wallet determine the fee"},
3507 "Set a specific fee rate in " + ticker +
"/kB"},
3509 "subtractFeeFromOutputs",
3513 " The fee will be equally "
3514 "deducted from the amount of each specified output.\n"
3515 " Those recipients will "
3516 "receive less bitcoins than you enter in their "
3517 "corresponding amount field.\n"
3518 " If no outputs are "
3519 "specified here, the sender pays the fee.",
3523 "The zero-based output index, before a change output "
3529 .oneline_description =
"options"}},
3536 "The resulting raw transaction (hex-encoded string)"},
3538 "Fee in " + ticker +
" the resulting transaction pays"},
3540 "The position of the added change output, or -1"},
3543 "\nCreate a transaction with no inputs\n" +
3545 "\"[]\" \"{\\\"myaddress\\\":10000}\"") +
3546 "\nAdd sufficient unsigned inputs to meet the output value\n" +
3548 "\nSign the transaction\n" +
3550 "\"fundedtransactionhex\"") +
3551 "\nSend the transaction\n" +
3552 HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")},
3555 std::shared_ptr<CWallet>
const wallet =
3564 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
3566 "TX decode failed");
3570 int change_position;
3576 request.params[1], coin_control);
3580 result.
pushKV(
"fee", fee);
3581 result.
pushKV(
"changepos", change_position);
3590 "signrawtransactionwithwallet",
3591 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
3592 "The second optional argument (may be null) is an array of previous "
3593 "transaction outputs that\n"
3594 "this transaction depends on but may not yet be in the block chain.\n" +
3598 "The transaction hex string"},
3603 "The previous dependent transaction outputs",
3614 "The output number"},
3626 "The signature hash type. Must be one of\n"
3628 " \"NONE|FORKID\"\n"
3629 " \"SINGLE|FORKID\"\n"
3630 " \"ALL|FORKID|ANYONECANPAY\"\n"
3631 " \"NONE|FORKID|ANYONECANPAY\"\n"
3632 " \"SINGLE|FORKID|ANYONECANPAY\""},
3640 "The hex-encoded raw transaction with signature(s)"},
3642 "If the transaction has a complete set of signatures"},
3646 "Script verification errors (if there are any)",
3653 "The hash of the referenced, previous transaction"},
3655 "The index of the output to spent and used as "
3658 "The hex-encoded signature script"},
3660 "Script sequence number"},
3662 "Verification or signing error related to the "
3672 std::shared_ptr<CWallet>
const wallet =
3680 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3682 "TX decode failed");
3690 std::map<COutPoint, Coin> coins;
3691 for (
const CTxIn &txin : mtx.
vin) {
3703 "Signature must use SIGHASH_FORKID");
3707 std::map<int, std::string> input_errors;
3722 "Rescan the local blockchain for wallet related transactions.\n"
3723 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3726 "block height where the rescan should start"},
3729 "the last block height that should be scanned"},
3737 "The block height where the rescan started (the requested "
3740 "The height of the last rescanned block. May be null in rare "
3741 "cases if there was a reorg and the call didn't scan any "
3742 "blocks because they were already scanned in the background."},
3748 std::shared_ptr<CWallet>
const wallet =
3758 "Wallet is currently rescanning. Abort "
3759 "existing rescan or wait.");
3762 int start_height = 0;
3763 std::optional<int> stop_height;
3769 if (!request.params[0].isNull()) {
3770 start_height = request.params[0].get_int();
3771 if (start_height < 0 || start_height > tip_height) {
3773 "Invalid start_height");
3777 if (!request.params[1].isNull()) {
3778 stop_height = request.params[1].get_int();
3779 if (*stop_height < 0 || *stop_height > tip_height) {
3781 "Invalid stop_height");
3782 }
else if (*stop_height < start_height) {
3785 "stop_height must be greater than start_height");
3792 start_height, stop_height)) {
3795 "Can't rescan beyond pruned data. Use RPC call "
3796 "getblockchaininfo to determine your pruned height.");
3805 start_block, start_height, stop_height, reserver,
3813 "Rescan failed. Potentially corrupted data files.");
3820 response.pushKV(
"start_height", start_height);
3835 std::vector<std::vector<uint8_t>> solutions_data;
3846 UniValue wallet_detail = std::visit(*
this, embedded);
3847 subobj.
pushKVs(wallet_detail);
3852 if (subobj.
exists(
"pubkey")) {
3853 obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3855 obj.
pushKV(
"embedded", std::move(subobj));
3861 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3863 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3864 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3867 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3905 std::unique_ptr<SigningProvider> provider =
nullptr;
3916 const bool verbose) {
3928 "Return information about the given bitcoin address.\n"
3929 "Some of the information will only be present if the address is in the "
3933 "The bitcoin address for which to get information."},
3941 "The bitcoin address validated."},
3943 "The hex-encoded scriptPubKey generated by the address."},
3946 "If the address is watchonly."},
3948 "If we know how to spend coins sent to this address, ignoring "
3949 "the possible lack of private keys."},
3951 "A descriptor for spending coins sent to this address (only "
3955 "If the address was used for change output."},
3957 "The output script type. Only if isscript is true and the "
3958 "redeemscript is known. Possible\n"
3960 "types: nonstandard, pubkey, pubkeyhash, scripthash, "
3961 "multisig, nulldata."},
3963 "The redeemscript for the p2sh address."},
3967 "Array of pubkeys associated with the known redeemscript "
3968 "(only if script is multisig).",
3973 "The number of signatures required to spend multisig output "
3974 "(only if script is multisig)."},
3976 "The hex value of the raw public key for single-key addresses "
3977 "(possibly embedded in P2SH)."},
3981 "Information about the address embedded in P2SH, if "
3982 "relevant and known.",
3985 "Includes all getaddressinfo output fields for the "
3986 "embedded address excluding metadata (timestamp, "
3987 "hdkeypath, hdseedid)\n"
3988 "and relation to the wallet (ismine, iswatchonly)."},
3991 "If the pubkey is compressed."},
3993 "The creation time of the key, if available, expressed in " +
3996 "The HD keypath, if the key is HD and available."},
3998 "The Hash160 of the HD seed."},
4000 true,
"The fingerprint of the master key."},
4003 "Array of labels associated with the address. Currently "
4004 "limited to one label but returned\n"
4005 "as an array to keep the API stable if multiple labels are "
4006 "enabled in the future.",
4009 "Label name (defaults to \"\")."},
4016 std::shared_ptr<CWallet>
const wallet =
4027 wallet->GetChainParams());
4035 ret.
pushKV(
"address", currentAddress);
4040 std::unique_ptr<SigningProvider> provider =
4046 bool solvable = provider &&
IsSolvable(*provider, scriptPubKey);
4047 ret.
pushKV(
"solvable", solvable);
4065 if (
const std::unique_ptr<CKeyMetadata> meta =
4067 ret.
pushKV(
"timestamp", meta->nCreateTime);
4068 if (meta->has_key_origin) {
4071 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
4072 ret.
pushKV(
"hdmasterfingerprint",
4073 HexStr(meta->key_origin.fingerprint));
4084 const auto *address_book_entry =
4086 if (address_book_entry) {
4087 labels.
push_back(address_book_entry->GetLabel());
4089 ret.
pushKV(
"labels", std::move(labels));
4098 "getaddressesbylabel",
4099 "Returns the list of addresses assigned the specified label.\n",
4105 "json object with addresses as keys",
4109 "Information about address",
4112 "Purpose of address (\"send\" for sending address, "
4113 "\"receive\" for receiving address)"},
4120 std::shared_ptr<CWallet>
const wallet =
4133 std::set<std::string> addresses;
4134 for (
const std::pair<const CTxDestination, CAddressBookData> &item :
4135 pwallet->m_address_book) {
4136 if (item.second.IsChange()) {
4139 if (item.second.GetLabel() == label) {
4157 std::string(
"No addresses with label " + label));
4168 "Returns the list of all labels, or labels that are assigned to "
4169 "addresses with a specific purpose.\n",
4172 "Address purpose to list labels for ('send','receive'). An empty "
4173 "string is the same as not providing this argument."},
4182 "\nList labels that have receiving addresses\n" +
4184 "\nList labels that have sending addresses\n" +
4186 "\nAs a JSON-RPC call\n" +
4190 std::shared_ptr<CWallet>
const wallet =
4199 std::string purpose;
4200 if (!request.params[0].isNull()) {
4201 purpose = request.params[0].get_str();
4206 std::set<std::string> label_set;
4207 for (
const std::pair<const CTxDestination, CAddressBookData>
4208 &entry : pwallet->m_address_book) {
4209 if (entry.second.IsChange()) {
4212 if (purpose.empty() || entry.second.purpose == purpose) {
4213 label_set.insert(entry.second.GetLabel());
4218 for (
const std::string &
name : label_set) {
4230 "EXPERIMENTAL warning: this call may be changed in future releases.\n"
4231 "\nSend a transaction.\n",
4236 "A JSON array with outputs (key-value pairs), where none of "
4237 "the keys are duplicated.\n"
4238 "That is, each address can only appear once and there can only "
4239 "be one 'data' object.\n"
4240 "For convenience, a dictionary, which holds the key-value "
4241 "pairs directly, is also accepted.",
4250 "A key-value pair. The key (string) is the "
4251 "bitcoin address, the value (float or string) is "
4263 "A key-value pair. The key must be \"data\", the "
4264 "value is hex-encoded data"},
4275 "If inputs are specified, automatically include more if they "
4278 "Include inputs that are not safe to spend (unconfirmed "
4279 "transactions from outside keys).\n"
4280 "Warning: the resulting transaction may become invalid if "
4281 "one of the unsafe inputs disappears.\n"
4282 "If that happens, you will need to fund the transaction with "
4283 "different inputs and republish it."},
4285 "When false, returns a serialized transaction which will not "
4286 "be added to the wallet or broadcast"},
4289 "The bitcoin address to receive the change"},
4292 "The index of the change output"},
4295 "not set: makes wallet determine the fee"},
4300 "true for watch-only wallets, otherwise false"},
4301 "Also select inputs which are watch only.\n"
4302 "Only solvable inputs can be used. Watch-only destinations "
4303 "are solvable if the public key and/or output script was "
4305 "e.g. with 'importpubkey' or 'importmulti' with the "
4306 "'pubkeys' or 'desc' field."},
4311 "Specify inputs instead of adding them automatically. A "
4312 "JSON array of JSON objects",
4315 "The transaction id"},
4317 "The output number"},
4319 "The sequence number"},
4323 "Raw locktime. Non-0 value also locktime-activates inputs"},
4325 "Lock selected unspent outputs"},
4327 "Always return a PSBT, implies add_to_wallet=false."},
4329 "subtract_fee_from_outputs",
4332 "Outputs to subtract the fee from, specified as integer "
4334 "The fee will be equally deducted from the amount of each "
4335 "specified output.\n"
4336 "Those recipients will receive less bitcoins than you "
4337 "enter in their corresponding amount field.\n"
4338 "If no outputs are specified here, the sender pays the "
4343 "The zero-based output index, before a change output "
4355 "If the transaction has a complete set of signatures"},
4357 "The transaction id for the send. Only 1 transaction is created "
4358 "regardless of the number of addresses."},
4360 "If add_to_wallet is false, the hex-encoded raw transaction with "
4363 "If more signatures are needed, or if add_to_wallet is false, "
4364 "the base64-encoded (partially) signed transaction"}}},
4367 "\nSend with a fee rate of 10 XEC/kB\n" +
4369 "\": 100000}' '{\"fee_rate\": 10}'\n") +
4370 "\nCreate a transaction with a specific input, and return "
4371 "result without adding to wallet or broadcasting to the "
4375 "\": 100000}' '{\"add_to_wallet\": "
4376 "false, \"inputs\": "
4378 "\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b565"
4379 "5e72f463568df1aadf0\", \"vout\":1}]}'")},
4382 std::shared_ptr<CWallet>
const wallet =
4389 UniValue options = request.params[1];
4390 if (options.
exists(
"changeAddress")) {
4393 if (options.
exists(
"changePosition")) {
4395 "Use change_position");
4397 if (options.
exists(
"includeWatching")) {
4399 "Use include_watching");
4401 if (options.
exists(
"lockUnspents")) {
4404 if (options.
exists(
"subtractFeeFromOutputs")) {
4406 "Use subtract_fee_from_outputs");
4408 if (options.
exists(
"feeRate")) {
4412 const bool psbt_opt_in =
4416 int change_position;
4418 wallet->GetChainParams(), options[
"inputs"], request.params[0],
4419 options[
"locktime"]);
4427 bool add_to_wallet =
true;
4428 if (options.
exists(
"add_to_wallet")) {
4429 add_to_wallet = options[
"add_to_wallet"].
get_bool();
4436 bool complete =
true;
4438 psbtx, complete,
SigHashType().withForkId(),
true,
false);
4448 if (psbt_opt_in || !complete || !add_to_wallet) {
4456 std::string err_string;
4459 result.
pushKV(
"txid", tx->GetHash().GetHex());
4460 if (add_to_wallet && !psbt_opt_in) {
4463 result.
pushKV(
"hex", hex);
4466 result.
pushKV(
"complete", complete);
4475 "Set or generate a new HD wallet seed. Non-HD wallets will not be "
4476 "upgraded to being a HD wallet. Wallets that are already\n"
4477 "HD will have a new HD seed set so that new keys added to the keypool "
4478 "will be derived from this new seed.\n"
4479 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after "
4480 "setting the HD wallet seed.\n" +
4484 "Whether to flush old unused addresses, including change "
4485 "addresses, from the keypool and regenerate it.\n"
4486 " If true, the next address from "
4487 "getnewaddress and change address from getrawchangeaddress will "
4488 "be from this new seed.\n"
4489 " If false, addresses (including "
4490 "change addresses if the wallet already had HD Chain Split "
4491 "enabled) from the existing\n"
4492 " keypool will be used until it has "
4495 "The WIF private key to use as the new HD seed.\n"
4496 " The seed value can be retrieved "
4497 "using the dumpwallet command. It is the private key marked "
4507 std::shared_ptr<CWallet>
const wallet =
4519 "Cannot set a HD seed to a wallet with "
4520 "private keys disabled");
4529 "Cannot set a HD seed on a non-HD wallet. Use the "
4530 "upgradewallet RPC in order to upgrade a non-HD wallet "
4536 bool flush_key_pool =
true;
4537 if (!request.params[0].isNull()) {
4538 flush_key_pool = request.params[0].get_bool();
4542 if (request.params[1].isNull()) {
4548 "Invalid private key");
4554 "Already have this key (either as an HD seed or "
4555 "as a loose private key)");
4562 if (flush_key_pool) {
4573 "walletprocesspsbt",
4574 "Update a PSBT with input information from our wallet and then sign "
4575 "inputs that we can sign for." +
4579 "The transaction base64 string"},
4581 "Also sign the transaction when updating"},
4583 "The signature hash type to sign with if not specified by "
4584 "the PSBT. Must be one of\n"
4586 " \"NONE|FORKID\"\n"
4587 " \"SINGLE|FORKID\"\n"
4588 " \"ALL|FORKID|ANYONECANPAY\"\n"
4589 " \"NONE|FORKID|ANYONECANPAY\"\n"
4590 " \"SINGLE|FORKID|ANYONECANPAY\""},
4592 "Includes the BIP 32 derivation paths for public keys if we know "
4600 "The base64-encoded partially signed transaction"},
4602 "If the transaction has a complete set of signatures"},
4607 std::shared_ptr<CWallet>
const wallet =
4626 "Signature must use SIGHASH_FORKID");
4630 bool sign = request.params[1].isNull()
4632 : request.params[1].get_bool();
4633 bool bip32derivs = request.params[3].isNull()
4635 : request.params[3].get_bool();
4636 bool complete =
true;
4638 psbtx, complete, nHashType, sign, bip32derivs);
4647 result.
pushKV(
"complete", complete);
4657 "walletcreatefundedpsbt",
4658 "Creates and funds a transaction in the Partially Signed Transaction "
4660 "Implements the Creator and Updater roles.\n",
4666 "Leave empty to add inputs automatically. See add_inputs "
4678 "The output number"},
4681 "depends on the value of the 'locktime' and "
4682 "'options.replaceable' arguments"},
4683 "The sequence number"},
4691 "The outputs (key-value pairs), where none of "
4692 "the keys are duplicated.\n"
4693 "That is, each address can only appear once and there can only "
4694 "be one 'data' object.\n"
4695 "For compatibility reasons, a dictionary, which holds the "
4696 "key-value pairs directly, is also\n"
4697 " accepted as second parameter.",
4706 "A key-value pair. The key (string) is the "
4707 "bitcoin address, the value (float or string) is "
4719 "A key-value pair. The key must be \"data\", the "
4720 "value is hex-encoded data"},
4726 "Raw locktime. Non-0 value also locktime-activates inputs\n"
4727 " Allows this transaction to be "
4728 "replaced by a transaction with higher fees. If provided, it is "
4729 "an error if explicit sequence numbers are incompatible."},
4736 "If inputs are specified, automatically include more if they "
4739 "Include inputs that are not safe to spend (unconfirmed "
4740 "transactions from outside keys).\n"
4741 "Warning: the resulting transaction may become invalid if "
4742 "one of the unsafe inputs disappears.\n"
4743 "If that happens, you will need to fund the transaction with "
4744 "different inputs and republish it."},
4747 "The bitcoin address to receive the change"},
4750 "The index of the change output"},
4753 "true for watch-only wallets, otherwise false"},
4754 "Also select inputs which are watch only"},
4756 "Lock selected unspent outputs"},
4759 "not set: makes wallet determine the fee"},
4760 "Set a specific fee rate in " + ticker +
"/kB"},
4762 "subtractFeeFromOutputs",
4765 "The outputs to subtract the fee from.\n"
4766 " The fee will be equally "
4767 "deducted from the amount of each specified output.\n"
4768 " Those recipients will "
4769 "receive less bitcoins than you enter in their "
4770 "corresponding amount field.\n"
4771 " If no outputs are "
4772 "specified here, the sender pays the fee.",
4776 "The zero-based output index, before a change output "
4783 "Includes the BIP 32 derivation paths for public keys if we know "
4791 "The resulting raw transaction (base64-encoded string)"},
4793 "Fee in " + ticker +
" the resulting transaction pays"},
4795 "The position of the added change output, or -1"},
4798 "\nCreate a transaction with no inputs\n" +
4800 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" "
4801 "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
4804 std::shared_ptr<CWallet>
const wallet =
4812 int change_position;
4814 wallet->GetChainParams(), request.params[0], request.params[1],
4821 request.params[3], coin_control);
4827 bool bip32derivs = request.params[4].isNull()
4829 : request.params[4].get_bool();
4830 bool complete =
true;
4833 false, bip32derivs);
4844 result.
pushKV(
"fee", fee);
4845 result.
pushKV(
"changepos", change_position);
4854 "Upgrade the wallet. Upgrades to the latest version if no "
4855 "version number is specified\n"
4856 "New keys may be generated and a new wallet backup will need to "
4859 "The version number to upgrade to. Default is the latest "
4866 std::shared_ptr<CWallet>
const wallet =
4876 if (!request.params[0].isNull()) {
4877 version = request.params[0].get_int();
4883 return error.original;
4892 "createwallettransaction",
4893 "Create a transaction sending an amount to a given address.\n" +
4897 "The bitcoin address to send to."},
4904 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
4906 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 100000")},
4909 std::shared_ptr<CWallet>
const wallet =
4919 pwallet->BlockUntilSyncedToCurrentChain();
4926 const std::string address = request.params[0].get_str();
4927 address_amounts.
pushKV(address, request.params[1]);
4930 std::vector<CRecipient> recipients;
4932 wallet->GetChainParams());
4935 return SendMoney(pwallet, coin_control, recipients, {},
false);
4974 {
"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.
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
int64_t get_int64() const
const UniValue & get_obj() const
void __pushKV(const std::string &key, const UniValue &val)
const std::vector< UniValue > & getValues() const
const std::vector< std::string > & getKeys() const
bool pushKVs(const UniValue &obj)
bool push_back(const UniValue &val)
const UniValue & get_array() const
bool exists(const std::string &key) const
bool pushKV(const std::string &key, const UniValue &val)
RAII object to check and reserve a wallet rescan.
std::string GetHex() const
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual int rpcSerializationFlags()=0
Current RPC serialization flags.
virtual bool findBlock(const BlockHash &hash, const FoundBlock &block={})=0
Return 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)
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
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 void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx, int nMinDepth, bool fLong, UniValue &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 getrawchangeaddress()
static RPCHelpMan walletprocesspsbt()
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)
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
std::string oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
@ 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,...