6#include <chainparams.h>
45#include <event2/http.h>
67 int confirms =
wallet.GetTxDepthInMainChain(wtx);
68 entry.pushKV(
"confirmations", confirms);
69 if (wtx.IsCoinBase()) {
70 entry.pushKV(
"generated",
true);
73 entry.pushKV(
"blockhash", wtx.m_confirm.hashBlock.GetHex());
74 entry.pushKV(
"blockheight", wtx.m_confirm.block_height);
75 entry.pushKV(
"blockindex", wtx.m_confirm.nIndex);
79 entry.pushKV(
"blocktime", block_time);
84 entry.pushKV(
"txid", hash.
GetHex());
89 entry.pushKV(
"walletconflicts", std::move(conflicts));
90 entry.pushKV(
"time", wtx.GetTxTime());
91 entry.pushKV(
"timereceived", int64_t{wtx.nTimeReceived});
93 for (
const std::pair<const std::string, std::string> &item : wtx.mapValue) {
94 entry.pushKV(item.first, item.second);
101 "Returns a new eCash address for receiving payments.\n"
102 "If 'label' is specified, it is added to the address book \n"
103 "so payments received with the address will be associated with "
107 "The label name for the address to be linked to. If not provided, "
108 "the default label \"\" is used. It can also be set to the empty "
109 "string \"\" to represent the default label. The label does not "
110 "need to exist, it will be created if there is no label by the "
118 std::shared_ptr<CWallet>
const wallet =
128 "Error: This wallet has no available keys");
134 if (!request.params[0].isNull()) {
152 "getrawchangeaddress",
153 "Returns a new Bitcoin address, for receiving change.\n"
154 "This is for use with raw transactions, NOT normal use.\n",
161 std::shared_ptr<CWallet>
const wallet =
172 "Error: This wallet has no available keys");
177 if (!request.params[0].isNull()) {
182 request.params[0].get_str()));
199 "Sets the label associated with the given address.\n",
202 "The bitcoin address to be associated with a label."},
204 "The label to assign to the address."},
209 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") +
212 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")},
215 std::shared_ptr<CWallet>
const wallet =
225 wallet->GetChainParams());
228 "Invalid Bitcoin address");
233 if (pwallet->
IsMine(dest)) {
245 const UniValue &subtract_fee_outputs,
246 std::vector<CRecipient> &recipients,
248 std::set<CTxDestination> destinations;
250 for (
const std::string &address : address_amounts.
getKeys()) {
254 std::string(
"Invalid Bitcoin address: ") +
258 if (destinations.count(dest)) {
261 std::string(
"Invalid parameter, duplicated address: ") +
264 destinations.insert(dest);
269 bool subtract_fee =
false;
270 for (
unsigned int idx = 0; idx < subtract_fee_outputs.
size(); idx++) {
271 const UniValue &addr = subtract_fee_outputs[idx];
272 if (addr.
get_str() == address) {
277 CRecipient recipient = {script_pub_key, amount, subtract_fee};
278 recipients.push_back(recipient);
283 std::vector<CRecipient> &recipients,
mapValue_t map_value,
284 bool broadcast =
true) {
291 constexpr int RANDOM_CHANGE_POSITION = -1;
293 *pwallet, recipients, RANDOM_CHANGE_POSITION, coin_control,
302 return tx->GetId().GetHex();
311 "The bitcoin address to send to."},
315 "A comment used to store what the transaction is for.\n"
316 " This is not part of the "
317 "transaction, just kept in your wallet."},
319 "A comment to store the name of the person or organization\n"
320 " to which you're sending the "
321 "transaction. This is not part of the \n"
322 " transaction, just kept in "
326 "The fee will be deducted from the amount being sent.\n"
327 " The recipient will receive "
328 "less bitcoins than you enter in the amount field."},
330 "(only available if avoid_reuse wallet flag is set) Avoid "
331 "spending from dirty addresses; addresses are considered\n"
332 " dirty if they have previously "
333 "been used in a transaction."},
338 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
339 HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
340 "dd\" 100000 \"donation\" \"seans "
343 "Jvaydd\" 100000 \"\" \"\" true") +
345 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
346 "dd\", 100000, \"donation\", \"seans "
350 std::shared_ptr<CWallet>
const wallet =
360 pwallet->BlockUntilSyncedToCurrentChain();
366 if (!request.params[2].isNull() &&
367 !request.params[2].get_str().empty()) {
368 mapValue[
"comment"] = request.params[2].get_str();
370 if (!request.params[3].isNull() &&
371 !request.params[3].get_str().empty()) {
372 mapValue[
"to"] = request.params[3].get_str();
375 bool fSubtractFeeFromAmount =
false;
376 if (!request.params[4].isNull()) {
377 fSubtractFeeFromAmount = request.params[4].get_bool();
390 const std::string address = request.params[0].get_str();
391 address_amounts.
pushKV(address, request.params[1]);
393 if (fSubtractFeeFromAmount) {
394 subtractFeeFromAmount.
push_back(address);
397 std::vector<CRecipient> recipients;
399 wallet->GetChainParams());
401 return SendMoney(pwallet, coin_control, recipients, mapValue);
408 "listaddressgroupings",
409 "Lists groups of addresses which have had their common ownership\n"
410 "made public by common use as inputs or as the resulting change\n"
411 "in past transactions\n",
426 "The bitcoin address"},
438 std::shared_ptr<CWallet>
const wallet =
448 pwallet->BlockUntilSyncedToCurrentChain();
453 std::map<CTxDestination, Amount> balances =
455 for (
const std::set<CTxDestination> &grouping :
461 addressInfo.
push_back(balances[address]);
463 const auto *address_book_entry =
465 if (address_book_entry) {
466 addressInfo.
push_back(address_book_entry->GetLabel());
468 jsonGrouping.
push_back(std::move(addressInfo));
470 jsonGroupings.
push_back(std::move(jsonGrouping));
473 return jsonGroupings;
481 std::set<CTxDestination> address_set;
486 address_set =
wallet.GetLabelAddresses(label);
493 "Invalid Bitcoin address");
496 if (!
wallet.IsMine(script_pub_key)) {
499 address_set.insert(dest);
504 if (!params[1].
isNull()) {
505 min_depth = params[1].getInt<
int>();
510 for (
const std::pair<const TxId, CWalletTx> &wtx_pair :
wallet.mapWallet) {
516 for (
const CTxOut &txout : wtx.
tx->vout) {
519 wallet.IsMine(address) && address_set.count(address)) {
530 "getreceivedbyaddress",
531 "Returns the total amount received by the given address in "
532 "transactions with at least minconf confirmations.\n",
535 "The bitcoin address for transactions."},
537 "Only include transactions confirmed at least this many times."},
541 " received at this address."},
543 "\nThe amount from transactions with at least 1 confirmation\n" +
545 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
546 "\nThe amount including unconfirmed transactions, zero "
549 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
550 "\nThe amount with at least 6 confirmations\n" +
552 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
553 "\nAs a JSON-RPC call\n" +
555 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")},
558 std::shared_ptr<CWallet>
const wallet =
568 pwallet->BlockUntilSyncedToCurrentChain();
580 "getreceivedbylabel",
581 "Returns the total amount received by addresses with <label> in "
582 "transactions with at least [minconf] confirmations.\n",
585 "The selected label, may be the default label using \"\"."},
587 "Only include transactions confirmed at least this many times."},
591 " received for this label."},
592 RPCExamples{
"\nAmount received by the default label with at least 1 "
595 "\nAmount received at the tabby label including "
596 "unconfirmed amounts with zero confirmations\n" +
598 "\nThe amount with at least 6 confirmations\n" +
600 "\nAs a JSON-RPC call\n" +
604 std::shared_ptr<CWallet>
const wallet =
614 pwallet->BlockUntilSyncedToCurrentChain();
627 "Returns the total available balance.\n"
628 "The available balance is what the wallet considers currently "
629 "spendable, and is\n"
630 "thus affected by options which limit spendability such as "
631 "-spendzeroconfchange.\n",
634 "Remains for backward compatibility. Must be excluded or set to "
637 "Only include transactions confirmed at least this many times."},
640 "true for watch-only wallets, otherwise false"},
641 "Also include balance in watch-only addresses (see "
644 "(only available if avoid_reuse wallet flag is set) Do not "
645 "include balance in dirty outputs; addresses are considered dirty "
646 "if they have previously been used in a transaction."},
650 " received for this wallet."},
652 "\nThe total amount in the wallet with 0 or more confirmations\n" +
654 "\nThe total amount in the wallet with at least 6 confirmations\n" +
655 HelpExampleCli(
"getbalance",
"\"*\" 6") +
"\nAs a JSON-RPC call\n" +
659 std::shared_ptr<CWallet>
const wallet =
669 pwallet->BlockUntilSyncedToCurrentChain();
673 const auto dummy_value{self.
MaybeArg<std::string>(
"dummy")};
674 if (dummy_value && *dummy_value !=
"*") {
677 "dummy first argument must be excluded or set to \"*\".");
680 const auto min_depth{self.
Arg<
int>(
"minconf")};
682 bool include_watchonly =
687 const auto bal =
GetBalance(*pwallet, min_depth, avoid_reuse);
689 return bal.m_mine_trusted + (include_watchonly
690 ? bal.m_watchonly_trusted
698 "getunconfirmedbalance",
699 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
705 std::shared_ptr<CWallet>
const wallet =
715 pwallet->BlockUntilSyncedToCurrentChain();
727 "Send multiple times. Amounts are double-precision "
728 "floating point numbers." +
732 "Must be set to \"\" for backwards compatibility.",
734 .oneline_description =
"\"\""}},
739 "The addresses and amounts",
742 "The bitcoin address is the key, the numeric amount (can "
748 "Only use the balance confirmed at least this many times."},
756 " The fee will be equally deducted "
757 "from the amount of each selected address.\n"
758 " Those recipients will receive less "
759 "bitcoins than you enter in their corresponding amount field.\n"
760 " If no addresses are specified "
761 "here, the sender pays the fee.",
764 "Subtract fee from this address"},
769 "The transaction id for the send. Only 1 transaction is "
770 "created regardless of the number of addresses."},
772 "\nSend two amounts to two different addresses:\n" +
776 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
778 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
780 "\nSend two amounts to two different addresses setting the "
781 "confirmation and comment:\n" +
785 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
787 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
790 "\nSend two amounts to two different addresses, subtract fee "
795 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
797 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
799 "\"[\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\","
800 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\"]"
802 "\nAs a JSON-RPC call\n" +
806 "{\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\":0.01,"
807 "\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\":0.02}, "
812 std::shared_ptr<CWallet>
const wallet =
822 pwallet->BlockUntilSyncedToCurrentChain();
826 if (!request.params[0].isNull() &&
827 !request.params[0].get_str().empty()) {
829 "Dummy value must be set to \"\"");
834 if (!request.params[3].isNull() &&
835 !request.params[3].get_str().empty()) {
836 mapValue[
"comment"] = request.params[3].
get_str();
840 if (!request.params[4].isNull()) {
841 subtractFeeFromAmount = request.params[4].
get_array();
844 std::vector<CRecipient> recipients;
846 wallet->GetChainParams());
849 return SendMoney(pwallet, coin_control, recipients,
850 std::move(mapValue));
857 "addmultisigaddress",
858 "Add an nrequired-to-sign multisignature address to the wallet. "
859 "Requires a new wallet backup.\n"
860 "Each key is a Bitcoin address or hex-encoded public key.\n"
861 "This functionality is only intended for use with non-watchonly "
863 "See `importaddress` for watchonly p2sh address support.\n"
864 "If 'label' is specified (DEPRECATED), assign address to that label.\n"
865 "Note: This command is only compatible with legacy wallets.\n",
868 "The number of required signatures out of the n keys or "
874 "The bitcoin addresses or hex-encoded public keys",
877 "bitcoin address or hex-encoded public key"},
881 "A label to assign the addresses to."},
888 "The value of the new multisig address"},
890 "The string value of the hex-encoded redemption script"},
892 "The descriptor for this multisig"},
895 "\nAdd a multisig address from 2 addresses\n" +
898 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
899 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
900 "\nAs a JSON-RPC call\n" +
903 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
904 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")},
907 std::shared_ptr<CWallet>
const wallet =
920 if (!request.params[2].isNull()) {
924 int required = request.params[0].getInt<
int>();
928 std::vector<CPubKey> pubkeys;
929 for (
size_t i = 0; i < keys_or_addrs.size(); ++i) {
930 if (
IsHex(keys_or_addrs[i].get_str()) &&
931 (keys_or_addrs[i].get_str().length() == 66 ||
932 keys_or_addrs[i].get_str().length() == 130)) {
937 keys_or_addrs[i].get_str()));
946 required, pubkeys, output_type, spk_man, inner);
950 std::unique_ptr<Descriptor> descriptor =
956 result.
pushKV(
"descriptor", descriptor->ToString());
964 int nConf{std::numeric_limits<int>::max()};
971 const UniValue ¶ms,
bool by_label)
975 if (!params[0].
isNull()) {
976 nMinDepth = params[0].getInt<
int>();
980 bool fIncludeEmpty =
false;
981 if (!params[1].
isNull()) {
982 fIncludeEmpty = params[1].get_bool();
990 bool has_filtered_address =
false;
992 if (!by_label && params.size() > 3) {
994 pwallet->GetChainParams())) {
996 "address_filter parameter was invalid");
1000 has_filtered_address =
true;
1004 std::map<CTxDestination, tallyitem> mapTally;
1005 for (
const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) {
1012 int nDepth = pwallet->GetTxDepthInMainChain(wtx);
1013 if (nDepth < nMinDepth) {
1017 for (
const CTxOut &txout : wtx.
tx->vout) {
1023 if (has_filtered_address && !(filtered_address == address)) {
1028 if (!(mine & filter)) {
1044 std::map<std::string, tallyitem> label_tally;
1048 auto start = pwallet->m_address_book.begin();
1049 auto end = pwallet->m_address_book.end();
1051 if (has_filtered_address) {
1052 start = pwallet->m_address_book.find(filtered_address);
1054 end = std::next(start);
1058 for (
auto item_it = start; item_it != end; ++item_it) {
1059 if (item_it->second.IsChange()) {
1063 const std::string &label = item_it->second.GetLabel();
1064 std::map<CTxDestination, tallyitem>::iterator it =
1065 mapTally.find(address);
1066 if (it == mapTally.end() && !fIncludeEmpty) {
1071 int nConf = std::numeric_limits<int>::max();
1072 bool fIsWatchonly =
false;
1073 if (it != mapTally.end()) {
1074 nAmount = (*it).second.nAmount;
1075 nConf = (*it).second.nConf;
1076 fIsWatchonly = (*it).second.fIsWatchonly;
1087 obj.
pushKV(
"involvesWatchonly",
true);
1090 obj.
pushKV(
"amount", nAmount);
1091 obj.
pushKV(
"confirmations",
1092 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1093 obj.
pushKV(
"label", label);
1095 if (it != mapTally.end()) {
1096 for (
const uint256 &_item : (*it).second.txids) {
1100 obj.
pushKV(
"txids", std::move(transactions));
1106 for (
const auto &entry : label_tally) {
1107 Amount nAmount = entry.second.nAmount;
1108 int nConf = entry.second.nConf;
1110 if (entry.second.fIsWatchonly) {
1111 obj.
pushKV(
"involvesWatchonly",
true);
1113 obj.
pushKV(
"amount", nAmount);
1114 obj.
pushKV(
"confirmations",
1115 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1116 obj.
pushKV(
"label", entry.first);
1126 "listreceivedbyaddress",
1127 "List balances by receiving address.\n",
1130 "The minimum number of confirmations before payments are "
1133 "Whether to include addresses that haven't received any "
1137 "true for watch-only wallets, otherwise false"},
1138 "Whether to include watch-only addresses (see 'importaddress')."},
1140 "If present, only return information on this address."},
1152 "Only returns true if imported addresses were involved "
1157 " received by the address"},
1159 "The number of confirmations of the most recent "
1160 "transaction included"},
1162 "The label of the receiving address. The default label "
1169 "The ids of transactions received with the address"},
1178 "listreceivedbyaddress",
1179 "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")},
1182 std::shared_ptr<CWallet>
const wallet =
1192 pwallet->BlockUntilSyncedToCurrentChain();
1196 return ListReceived(config, pwallet, request.params,
false);
1203 "listreceivedbylabel",
1204 "List received transactions by label.\n",
1207 "The minimum number of confirmations before payments are "
1210 "Whether to include labels that haven't received any payments."},
1213 "true for watch-only wallets, otherwise false"},
1214 "Whether to include watch-only addresses (see 'importaddress')."},
1226 "Only returns true if imported addresses were involved "
1229 "The total amount received by addresses with this label"},
1231 "The number of confirmations of the most recent "
1232 "transaction included"},
1234 "The label of the receiving address. The default label "
1243 std::shared_ptr<CWallet>
const wallet =
1253 pwallet->BlockUntilSyncedToCurrentChain();
1257 return ListReceived(config, pwallet, request.params,
true);
1282 int nMinDepth,
bool fLong, Vec &ret,
1284 const std::string *filter_label)
1287 std::list<COutputEntry> listReceived;
1288 std::list<COutputEntry> listSent;
1296 if (!filter_label) {
1299 if (involvesWatchonly ||
1301 entry.
pushKV(
"involvesWatchonly",
true);
1304 entry.
pushKV(
"category",
"send");
1305 entry.
pushKV(
"amount", -s.amount);
1306 const auto *address_book_entry =
1307 pwallet->FindAddressBookEntry(s.destination);
1308 if (address_book_entry) {
1309 entry.
pushKV(
"label", address_book_entry->GetLabel());
1311 entry.
pushKV(
"vout", s.vout);
1312 entry.
pushKV(
"fee", -1 * nFee);
1316 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1317 ret.push_back(std::move(entry));
1322 if (listReceived.size() > 0 &&
1323 pwallet->GetTxDepthInMainChain(wtx) >= nMinDepth) {
1326 const auto *address_book_entry =
1327 pwallet->FindAddressBookEntry(r.destination);
1328 if (address_book_entry) {
1329 label = address_book_entry->GetLabel();
1331 if (filter_label && label != *filter_label) {
1335 if (involvesWatchonly ||
1337 entry.
pushKV(
"involvesWatchonly",
true);
1340 if (wtx.IsCoinBase()) {
1341 if (pwallet->GetTxDepthInMainChain(wtx) < 1) {
1342 entry.
pushKV(
"category",
"orphan");
1343 }
else if (pwallet->IsTxImmatureCoinBase(wtx)) {
1344 entry.
pushKV(
"category",
"immature");
1346 entry.
pushKV(
"category",
"generate");
1349 entry.
pushKV(
"category",
"receive");
1351 entry.
pushKV(
"amount", r.amount);
1352 if (address_book_entry) {
1353 entry.
pushKV(
"label", label);
1355 entry.
pushKV(
"vout", r.vout);
1359 ret.push_back(std::move(entry));
1367 "The number of confirmations for the transaction. Negative "
1368 "confirmations means the\n"
1369 "transaction conflicted that many blocks ago."},
1371 "Only present if transaction only input is a coinbase one."},
1373 "Only present if we consider transaction to be trusted and so safe to "
1376 "The block hash containing the transaction."},
1378 "The block height containing the transaction."},
1380 "The index of the transaction in the block that includes it."},
1386 "Conflicting transaction ids.",
1395 "If a comment is associated with the transaction, only present if not "
1404 "If a label name is provided, this will return only incoming "
1405 "transactions paying to addresses with the specified label.\n"
1406 "\nReturns up to 'count' most recent transactions skipping the first "
1407 "'from' transactions.\n",
1410 "If set, should be a valid label name to return only incoming "
1411 "transactions with the specified label, or \"*\" to disable "
1412 "filtering and return all transactions."},
1414 "The number of transactions to return"},
1416 "The number of transactions to skip"},
1419 "true for watch-only wallets, otherwise false"},
1420 "Include transactions to watch-only addresses (see "
1421 "'importaddress')"},
1429 Cat(
Cat<std::vector<RPCResult>>(
1432 "Only returns true if imported addresses were "
1433 "involved in transaction."},
1435 "The bitcoin address of the transaction."},
1437 "The transaction category.\n"
1438 "\"send\" Transactions sent.\n"
1439 "\"receive\" Non-coinbase "
1440 "transactions received.\n"
1441 "\"generate\" Coinbase transactions "
1442 "received with more than 100 confirmations.\n"
1443 "\"immature\" Coinbase transactions "
1444 "received with 100 or fewer confirmations.\n"
1445 "\"orphan\" Orphaned coinbase "
1446 "transactions received."},
1448 "The amount in " + ticker +
1449 ". This is negative for the 'send' category, "
1451 "for all other categories"},
1453 "A comment for the address/transaction, if any"},
1456 "The amount of the fee in " + ticker +
1457 ". This is negative and only available for "
1459 "'send' category of transactions."},
1464 "'true' if the transaction has been abandoned "
1465 "(inputs are respendable). Only available for the \n"
1466 "'send' category of transactions."},
1469 RPCExamples{
"\nList the most recent 10 transactions in the systems\n" +
1471 "\nList transactions 100 to 120\n" +
1473 "\nAs a JSON-RPC call\n" +
1477 std::shared_ptr<CWallet>
const wallet =
1487 pwallet->BlockUntilSyncedToCurrentChain();
1489 const std::string *filter_label =
nullptr;
1490 if (!request.params[0].isNull() &&
1491 request.params[0].get_str() !=
"*") {
1492 filter_label = &request.params[0].get_str();
1493 if (filter_label->empty()) {
1496 "Label argument must be a valid label name or \"*\".");
1500 if (!request.params[1].isNull()) {
1501 nCount = request.params[1].getInt<
int>();
1505 if (!request.params[2].isNull()) {
1506 nFrom = request.params[2].getInt<
int>();
1521 std::vector<UniValue> ret;
1528 for (CWallet::TxItems::const_reverse_iterator it =
1530 it != txOrdered.rend(); ++it) {
1534 if (
int(ret.size()) >= (nCount + nFrom)) {
1542 if (nFrom > (
int)ret.size()) {
1545 if ((nFrom + nCount) > (
int)ret.size()) {
1546 nCount = ret.size() - nFrom;
1549 auto txs_rev_it{std::make_move_iterator(ret.rend())};
1552 result.push_backV(txs_rev_it - nFrom - nCount, txs_rev_it - nFrom);
1562 "Get all transactions in blocks since block [blockhash], or all "
1563 "transactions if omitted.\n"
1564 "If \"blockhash\" is no longer a part of the main chain, transactions "
1565 "from the fork point onward are included.\n"
1566 "Additionally, if include_removed is set, transactions affecting the "
1567 "wallet which were removed are returned in the \"removed\" array.\n",
1570 "If set, the block hash to list transactions since, otherwise "
1571 "list all transactions."},
1573 "Return the nth block hash from the main chain. e.g. 1 would mean "
1574 "the best block hash. Note: this is not used as a filter, but "
1575 "only affects [lastblock] in the return value"},
1578 "true for watch-only wallets, otherwise false"},
1579 "Include transactions to watch-only addresses (see "
1580 "'importaddress')"},
1582 "Show transactions that were removed due to a reorg in the "
1583 "\"removed\" array\n"
1585 "guaranteed to work on pruned nodes)"},
1597 Cat(
Cat<std::vector<RPCResult>>(
1600 "Only returns true if imported addresses "
1601 "were involved in transaction."},
1603 "The bitcoin address of the transaction."},
1605 "The transaction category.\n"
1606 "\"send\" Transactions "
1608 "\"receive\" Non-coinbase "
1609 "transactions received.\n"
1610 "\"generate\" Coinbase "
1611 "transactions received with more than 100 "
1613 "\"immature\" Coinbase "
1614 "transactions received with 100 or fewer "
1616 "\"orphan\" Orphaned "
1617 "coinbase transactions received."},
1619 "The amount in " + ticker +
1620 ". This is negative for the 'send' "
1621 "category, and is positive\n"
1622 "for all other categories"},
1626 "The amount of the fee in " + ticker +
1627 ". This is negative and only available "
1629 "'send' category of transactions."},
1634 "'true' if the transaction has been abandoned "
1635 "(inputs are respendable). Only available for "
1637 "'send' category of transactions."},
1639 "If a comment is associated with the "
1642 "A comment for the address/transaction, if any"},
1644 "If a comment to is associated with the "
1650 "<structure is the same as \"transactions\" above, only "
1651 "present if include_removed=true>\n"
1652 "Note: transactions that were re-added in the active chain "
1653 "will appear as-is in this array, and may thus have a "
1654 "positive confirmation count.",
1659 "The hash of the block (target_confirmations-1) from the best "
1660 "block on the main chain, or the genesis hash if the "
1661 "referenced block does not exist yet. This is typically used "
1662 "to feed back into listsinceblock the next time you call it. "
1663 "So you would generally use a target_confirmations of say 6, "
1664 "so you will be continually re-notified of transactions until "
1665 "they've reached 6 confirmations plus any new ones"},
1669 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1670 "7d38571037cdb1a57f663ad\" 6") +
1672 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1673 "7d38571037cdb1a57f663ad\", 6")},
1676 std::shared_ptr<CWallet>
const pwallet =
1687 wallet.BlockUntilSyncedToCurrentChain();
1693 std::optional<int> height;
1697 std::optional<int> altheight;
1698 int target_confirms = 1;
1702 if (!request.params[0].isNull() &&
1703 !request.params[0].get_str().empty()) {
1707 if (!
wallet.chain().findCommonAncestor(
1708 blockId,
wallet.GetLastBlockHash(),
1716 if (!request.params[1].isNull()) {
1717 target_confirms = request.params[1].getInt<
int>();
1719 if (target_confirms < 1) {
1721 "Invalid parameter");
1729 bool include_removed =
1730 (request.params[3].isNull() || request.params[3].get_bool());
1732 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1736 for (
const std::pair<const TxId, CWalletTx> &pairWtx :
1740 if (depth == -1 ||
wallet.GetTxDepthInMainChain(tx) < depth) {
1749 while (include_removed && altheight && *altheight > *height) {
1751 if (!
wallet.chain().findBlock(blockId,
1755 "Can't read block from disk");
1758 auto it =
wallet.mapWallet.find(tx->GetId());
1759 if (it !=
wallet.mapWallet.end()) {
1774 std::min(target_confirms,
wallet.GetLastBlockHeight() + 1);
1776 wallet.GetLastBlockHash(),
1777 wallet.GetLastBlockHeight() + 1 - target_confirms,
1781 ret.
pushKV(
"transactions", std::move(transactions));
1782 if (include_removed) {
1783 ret.
pushKV(
"removed", std::move(removed));
1796 "Get detailed information about in-wallet transaction <txid>\n",
1799 "The transaction id"},
1802 "true for watch-only wallets, otherwise false"},
1803 "Whether to include watch-only addresses in balance calculation "
1806 "Whether to include a `decoded` field containing the decoded "
1807 "transaction (equivalent to RPC decoderawtransaction)"},
1811 Cat(
Cat<std::vector<RPCResult>>(
1814 "The amount in " + ticker},
1816 "The amount of the fee in " + ticker +
1817 ". This is negative and only available for the\n"
1818 "'send' category of transactions."},
1831 "Only returns true if imported addresses were "
1832 "involved in transaction."},
1834 "The bitcoin address involved in the "
1837 "The transaction category.\n"
1838 "\"send\" Transactions sent.\n"
1839 "\"receive\" Non-coinbase "
1840 "transactions received.\n"
1841 "\"generate\" Coinbase "
1842 "transactions received with more than 100 "
1844 "\"immature\" Coinbase "
1845 "transactions received with 100 or fewer "
1847 "\"orphan\" Orphaned coinbase "
1848 "transactions received."},
1850 "The amount in " + ticker},
1852 "A comment for the address/transaction, if any"},
1855 "The amount of the fee in " + ticker +
1856 ". This is negative and only available for "
1858 "'send' category of transactions."},
1860 "'true' if the transaction has been abandoned "
1861 "(inputs are respendable). Only available for "
1863 "'send' category of transactions."},
1867 "Raw data for transaction"},
1870 "Optional, the decoded transaction (only present when "
1871 "`verbose` is passed)",
1878 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1879 "5cf302fc80e9d5fbf5d48d\"") +
1881 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1882 "5cf302fc80e9d5fbf5d48d\" true") +
1884 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1885 "5cf302fc80e9d5fbf5d48d\" false true") +
1887 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1888 "5cf302fc80e9d5fbf5d48d\"")},
1891 std::shared_ptr<CWallet>
const wallet =
1901 pwallet->BlockUntilSyncedToCurrentChain();
1912 bool verbose = request.params[2].isNull()
1914 : request.params[2].get_bool();
1917 auto it = pwallet->mapWallet.find(txid);
1918 if (it == pwallet->mapWallet.end()) {
1920 "Invalid or non-wallet transaction id");
1926 Amount nNet = nCredit - nDebit;
1928 ? wtx.
tx->GetValueOut() - nDebit
1931 entry.
pushKV(
"amount", nNet - nFee);
1933 entry.
pushKV(
"fee", nFee);
1941 entry.
pushKV(
"details", std::move(details));
1944 entry.
pushKV(
"hex", strHex);
1955 [&pwallet](
const CTxOut &txout)
1957 AssertLockHeld(pwallet->cs_wallet);
1958 return OutputIsChange(*pwallet, txout);
1960 entry.
pushKV(
"decoded", std::move(decoded));
1970 "abandontransaction",
1971 "Mark in-wallet transaction <txid> as abandoned\n"
1972 "This will mark this transaction and all its in-wallet descendants as "
1973 "abandoned which will allow\n"
1974 "for their inputs to be respent. It can be used to replace \"stuck\" "
1975 "or evicted transactions.\n"
1976 "It only works on transactions which are not included in a block and "
1977 "are not currently in the mempool.\n"
1978 "It has no effect on transactions which are already abandoned.\n",
1981 "The transaction id"},
1985 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1986 "5cf302fc80e9d5fbf5d48d\"") +
1988 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1989 "5cf302fc80e9d5fbf5d48d\"")},
1992 std::shared_ptr<CWallet>
const wallet =
2002 pwallet->BlockUntilSyncedToCurrentChain();
2008 if (!pwallet->mapWallet.count(txid)) {
2010 "Invalid or non-wallet transaction id");
2015 "Transaction not eligible for abandonment");
2029 "The new keypool size"},
2036 std::shared_ptr<CWallet>
const wallet =
2047 "Error: Private keys are disabled for this wallet");
2054 unsigned int kpSize = 0;
2055 if (!request.params[0].isNull()) {
2056 if (request.params[0].getInt<
int>() < 0) {
2059 "Invalid parameter, expected valid size.");
2061 kpSize = (
unsigned int)request.params[0].getInt<
int>();
2069 "Error refreshing keypool.");
2080 "Updates list of temporarily unspendable outputs.\n"
2081 "Temporarily lock (unlock=false) or unlock (unlock=true) specified "
2082 "transaction outputs.\n"
2083 "If no transaction outputs are specified when unlocking then all "
2084 "current locked transaction outputs are unlocked.\n"
2085 "A locked transaction output will not be chosen by automatic coin "
2086 "selection, when spending bitcoins.\n"
2087 "Manually selected coins are automatically unlocked.\n"
2088 "Locks are stored in memory only. Nodes start with zero locked "
2089 "outputs, and the locked output list\n"
2090 "is always cleared (by virtue of process exit) when a node stops or "
2092 "Also see the listunspent call\n",
2095 "Whether to unlock (true) or lock (false) the specified "
2101 "The transaction outputs and within each, txid (string) vout "
2113 "The output number"},
2120 "Whether the command was successful or not"},
2122 "\nList the unspent transactions\n" +
2124 "\nLock an unspent transaction\n" +
2127 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2128 "b764ed838b5655e72f463568df1aadf0\\\""
2129 ",\\\"vout\\\":1}]\"") +
2130 "\nList the locked transactions\n" +
2132 "\nUnlock the transaction again\n" +
2135 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2136 "b764ed838b5655e72f463568df1aadf0\\\""
2137 ",\\\"vout\\\":1}]\"") +
2138 "\nAs a JSON-RPC call\n" +
2141 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2142 "b764ed838b5655e72f463568df1aadf0\\\""
2143 ",\\\"vout\\\":1}]\"")},
2146 std::shared_ptr<CWallet>
const wallet =
2156 pwallet->BlockUntilSyncedToCurrentChain();
2160 bool fUnlock = request.params[0].get_bool();
2162 if (request.params[1].isNull()) {
2173 std::vector<COutPoint> outputs;
2176 for (
size_t idx = 0; idx < output_params.
size(); idx++) {
2188 "Invalid parameter, vout cannot be negative");
2192 const auto it = pwallet->mapWallet.find(txid);
2193 if (it == pwallet->mapWallet.end()) {
2196 "Invalid parameter, unknown transaction");
2199 const COutPoint output(txid, nOutput);
2201 if (output.GetN() >= trans.
tx->vout.size()) {
2204 "Invalid parameter, vout index out of bounds");
2207 if (pwallet->
IsSpent(output)) {
2210 "Invalid parameter, expected unspent output");
2214 if (fUnlock && !is_locked) {
2217 "Invalid parameter, expected locked output");
2220 if (!fUnlock && is_locked) {
2223 "Invalid parameter, output already locked");
2226 outputs.push_back(output);
2230 for (
const COutPoint &output : outputs) {
2246 "Returns list of temporarily unspendable outputs.\n"
2247 "See the lockunspent call to lock and unlock transactions for "
2259 "The transaction id locked"},
2264 "\nList the unspent transactions\n" +
2266 "\nLock an unspent transaction\n" +
2269 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2270 "b764ed838b5655e72f463568df1aadf0\\\""
2271 ",\\\"vout\\\":1}]\"") +
2272 "\nList the locked transactions\n" +
2274 "\nUnlock the transaction again\n" +
2277 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2278 "b764ed838b5655e72f463568df1aadf0\\\""
2279 ",\\\"vout\\\":1}]\"") +
2280 "\nAs a JSON-RPC call\n" +
HelpExampleRpc(
"listlockunspent",
"")},
2283 std::shared_ptr<CWallet>
const wallet =
2292 std::vector<COutPoint> vOutpts;
2297 for (
const COutPoint &output : vOutpts) {
2300 o.
pushKV(
"txid", output.GetTxId().GetHex());
2301 o.
pushKV(
"vout",
int(output.GetN()));
2313 "Set the transaction fee per kB for this wallet. Overrides the "
2314 "global -paytxfee command line parameter.\n"
2315 "Can be deactivated by passing 0 as the fee. In that case automatic "
2316 "fee selection will be used by default.\n",
2326 std::shared_ptr<CWallet>
const wallet =
2336 CFeeRate tx_fee_rate(nAmount, 1000);
2340 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2343 strprintf(
"txfee cannot be less than min relay tx fee (%s)",
2345 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2348 strprintf(
"txfee cannot be less than wallet min fee (%s)",
2350 }
else if (tx_fee_rate > max_tx_fee_rate) {
2354 "txfee cannot be more than wallet max tx fee (%s)",
2376 "balances from outputs that the wallet can sign",
2379 "trusted balance (outputs created by the wallet or "
2380 "confirmed outputs)"},
2382 "untrusted pending balance (outputs created by "
2383 "others that are in the mempool)"},
2385 "balance from immature coinbase outputs"},
2387 "(only present if avoid_reuse is set) balance from "
2388 "coins sent to addresses that were previously "
2389 "spent from (potentially privacy violating)"},
2393 "watchonly balances (not present if wallet does not "
2397 "trusted balance (outputs created by the wallet or "
2398 "confirmed outputs)"},
2400 "untrusted pending balance (outputs created by "
2401 "others that are in the mempool)"},
2403 "balance from immature coinbase outputs"},
2410 std::shared_ptr<CWallet>
const rpc_wallet =
2420 wallet.BlockUntilSyncedToCurrentChain();
2428 balances_mine.pushKV(
"trusted", bal.m_mine_trusted);
2429 balances_mine.pushKV(
"untrusted_pending",
2430 bal.m_mine_untrusted_pending);
2431 balances_mine.pushKV(
"immature", bal.m_mine_immature);
2437 balances_mine.pushKV(
"used",
2438 full_bal.m_mine_trusted +
2439 full_bal.m_mine_untrusted_pending -
2440 bal.m_mine_trusted -
2441 bal.m_mine_untrusted_pending);
2443 balances.pushKV(
"mine", std::move(balances_mine));
2445 auto spk_man =
wallet.GetLegacyScriptPubKeyMan();
2446 if (spk_man && spk_man->HaveWatchOnly()) {
2448 balances_watchonly.pushKV(
"trusted", bal.m_watchonly_trusted);
2449 balances_watchonly.pushKV(
"untrusted_pending",
2450 bal.m_watchonly_untrusted_pending);
2451 balances_watchonly.pushKV(
"immature", bal.m_watchonly_immature);
2452 balances.pushKV(
"watchonly", std::move(balances_watchonly));
2462 "Returns an object containing various wallet state info.\n",
2472 "DEPRECATED. Identical to getbalances().mine.trusted"},
2474 "DEPRECATED. Identical to "
2475 "getbalances().mine.untrusted_pending"},
2477 "DEPRECATED. Identical to getbalances().mine.immature"},
2479 "the total number of transactions in the wallet"},
2482 " of the oldest pre-generated key in the key pool. "
2483 "Legacy wallets only."},
2485 "how many new keys are pre-generated (only counts external "
2488 "how many new keys are pre-generated for internal use (used "
2489 "for change outputs, only appears if the wallet is using "
2490 "this feature, otherwise external keys are used)"},
2494 " until which the wallet is unlocked for transfers, or 0 "
2495 "if the wallet is locked (only present for "
2496 "passphrase-encrypted wallets)"},
2498 "the transaction fee configuration, set in " +
2501 "the Hash160 of the HD seed (only present when HD is "
2504 "false if privatekeys are disabled for this wallet (enforced "
2505 "watch-only wallet)"},
2508 "current scanning details, or false if no scan is in "
2512 "elapsed seconds since scan start"},
2514 "scanning progress percentage [0.0, 1.0]"},
2518 "whether this wallet tracks clean/dirty coins in terms of "
2521 "whether this wallet uses descriptors for scriptPubKey "
2529 std::shared_ptr<CWallet>
const wallet =
2539 pwallet->BlockUntilSyncedToCurrentChain();
2550 obj.
pushKV(
"balance", bal.m_mine_trusted);
2551 obj.
pushKV(
"unconfirmed_balance", bal.m_mine_untrusted_pending);
2552 obj.
pushKV(
"immature_balance", bal.m_mine_immature);
2553 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2554 if (kp_oldest > 0) {
2555 obj.
pushKV(
"keypoololdest", kp_oldest);
2557 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2569 obj.
pushKV(
"keypoolsize_hd_internal",
2573 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2577 "private_keys_enabled",
2581 scanning.
pushKV(
"duration", Ticks<std::chrono::seconds>(
2584 obj.
pushKV(
"scanning", std::move(scanning));
2586 obj.
pushKV(
"scanning",
false);
2588 obj.
pushKV(
"avoid_reuse",
2590 obj.
pushKV(
"descriptors",
2600 "Returns a list of wallets in the wallet directory.\n",
2626 wallet.pushKV(
"name", path.u8string());
2631 result.
pushKV(
"wallets", std::move(wallets));
2640 "Returns a list of currently loaded wallets.\n"
2641 "For full information on the wallet, use \"getwalletinfo\"\n",
2669 "Loads a wallet from a wallet file or directory."
2670 "\nNote that all wallet command-line options used when starting "
2672 "\napplied to the new wallet (eg -rescan, etc).\n",
2675 "The wallet directory or .dat file."},
2677 "Save wallet name to persistent settings and load on startup. "
2678 "True to add wallet to startup list, false to remove, null to "
2679 "leave unchanged."},
2686 "The wallet name if loaded successfully."},
2688 "Warning message if wallet was not loaded cleanly."},
2695 const std::string
name(request.params[0].get_str());
2701 std::vector<bilingual_str> warnings;
2702 std::optional<bool> load_on_start =
2703 request.params[1].isNull()
2705 : std::optional<bool>(request.params[1].get_bool());
2707 context,
name, load_on_start, options, status, error, warnings);
2721 std::string
flags =
"";
2724 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2729 "Change the state of the given wallet flag for a wallet.\n",
2732 "The name of the flag to change. Current available flags: " +
2742 "The name of the flag that was modified"},
2744 "The new state of the flag"},
2746 "Any warnings associated with the change"},
2752 std::shared_ptr<CWallet>
const wallet =
2759 std::string flag_str = request.params[0].get_str();
2761 request.params[1].isNull() || request.params[1].get_bool();
2766 strprintf(
"Unknown wallet flag: %s", flag_str));
2774 strprintf(
"Wallet flag is immutable: %s", flag_str));
2782 strprintf(
"Wallet flag is already set to %s: %s",
2783 value ?
"true" :
"false", flag_str));
2786 res.
pushKV(
"flag_name", flag_str);
2787 res.
pushKV(
"flag_state", value);
2807 "Creates and loads a new wallet.\n",
2810 "The name for the new wallet. If this is a path, the wallet will "
2811 "be created at the path location."},
2813 "Disable the possibility of private keys (only watchonlys are "
2814 "possible in this mode)."},
2816 "Create a blank wallet. A blank wallet has no keys or HD seed. "
2817 "One can be set using sethdseed."},
2819 "Encrypt the wallet with this passphrase."},
2821 "Keep track of coin reuse, and treat dirty and clean coins "
2822 "differently with privacy considerations in mind."},
2824 "Create a native descriptor wallet. The wallet will use "
2825 "descriptors internally to handle address creation"},
2827 "Save wallet name to persistent settings and load on startup. "
2828 "True to add wallet to startup list, false to remove, null to "
2829 "leave unchanged."},
2836 "The wallet name if created successfully. If the wallet "
2837 "was created using a full path, the wallet_name will be "
2840 "Warning message if wallet was not loaded cleanly."},
2846 {
"avoid_reuse",
true},
2847 {
"descriptors",
true},
2848 {
"load_on_startup",
true}}) +
2850 {
"avoid_reuse",
true},
2851 {
"descriptors",
true},
2852 {
"load_on_startup",
true}})},
2857 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2861 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2866 passphrase.reserve(100);
2867 std::vector<bilingual_str> warnings;
2868 if (!request.params[3].isNull()) {
2869 passphrase = request.params[3].get_str().c_str();
2870 if (passphrase.empty()) {
2873 "Empty string given as passphrase, wallet will "
2874 "not be encrypted."));
2878 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2881 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2884 "Wallet is an experimental descriptor wallet"));
2893 std::optional<bool> load_on_start =
2894 request.params[6].isNull()
2896 : std::make_optional<bool>(request.params[6].get_bool());
2897 std::shared_ptr<CWallet>
wallet =
2899 load_on_start, options, status, error, warnings);
2919 "Unloads the wallet referenced by the request endpoint otherwise "
2920 "unloads the wallet specified in the argument.\n"
2921 "Specifying the wallet name on a wallet endpoint is invalid.",
2925 "The name of the wallet to unload."},
2927 "Save wallet name to persistent settings and load on startup. "
2928 "True to add wallet to startup list, false to remove, null to "
2929 "leave unchanged."},
2936 "Warning message if wallet was not unloaded cleanly."},
2942 std::string wallet_name;
2944 if (!request.params[0].isNull()) {
2946 "Cannot unload the requested wallet");
2949 wallet_name = request.params[0].get_str();
2957 "Requested wallet does not exist or is not loaded");
2963 std::vector<bilingual_str> warnings;
2964 std::optional<bool> load_on_start{self.
MaybeArg<
bool>(1)};
2967 "Requested wallet already unloaded");
2984 "Returns array of unspent transaction outputs\n"
2985 "with between minconf and maxconf (inclusive) confirmations.\n"
2986 "Optionally filter to only include txouts paid to specified "
2990 "The minimum confirmations to filter"},
2992 "The maximum confirmations to filter"},
2997 "The bitcoin addresses to filter",
3004 "Include outputs that are not safe to spend\n"
3005 " See description of \"safe\" attribute below."},
3009 "JSON with query options",
3013 "Minimum value of each UTXO in " + ticker +
""},
3016 "Maximum value of each UTXO in " + ticker +
""},
3021 "Minimum sum value of all UTXOs in " + ticker +
""},
3038 "The associated label, or \"\" for the default label"},
3041 "the transaction output amount in " + ticker},
3043 "The number of confirmations"},
3045 "The redeemScript if scriptPubKey is P2SH"},
3047 "Whether we have the private keys to spend this output"},
3049 "Whether we know how to spend this output, ignoring the "
3052 "(only present if avoid_reuse is set) Whether this "
3053 "output is reused/dirty (sent to an address that was "
3054 "previously spent from)"},
3056 "(only when solvable) A descriptor for spending this "
3059 "Whether this output is considered safe to spend. "
3060 "Unconfirmed transactions\n"
3061 "from outside keys are considered unsafe\n"
3062 "and are not eligible for spending by fundrawtransaction "
3063 "and sendtoaddress."},
3070 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3071 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3074 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3075 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3078 "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") +
3081 "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")},
3084 std::shared_ptr<CWallet>
const wallet =
3092 if (!request.params[0].isNull()) {
3093 nMinDepth = request.params[0].getInt<
int>();
3096 int nMaxDepth = 9999999;
3097 if (!request.params[1].isNull()) {
3098 nMaxDepth = request.params[1].getInt<
int>();
3101 std::set<CTxDestination> destinations;
3102 if (!request.params[2].isNull()) {
3104 for (
size_t idx = 0; idx < inputs.
size(); idx++) {
3105 const UniValue &input = inputs[idx];
3111 std::string(
"Invalid Bitcoin address: ") +
3114 if (!destinations.insert(dest).second) {
3118 "Invalid parameter, duplicated address: ") +
3124 bool include_unsafe =
true;
3125 if (!request.params[3].isNull()) {
3126 include_unsafe = request.params[3].get_bool();
3132 uint64_t nMaximumCount = 0;
3134 if (!request.params[4].isNull()) {
3147 if (options.
exists(
"minimumAmount")) {
3151 if (options.
exists(
"maximumAmount")) {
3155 if (options.
exists(
"minimumSumAmount")) {
3160 if (options.
exists(
"maximumCount")) {
3161 nMaximumCount = options[
"maximumCount"].
getInt<int64_t>();
3168 pwallet->BlockUntilSyncedToCurrentChain();
3171 std::vector<COutput> vecOutputs;
3180 nMaximumAmount, nMinimumSumAmount,
3186 const bool avoid_reuse =
3191 const CScript &scriptPubKey =
3192 out.tx->tx->vout[
out.i].scriptPubKey;
3197 if (destinations.size() &&
3198 (!fValidAddress || !destinations.count(address))) {
3203 entry.
pushKV(
"txid",
out.tx->GetId().GetHex());
3206 if (fValidAddress) {
3209 const auto *address_book_entry =
3211 if (address_book_entry) {
3212 entry.
pushKV(
"label", address_book_entry->GetLabel());
3215 std::unique_ptr<SigningProvider> provider =
3218 if (scriptPubKey.IsPayToScriptHash()) {
3223 entry.
pushKV(
"redeemScript",
3231 entry.
pushKV(
"amount",
out.tx->tx->vout[
out.i].nValue);
3232 entry.
pushKV(
"confirmations",
out.nDepth);
3233 entry.
pushKV(
"spendable",
out.fSpendable);
3234 entry.
pushKV(
"solvable",
out.fSolvable);
3235 if (
out.fSolvable) {
3236 std::unique_ptr<SigningProvider> provider =
3241 entry.
pushKV(
"desc", descriptor->ToString());
3245 entry.
pushKV(
"reused", reused);
3257 Amount &fee_out,
int &change_position,
3261 pwallet->BlockUntilSyncedToCurrentChain();
3263 change_position = -1;
3264 bool lockUnspents =
false;
3266 std::set<int> setSubtractFeeFromOutputs;
3298 if (options.
exists(
"add_inputs")) {
3302 if (options.
exists(
"changeAddress") ||
3303 options.
exists(
"change_address")) {
3304 const std::string change_address_str =
3305 (options.
exists(
"change_address")
3306 ? options[
"change_address"]
3307 : options[
"changeAddress"])
3315 "Change address must be a valid bitcoin address");
3321 if (options.
exists(
"changePosition") ||
3322 options.
exists(
"change_position")) {
3323 change_position = (options.
exists(
"change_position")
3324 ? options[
"change_position"]
3325 : options[
"changePosition"])
3329 const UniValue include_watching_option =
3330 options.
exists(
"include_watching") ? options[
"include_watching"]
3331 : options[
"includeWatching"];
3335 if (options.
exists(
"lockUnspents") ||
3336 options.
exists(
"lock_unspents")) {
3338 (options.
exists(
"lock_unspents") ? options[
"lock_unspents"]
3339 : options[
"lockUnspents"])
3343 if (options.
exists(
"include_unsafe")) {
3345 options[
"include_unsafe"].
get_bool();
3348 if (options.
exists(
"feeRate") || options.
exists(
"fee_rate")) {
3350 options.
exists(
"fee_rate") ? options[
"fee_rate"]
3351 : options[
"feeRate"]));
3355 if (options.
exists(
"subtractFeeFromOutputs") ||
3356 options.
exists(
"subtract_fee_from_outputs")) {
3357 subtractFeeFromOutputs =
3358 (options.
exists(
"subtract_fee_from_outputs")
3359 ? options[
"subtract_fee_from_outputs"]
3360 : options[
"subtractFeeFromOutputs"])
3370 if (tx.
vout.size() == 0) {
3372 "TX must have at least one output");
3375 if (change_position != -1 &&
3376 (change_position < 0 ||
3377 (
unsigned int)change_position > tx.
vout.size())) {
3379 "changePosition out of bounds");
3382 for (
size_t idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3383 int pos = subtractFeeFromOutputs[idx].
getInt<
int>();
3384 if (setSubtractFeeFromOutputs.count(pos)) {
3387 strprintf(
"Invalid parameter, duplicated position: %d", pos));
3392 strprintf(
"Invalid parameter, negative position: %d", pos));
3394 if (pos >=
int(tx.
vout.size())) {
3397 strprintf(
"Invalid parameter, position too large: %d", pos));
3399 setSubtractFeeFromOutputs.insert(pos);
3405 lockUnspents, setSubtractFeeFromOutputs,
3414 "fundrawtransaction",
3415 "If the transaction has no inputs, they will be automatically selected "
3416 "to meet its out value.\n"
3417 "It will add at most one change output to the outputs.\n"
3418 "No existing outputs will be modified unless "
3419 "\"subtractFeeFromOutputs\" is specified.\n"
3420 "Note that inputs which were signed may need to be resigned after "
3421 "completion since in/outputs have been added.\n"
3422 "The inputs added will not be signed, use signrawtransactionwithkey or "
3423 "signrawtransactionwithwallet for that.\n"
3424 "Note that all existing inputs must have their previous output "
3425 "transaction be in the wallet.\n"
3426 "Note that all inputs selected must be of standard form and P2SH "
3428 "in the wallet using importaddress or addmultisigaddress (to calculate "
3430 "You can see whether this is the case by checking the \"solvable\" "
3431 "field in the listunspent output.\n"
3432 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently "
3433 "supported for watch-only\n",
3436 "The hex string of the raw transaction"},
3440 "For backward compatibility: passing in a true instead of an "
3441 "object will result in {\"includeWatching\":true}",
3444 "For a transaction with existing inputs, automatically "
3445 "include more if they are not enough."},
3447 "Include inputs that are not safe to spend (unconfirmed "
3448 "transactions from outside keys).\n"
3449 "Warning: the resulting transaction may become invalid if "
3450 "one of the unsafe inputs disappears.\n"
3451 "If that happens, you will need to fund the transaction with "
3452 "different inputs and republish it."},
3455 "The bitcoin address to receive the change"},
3458 "The index of the change output"},
3461 "true for watch-only wallets, otherwise false"},
3462 "Also select inputs which are watch only.\n"
3463 "Only solvable inputs can be used. Watch-only destinations "
3464 "are solvable if the public key and/or output script was "
3466 "e.g. with 'importpubkey' or 'importmulti' with the "
3467 "'pubkeys' or 'desc' field."},
3469 "Lock selected unspent outputs"},
3472 "not set: makes wallet determine the fee"},
3473 "Set a specific fee rate in " + ticker +
"/kB",
3476 "subtractFeeFromOutputs",
3480 " The fee will be equally "
3481 "deducted from the amount of each specified output.\n"
3482 " Those recipients will "
3483 "receive less bitcoins than you enter in their "
3484 "corresponding amount field.\n"
3485 " If no outputs are "
3486 "specified here, the sender pays the fee.",
3490 "The zero-based output index, before a change output "
3496 .oneline_description =
"options"}},
3503 "The resulting raw transaction (hex-encoded string)"},
3505 "Fee in " + ticker +
" the resulting transaction pays"},
3507 "The position of the added change output, or -1"},
3510 "\nCreate a transaction with no inputs\n" +
3512 "\"[]\" \"{\\\"myaddress\\\":10000}\"") +
3513 "\nAdd sufficient unsigned inputs to meet the output value\n" +
3515 "\nSign the transaction\n" +
3517 "\"fundedtransactionhex\"") +
3518 "\nSend the transaction\n" +
3519 HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")},
3522 std::shared_ptr<CWallet>
const wallet =
3531 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
3533 "TX decode failed");
3537 int change_position;
3543 request.params[1], coin_control);
3547 result.
pushKV(
"fee", fee);
3548 result.
pushKV(
"changepos", change_position);
3557 "signrawtransactionwithwallet",
3558 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
3559 "The second optional argument (may be null) is an array of previous "
3560 "transaction outputs that\n"
3561 "this transaction depends on but may not yet be in the block chain.\n" +
3565 "The transaction hex string"},
3570 "The previous dependent transaction outputs",
3581 "The output number"},
3593 "The signature hash type. Must be one of\n"
3595 " \"NONE|FORKID\"\n"
3596 " \"SINGLE|FORKID\"\n"
3597 " \"ALL|FORKID|ANYONECANPAY\"\n"
3598 " \"NONE|FORKID|ANYONECANPAY\"\n"
3599 " \"SINGLE|FORKID|ANYONECANPAY\""},
3607 "The hex-encoded raw transaction with signature(s)"},
3609 "If the transaction has a complete set of signatures"},
3613 "Script verification errors (if there are any)",
3620 "The hash of the referenced, previous transaction"},
3622 "The index of the output to spent and used as "
3625 "The hex-encoded signature script"},
3627 "Script sequence number"},
3629 "Verification or signing error related to the "
3639 std::shared_ptr<CWallet>
const wallet =
3647 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3649 "TX decode failed");
3657 std::map<COutPoint, Coin> coins;
3658 for (
const CTxIn &txin : mtx.
vin) {
3660 coins[txin.prevout];
3670 "Signature must use SIGHASH_FORKID");
3674 std::map<int, std::string> input_errors;
3689 "Rescan the local blockchain for wallet related transactions.\n"
3690 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3693 "block height where the rescan should start"},
3695 "the last block height that should be scanned"},
3703 "The block height where the rescan started (the requested "
3706 "The height of the last rescanned block. May be null in rare "
3707 "cases if there was a reorg and the call didn't scan any "
3708 "blocks because they were already scanned in the background."},
3714 std::shared_ptr<CWallet>
const wallet =
3724 "Wallet is currently rescanning. Abort "
3725 "existing rescan or wait.");
3728 int start_height = 0;
3729 std::optional<int> stop_height;
3735 if (!request.params[0].isNull()) {
3736 start_height = request.params[0].getInt<
int>();
3737 if (start_height < 0 || start_height > tip_height) {
3739 "Invalid start_height");
3743 if (!request.params[1].isNull()) {
3744 stop_height = request.params[1].getInt<
int>();
3745 if (*stop_height < 0 || *stop_height > tip_height) {
3747 "Invalid stop_height");
3748 }
else if (*stop_height < start_height) {
3751 "stop_height must be greater than start_height");
3757 start_height, stop_height)) {
3761 "Can't rescan beyond pruned data. "
3762 "Use RPC call getblockchaininfo to "
3763 "determine your pruned height.");
3768 "Failed to rescan unavailable blocks likely due to "
3769 "an in-progress assumeutxo background sync. Check "
3770 "logs or getchainstates RPC for assumeutxo "
3771 "background sync progress and try again later.");
3775 "Failed to rescan unavailable blocks, potentially "
3776 "caused by data corruption. If the issue persists you "
3777 "may want to reindex (see -reindex option).");
3786 start_block, start_height, stop_height, reserver,
3794 "Rescan failed. Potentially corrupted data files.");
3801 response.pushKV(
"start_height", start_height);
3816 std::vector<std::vector<uint8_t>> solutions_data;
3827 UniValue wallet_detail = std::visit(*
this, embedded);
3828 subobj.
pushKVs(std::move(wallet_detail));
3833 if (subobj.
exists(
"pubkey")) {
3834 obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3836 obj.
pushKV(
"embedded", std::move(subobj));
3842 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3844 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3845 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3848 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3886 std::unique_ptr<SigningProvider> provider =
nullptr;
3897 const bool verbose) {
3909 "Return information about the given bitcoin address.\n"
3910 "Some of the information will only be present if the address is in the "
3914 "The bitcoin address for which to get information."},
3922 "The bitcoin address validated."},
3924 "The hex-encoded scriptPubKey generated by the address."},
3927 "If the address is watchonly."},
3929 "If we know how to spend coins sent to this address, ignoring "
3930 "the possible lack of private keys."},
3932 "A descriptor for spending coins sent to this address (only "
3936 "If the address was used for change output."},
3938 "The output script type. Only if isscript is true and the "
3939 "redeemscript is known. Possible\n"
3941 "types: nonstandard, pubkey, pubkeyhash, scripthash, "
3942 "multisig, nulldata."},
3944 "The redeemscript for the p2sh address."},
3948 "Array of pubkeys associated with the known redeemscript "
3949 "(only if script is multisig).",
3954 "The number of signatures required to spend multisig output "
3955 "(only if script is multisig)."},
3957 "The hex value of the raw public key for single-key addresses "
3958 "(possibly embedded in P2SH)."},
3962 "Information about the address embedded in P2SH, if "
3963 "relevant and known.",
3966 "Includes all getaddressinfo output fields for the "
3967 "embedded address excluding metadata (timestamp, "
3968 "hdkeypath, hdseedid)\n"
3969 "and relation to the wallet (ismine, iswatchonly)."},
3972 "If the pubkey is compressed."},
3974 "The creation time of the key, if available, expressed in " +
3977 "The HD keypath, if the key is HD and available."},
3979 "The Hash160 of the HD seed."},
3981 true,
"The fingerprint of the master key."},
3984 "Array of labels associated with the address. Currently "
3985 "limited to one label but returned\n"
3986 "as an array to keep the API stable if multiple labels are "
3987 "enabled in the future.",
3990 "Label name (defaults to \"\")."},
3997 std::shared_ptr<CWallet>
const wallet =
4008 wallet->GetChainParams());
4016 ret.
pushKV(
"address", currentAddress);
4021 std::unique_ptr<SigningProvider> provider =
4027 bool solvable = provider &&
IsSolvable(*provider, scriptPubKey);
4028 ret.
pushKV(
"solvable", solvable);
4046 if (
const std::unique_ptr<CKeyMetadata> meta =
4048 ret.
pushKV(
"timestamp", meta->nCreateTime);
4049 if (meta->has_key_origin) {
4052 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
4053 ret.
pushKV(
"hdmasterfingerprint",
4054 HexStr(meta->key_origin.fingerprint));
4065 const auto *address_book_entry =
4067 if (address_book_entry) {
4068 labels.
push_back(address_book_entry->GetLabel());
4070 ret.
pushKV(
"labels", std::move(labels));
4079 "getaddressesbylabel",
4080 "Returns the list of addresses assigned the specified label.\n",
4086 "json object with addresses as keys",
4090 "Information about address",
4093 "Purpose of address (\"send\" for sending address, "
4094 "\"receive\" for receiving address)"},
4101 std::shared_ptr<CWallet>
const wallet =
4114 std::set<std::string> addresses;
4115 for (
const std::pair<const CTxDestination, CAddressBookData> &item :
4116 pwallet->m_address_book) {
4117 if (item.second.IsChange()) {
4120 if (item.second.GetLabel() == label) {
4138 std::string(
"No addresses with label " + label));
4149 "Returns the list of all labels, or labels that are assigned to "
4150 "addresses with a specific purpose.\n",
4153 "Address purpose to list labels for ('send','receive'). An empty "
4154 "string is the same as not providing this argument."},
4163 "\nList labels that have receiving addresses\n" +
4165 "\nList labels that have sending addresses\n" +
4167 "\nAs a JSON-RPC call\n" +
4171 std::shared_ptr<CWallet>
const wallet =
4180 std::string purpose;
4181 if (!request.params[0].isNull()) {
4182 purpose = request.params[0].get_str();
4187 std::set<std::string> label_set;
4188 for (
const std::pair<const CTxDestination, CAddressBookData>
4189 &entry : pwallet->m_address_book) {
4190 if (entry.second.IsChange()) {
4193 if (purpose.empty() || entry.second.purpose == purpose) {
4194 label_set.insert(entry.second.GetLabel());
4199 for (
const std::string &
name : label_set) {
4211 "EXPERIMENTAL warning: this call may be changed in future releases.\n"
4212 "\nSend a transaction.\n",
4217 "A JSON array with outputs (key-value pairs), where none of "
4218 "the keys are duplicated.\n"
4219 "That is, each address can only appear once and there can only "
4220 "be one 'data' object.\n"
4221 "For convenience, a dictionary, which holds the key-value "
4222 "pairs directly, is also accepted.",
4231 "A key-value pair. The key (string) is the "
4232 "bitcoin address, the value (float or string) is "
4244 "A key-value pair. The key must be \"data\", the "
4245 "value is hex-encoded data"},
4256 "If inputs are specified, automatically include more if they "
4259 "Include inputs that are not safe to spend (unconfirmed "
4260 "transactions from outside keys).\n"
4261 "Warning: the resulting transaction may become invalid if "
4262 "one of the unsafe inputs disappears.\n"
4263 "If that happens, you will need to fund the transaction with "
4264 "different inputs and republish it."},
4266 "When false, returns a serialized transaction which will not "
4267 "be added to the wallet or broadcast"},
4270 "The bitcoin address to receive the change"},
4273 "The index of the change output"},
4276 "not set: makes wallet determine the fee"},
4281 "true for watch-only wallets, otherwise false"},
4282 "Also select inputs which are watch only.\n"
4283 "Only solvable inputs can be used. Watch-only destinations "
4284 "are solvable if the public key and/or output script was "
4286 "e.g. with 'importpubkey' or 'importmulti' with the "
4287 "'pubkeys' or 'desc' field."},
4292 "Specify inputs instead of adding them automatically. A "
4293 "JSON array of JSON objects",
4296 "The transaction id"},
4298 "The output number"},
4300 "The sequence number"},
4304 "Raw locktime. Non-0 value also locktime-activates inputs"},
4306 "Lock selected unspent outputs"},
4308 "Always return a PSBT, implies add_to_wallet=false."},
4310 "subtract_fee_from_outputs",
4313 "Outputs to subtract the fee from, specified as integer "
4315 "The fee will be equally deducted from the amount of each "
4316 "specified output.\n"
4317 "Those recipients will receive less bitcoins than you "
4318 "enter in their corresponding amount field.\n"
4319 "If no outputs are specified here, the sender pays the "
4324 "The zero-based output index, before a change output "
4336 "If the transaction has a complete set of signatures"},
4338 "The transaction id for the send. Only 1 transaction is created "
4339 "regardless of the number of addresses."},
4341 "If add_to_wallet is false, the hex-encoded raw transaction with "
4344 "If more signatures are needed, or if add_to_wallet is false, "
4345 "the base64-encoded (partially) signed transaction"}}},
4348 "\nSend with a fee rate of 10 XEC/kB\n" +
4350 "\": 100000}' '{\"fee_rate\": 10}'\n") +
4351 "\nCreate a transaction with a specific input, and return "
4352 "result without adding to wallet or broadcasting to the "
4356 "\": 100000}' '{\"add_to_wallet\": "
4357 "false, \"inputs\": "
4359 "\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b565"
4360 "5e72f463568df1aadf0\", \"vout\":1}]}'")},
4363 std::shared_ptr<CWallet>
const wallet =
4370 const UniValue &options = request.params[1];
4371 if (options.
exists(
"changeAddress")) {
4374 if (options.
exists(
"changePosition")) {
4376 "Use change_position");
4378 if (options.
exists(
"includeWatching")) {
4380 "Use include_watching");
4382 if (options.
exists(
"lockUnspents")) {
4385 if (options.
exists(
"subtractFeeFromOutputs")) {
4387 "Use subtract_fee_from_outputs");
4389 if (options.
exists(
"feeRate")) {
4393 const bool psbt_opt_in =
4397 int change_position;
4399 wallet->GetChainParams(), options[
"inputs"], request.params[0],
4400 options[
"locktime"]);
4408 bool add_to_wallet =
true;
4409 if (options.
exists(
"add_to_wallet")) {
4410 add_to_wallet = options[
"add_to_wallet"].
get_bool();
4417 bool complete =
true;
4418 const auto err = pwallet->
FillPSBT(
4419 psbtx, complete,
SigHashType().withForkId(),
true,
false);
4429 if (psbt_opt_in || !complete || !add_to_wallet) {
4437 std::string err_string;
4440 result.
pushKV(
"txid", tx->GetHash().GetHex());
4441 if (add_to_wallet && !psbt_opt_in) {
4444 result.
pushKV(
"hex", hex);
4447 result.
pushKV(
"complete", complete);
4456 "Set or generate a new HD wallet seed. Non-HD wallets will not be "
4457 "upgraded to being a HD wallet. Wallets that are already\n"
4458 "HD will have a new HD seed set so that new keys added to the keypool "
4459 "will be derived from this new seed.\n"
4460 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after "
4461 "setting the HD wallet seed.\n" +
4463 "Note: This command is only compatible with legacy wallets.\n",
4466 "Whether to flush old unused addresses, including change "
4467 "addresses, from the keypool and regenerate it.\n"
4468 " If true, the next address from "
4469 "getnewaddress and change address from getrawchangeaddress will "
4470 "be from this new seed.\n"
4471 " If false, addresses (including "
4472 "change addresses if the wallet already had HD Chain Split "
4473 "enabled) from the existing\n"
4474 " keypool will be used until it has "
4477 "The WIF private key to use as the new HD seed.\n"
4478 " The seed value can be retrieved "
4479 "using the dumpwallet command. It is the private key marked "
4489 std::shared_ptr<CWallet>
const wallet =
4501 "Cannot set a HD seed to a wallet with "
4502 "private keys disabled");
4511 "Cannot set a HD seed on a non-HD wallet. Use the "
4512 "upgradewallet RPC in order to upgrade a non-HD wallet "
4518 bool flush_key_pool =
true;
4519 if (!request.params[0].isNull()) {
4520 flush_key_pool = request.params[0].get_bool();
4524 if (request.params[1].isNull()) {
4530 "Invalid private key");
4536 "Already have this key (either as an HD seed or "
4537 "as a loose private key)");
4544 if (flush_key_pool) {
4555 "walletprocesspsbt",
4556 "Update a PSBT with input information from our wallet and then sign "
4557 "inputs that we can sign for." +
4561 "The transaction base64 string"},
4563 "Also sign the transaction when updating"},
4565 "The signature hash type to sign with if not specified by "
4566 "the PSBT. Must be one of\n"
4568 " \"NONE|FORKID\"\n"
4569 " \"SINGLE|FORKID\"\n"
4570 " \"ALL|FORKID|ANYONECANPAY\"\n"
4571 " \"NONE|FORKID|ANYONECANPAY\"\n"
4572 " \"SINGLE|FORKID|ANYONECANPAY\""},
4574 "Includes the BIP 32 derivation paths for public keys if we know "
4577 "Also finalize inputs if possible"},
4584 "The base64-encoded partially signed transaction"},
4586 "If the transaction has a complete set of signatures"},
4591 std::shared_ptr<CWallet>
const wallet =
4603 strprintf(
"TX decode failed %s", error));
4610 "Signature must use SIGHASH_FORKID");
4614 bool sign = request.params[1].isNull()
4616 : request.params[1].get_bool();
4617 bool bip32derivs = request.params[3].isNull()
4619 : request.params[3].get_bool();
4620 bool finalize = request.params[4].isNull()
4622 : request.params[4].get_bool();
4623 bool complete =
true;
4624 const auto err = pwallet->
FillPSBT(psbtx, complete, nHashType, sign,
4625 bip32derivs, finalize);
4634 result.
pushKV(
"complete", complete);
4644 "walletcreatefundedpsbt",
4645 "Creates and funds a transaction in the Partially Signed Transaction "
4647 "Implements the Creator and Updater roles.\n",
4653 "Leave empty to add inputs automatically. See add_inputs "
4665 "The output number"},
4668 "depends on the value of the 'locktime' and "
4669 "'options.replaceable' arguments"},
4670 "The sequence number"},
4678 "The outputs (key-value pairs), where none of "
4679 "the keys are duplicated.\n"
4680 "That is, each address can only appear once and there can only "
4681 "be one 'data' object.\n"
4682 "For compatibility reasons, a dictionary, which holds the "
4683 "key-value pairs directly, is also\n"
4684 " accepted as second parameter.",
4693 "A key-value pair. The key (string) is the "
4694 "bitcoin address, the value (float or string) is "
4706 "A key-value pair. The key must be \"data\", the "
4707 "value is hex-encoded data"},
4713 "Raw locktime. Non-0 value also locktime-activates inputs\n"
4714 " Allows this transaction to be "
4715 "replaced by a transaction with higher fees. If provided, it is "
4716 "an error if explicit sequence numbers are incompatible."},
4723 "If inputs are specified, automatically include more if they "
4726 "Include inputs that are not safe to spend (unconfirmed "
4727 "transactions from outside keys).\n"
4728 "Warning: the resulting transaction may become invalid if "
4729 "one of the unsafe inputs disappears.\n"
4730 "If that happens, you will need to fund the transaction with "
4731 "different inputs and republish it."},
4734 "The bitcoin address to receive the change"},
4737 "The index of the change output"},
4740 "true for watch-only wallets, otherwise false"},
4741 "Also select inputs which are watch only"},
4743 "Lock selected unspent outputs"},
4746 "not set: makes wallet determine the fee"},
4747 "Set a specific fee rate in " + ticker +
"/kB",
4750 "subtractFeeFromOutputs",
4753 "The outputs to subtract the fee from.\n"
4754 " The fee will be equally "
4755 "deducted from the amount of each specified output.\n"
4756 " Those recipients will "
4757 "receive less bitcoins than you enter in their "
4758 "corresponding amount field.\n"
4759 " If no outputs are "
4760 "specified here, the sender pays the fee.",
4764 "The zero-based output index, before a change output "
4771 "Includes the BIP 32 derivation paths for public keys if we know "
4779 "The resulting raw transaction (base64-encoded string)"},
4781 "Fee in " + ticker +
" the resulting transaction pays"},
4783 "The position of the added change output, or -1"},
4786 "\nCreate a transaction with no inputs\n" +
4788 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" "
4789 "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
4792 std::shared_ptr<CWallet>
const wallet =
4800 int change_position;
4802 wallet->GetChainParams(), request.params[0], request.params[1],
4809 request.params[3], coin_control);
4815 bool bip32derivs = request.params[4].isNull()
4817 : request.params[4].get_bool();
4818 bool complete =
true;
4821 false, bip32derivs);
4832 result.
pushKV(
"fee", fee);
4833 result.
pushKV(
"changepos", change_position);
4842 "Upgrade the wallet. Upgrades to the latest version if no "
4843 "version number is specified\n"
4844 "New keys may be generated and a new wallet backup will need to "
4847 "The version number to upgrade to. Default is the latest "
4854 std::shared_ptr<CWallet>
const wallet =
4864 if (!request.params[0].isNull()) {
4865 version = request.params[0].getInt<
int>();
4880 "createwallettransaction",
4881 "Create a transaction sending an amount to a given address.\n" +
4885 "The bitcoin address to send to."},
4892 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
4894 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 100000")},
4897 std::shared_ptr<CWallet>
const wallet =
4907 pwallet->BlockUntilSyncedToCurrentChain();
4914 const std::string address = request.params[0].get_str();
4915 address_amounts.
pushKV(address, request.params[1]);
4918 std::vector<CRecipient> recipients;
4920 wallet->GetChainParams());
4923 return SendMoney(pwallet, coin_control, recipients, {},
false);
4962 {
"wallet",
send, },
CScriptID ToScriptID(const ScriptHash &script_hash)
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
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.
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.
const CScript redeemScript
#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.
Fee rate in satoshis per virtualbyte: Amount / vB the feerate is represented internally as FeeFrac.
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.
bool IsValid() const
Check whether this private key is valid.
const uint8_t * begin() const
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 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)
A reference to a CScript: the Hash160 of its serialization.
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
SteadyClock::duration ScanningDuration() const
interfaces::Chain & chain() const
Interface for accessing chain state.
bool IsLegacy() const
Determine if we are a legacy wallet.
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
OutputType m_default_address_type
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
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.
Double ended buffer combining vector and stream-like interfaces.
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)
auto Arg(size_t i) const
Helper to get a required or default-valued request argument.
auto MaybeArg(size_t i) const
Helper to get an optional request argument.
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
virtual std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const
Signature hash type wrapper class.
An interface to be implemented by keystores that support signing.
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
A Span is an object that can refer to a contiguous sequence of objects.
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const UniValue & get_obj() const
void pushKVs(UniValue obj)
const std::vector< std::string > & getKeys() const
void pushKVEnd(std::string key, UniValue val)
const UniValue & get_array() const
bool exists(const std::string &key) const
void pushKV(std::string key, UniValue val)
RAII object to check and reserve a wallet rescan.
constexpr bool IsNull() const
std::string GetHex() const
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual bool findBlock(const BlockHash &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
virtual bool havePruned()=0
Check if any block has been pruned.
virtual void findCoins(std::map< COutPoint, Coin > &coins)=0
Look up unspent output information.
virtual bool hasAssumedValidChain()=0
Return true if an assumed-valid chain is in use.
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 std::optional< int > getPruneHeight()=0
Get the current prune height.
Helper for findBlock to selectively return pieces of block data.
const Config & GetConfig()
std::string EncodeHexTx(const CTransaction &tx)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
@ SHOW_DETAILS
Include TXID, inputs, outputs, and other common block's transaction information.
SigHashType ParseSighashString(const UniValue &sighash)
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex=true, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS, std::function< bool(const CTxOut &)> is_change_func={})
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)
util::Result< CTxDestination > GetNewDestination(const OutputType type, const std::string &label)
util::Result< CTxDestination > GetNewChangeDestination(const OutputType type)
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)
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool TopUpKeyPool(unsigned int kpSize=0)
int64_t GetOldestKeyPoolTime() const
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.
std::optional< common::PSBTError > FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=true, bool finalize=true) const
Fills out a PSBT with information from the wallet.
void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(void SetWalletFlag(uint64_t flags)
Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function...
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.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
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)
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)
bilingual_str ErrorString(const Result< T > &result)
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
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.
std::vector< RPCResult > DecodeTxDoc(const std::string &txid_field_doc, bool wallet)
Explain the UniValue "decoded" transaction object, may include extra fields if processed by wallet.
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.
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
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)
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, Amount &nFee, const isminefilter &filter)
std::map< CTxDestination, Amount > GetAddressBalances(const CWallet &wallet)
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)
Amount AmountFromValue(const UniValue &value)
UniValue JSONRPCPSBTError(PSBTError err)
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()
Span< const CRPCCommand > GetWalletRPCCommands()
static RPCHelpMan listunspent()
static RPCHelpMan getrawchangeaddress()
static RPCHelpMan walletprocesspsbt()
static void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx, int nMinDepth, bool fLong, Vec &ret, const isminefilter &filter_ismine, const std::string *filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
List transactions based on the given criteria.
static RPCHelpMan fundrawtransaction()
static RPCHelpMan gettransaction()
static UniValue ListReceived(const Config &config, const CWallet *const pwallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static UniValue AddressBookDataToJSON(const CAddressBookData &data, const bool verbose)
Convert CAddressBookData to JSON record.
static RPCHelpMan listaddressgroupings()
static void WalletTxToJSON(const CWallet &wallet, const CWalletTx &wtx, UniValue &entry) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan addmultisigaddress()
RPCHelpMan getaddressesbylabel()
static RPCHelpMan listlockunspent()
static Amount GetReceived(const CWallet &wallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan getunconfirmedbalance()
static RPCHelpMan listwallets()
RPCHelpMan rescanblockchain()
static RPCHelpMan upgradewallet()
static RPCHelpMan unloadwallet()
static RPCHelpMan walletcreatefundedpsbt()
static RPCHelpMan getbalances()
static RPCHelpMan listwalletdir()
static RPCHelpMan keypoolrefill()
bool HaveKey(const SigningProvider &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
RPCHelpMan getaddressinfo()
static std::vector< RPCResult > TransactionDescriptionString()
static RPCHelpMan getwalletinfo()
static RPCHelpMan lockunspent()
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 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
static std::string ToString(const CService &ip)
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.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< uint8_t > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
util::Result< CreatedTransactionResult > CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, int change_pos, 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.
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::@19 status
static std::string getTicker()
SecureString create_passphrase
A version of CTransaction with the PSBT format.
@ OBJ_USER_KEYS
Special type where the user must set the keys e.g.
@ STR_HEX
Special type that is a STR with only hex chars.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
@ OBJ_NAMED_PARAMS
Special type that behaves almost exactly like OBJ, defining an options object with a list of pre-defi...
std::string DefaultHint
Hint for default value.
@ OMITTED
Optional argument for which the default value is omitted from help text for one of two reasons:
std::string oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
bool also_positional
If set allows a named-parameter field in an OBJ_NAMED_PARAM options object to have the same name as a...
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ ARR_FIXED
Special array that has a fixed number of entries.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
A TxId is the identifier of a transaction.
Wrapper for UniValue::VType, which includes typeAny: used to denote don't care type.
WalletContext struct containing references to state shared between CWallet instances,...
std::vector< uint256 > txids
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
const UniValue NullUniValue
std::string EncodeBase64(Span< const uint8_t > input)
bool IsHex(std::string_view str)
Returns true if each character in str is a hex character, and has an even number of hex digits.
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
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)
bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
void HandleWalletError(const std::shared_ptr< CWallet > wallet, DatabaseStatus &status, bilingual_str &error)
bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &pwallet)
Used by RPC commands that have an include_watchonly parameter.
WalletContext & EnsureWalletContext(const std::any &context)
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
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
void WaitForDeleteWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly delete the wallet.
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
std::shared_ptr< CWallet > CreateWallet(WalletContext &context, const std::string &name, std::optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
std::shared_ptr< CWallet > LoadWallet(WalletContext &context, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
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,...