6#include <chainparams.h>
43#include <event2/http.h>
65 entry.pushKV(
"confirmations",
confirms);
66 if (wtx.IsCoinBase()) {
67 entry.pushKV(
"generated",
true);
70 entry.pushKV(
"blockhash", wtx.m_confirm.hashBlock.GetHex());
71 entry.pushKV(
"blockheight", wtx.m_confirm.block_height);
72 entry.pushKV(
"blockindex", wtx.m_confirm.nIndex);
76 entry.pushKV(
"blocktime", block_time);
81 entry.pushKV(
"txid", hash.
GetHex());
86 entry.pushKV(
"walletconflicts",
conflicts);
87 entry.pushKV(
"time", wtx.GetTxTime());
88 entry.pushKV(
"timereceived",
int64_t{wtx.nTimeReceived});
90 for (
const std::pair<const std::string, std::string> &item : wtx.mapValue) {
91 entry.pushKV(item.first, item.second);
98 "Returns a new Bitcoin address for receiving payments.\n"
99 "If 'label' is specified, it is added to the address book \n"
100 "so payments received with the address will be associated with "
104 "The label name for the address to be linked to. If not provided, "
105 "the default label \"\" is used. It can also be set to the empty "
106 "string \"\" to represent the default label. The label does not "
107 "need to exist, it will be created if there is no label by the "
111 "The address type to use. Options are \"legacy\"."},
118 std::shared_ptr<CWallet>
const wallet =
128 "Error: This wallet has no available keys");
134 if (!request.params[0].isNull()) {
139 if (!request.params[1].isNull()) {
144 request.params[1].get_str()));
161 "getrawchangeaddress",
162 "Returns a new Bitcoin address, for receiving change.\n"
163 "This is for use with raw transactions, NOT normal use.\n",
170 std::shared_ptr<CWallet>
const wallet =
181 "Error: This wallet has no available keys");
186 if (!request.params[0].isNull()) {
191 request.params[0].get_str()));
208 "Sets the label associated with the given address.\n",
211 "The bitcoin address to be associated with a label."},
213 "The label to assign to the address."},
218 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") +
221 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")},
224 std::shared_ptr<CWallet>
const wallet =
234 wallet->GetChainParams());
237 "Invalid Bitcoin address");
242 if (pwallet->
IsMine(dest)) {
255 std::vector<CRecipient> &recipients,
263 std::string(
"Invalid Bitcoin address: ") +
270 std::string(
"Invalid parameter, duplicated address: ") +
281 if (addr.
get_str() == address) {
287 recipients.push_back(recipient);
313 return tx->GetId().GetHex();
322 "The bitcoin address to send to."},
326 "A comment used to store what the transaction is for.\n"
327 " This is not part of the "
328 "transaction, just kept in your wallet."},
331 "A comment to store the name of the person or organization\n"
332 " to which you're sending the "
333 "transaction. This is not part of the \n"
334 " transaction, just kept in "
338 "The fee will be deducted from the amount being sent.\n"
339 " The recipient will receive "
340 "less bitcoins than you enter in the amount field."},
342 "(only available if avoid_reuse wallet flag is set) Avoid "
343 "spending from dirty addresses; addresses are considered\n"
344 " dirty if they have previously "
345 "been used in a transaction."},
350 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
351 HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
352 "dd\" 100000 \"donation\" \"seans "
355 "Jvaydd\" 100000 \"\" \"\" true") +
357 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
358 "dd\", 100000, \"donation\", \"seans "
362 std::shared_ptr<CWallet>
const wallet =
372 pwallet->BlockUntilSyncedToCurrentChain();
378 if (!request.params[2].isNull() &&
379 !request.params[2].get_str().empty()) {
380 mapValue[
"comment"] = request.params[2].get_str();
382 if (!request.params[3].isNull() &&
383 !request.params[3].get_str().empty()) {
384 mapValue[
"to"] = request.params[3].get_str();
387 bool fSubtractFeeFromAmount =
false;
388 if (!request.params[4].isNull()) {
389 fSubtractFeeFromAmount = request.params[4].get_bool();
402 const std::string address = request.params[0].get_str();
405 if (fSubtractFeeFromAmount) {
409 std::vector<CRecipient> recipients;
411 wallet->GetChainParams());
420 "listaddressgroupings",
421 "Lists groups of addresses which have had their common ownership\n"
422 "made public by common use as inputs or as the resulting change\n"
423 "in past transactions\n",
438 "The bitcoin address"},
450 std::shared_ptr<CWallet>
const wallet =
460 pwallet->BlockUntilSyncedToCurrentChain();
465 std::map<CTxDestination, Amount>
balances =
467 for (
const std::set<CTxDestination> &
grouping :
505 "Invalid Bitcoin address");
516 if (!params[1].isNull()) {
522 for (
const std::pair<const TxId, CWalletTx> &
wtx_pair :
wallet.mapWallet) {
528 for (
const CTxOut &txout : wtx.
tx->vout) {
532 amount += txout.nValue;
542 "getreceivedbyaddress",
543 "Returns the total amount received by the given address in "
544 "transactions with at least minconf confirmations.\n",
547 "The bitcoin address for transactions."},
549 "Only include transactions confirmed at least this many times."},
553 " received at this address."},
555 "\nThe amount from transactions with at least 1 confirmation\n" +
557 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
558 "\nThe amount including unconfirmed transactions, zero "
561 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
562 "\nThe amount with at least 6 confirmations\n" +
564 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
565 "\nAs a JSON-RPC call\n" +
567 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")},
570 std::shared_ptr<CWallet>
const wallet =
580 pwallet->BlockUntilSyncedToCurrentChain();
592 "getreceivedbylabel",
593 "Returns the total amount received by addresses with <label> in "
594 "transactions with at least [minconf] confirmations.\n",
597 "The selected label, may be the default label using \"\"."},
599 "Only include transactions confirmed at least this many times."},
603 " received for this label."},
604 RPCExamples{
"\nAmount received by the default label with at least 1 "
607 "\nAmount received at the tabby label including "
608 "unconfirmed amounts with zero confirmations\n" +
610 "\nThe amount with at least 6 confirmations\n" +
612 "\nAs a JSON-RPC call\n" +
616 std::shared_ptr<CWallet>
const wallet =
626 pwallet->BlockUntilSyncedToCurrentChain();
639 "Returns the total available balance.\n"
640 "The available balance is what the wallet considers currently "
641 "spendable, and is\n"
642 "thus affected by options which limit spendability such as "
643 "-spendzeroconfchange.\n",
646 "Remains for backward compatibility. Must be excluded or set to "
649 "Only include transactions confirmed at least this many times."},
652 "true for watch-only wallets, otherwise false"},
653 "Also include balance in watch-only addresses (see "
656 "(only available if avoid_reuse wallet flag is set) Do not "
657 "include balance in dirty outputs; addresses are considered dirty "
658 "if they have previously been used in a transaction."},
662 " received for this wallet."},
664 "\nThe total amount in the wallet with 0 or more confirmations\n" +
666 "\nThe total amount in the wallet with at least 6 confirmations\n" +
667 HelpExampleCli(
"getbalance",
"\"*\" 6") +
"\nAs a JSON-RPC call\n" +
671 std::shared_ptr<CWallet>
const wallet =
681 pwallet->BlockUntilSyncedToCurrentChain();
689 "dummy first argument must be excluded or set to \"*\".");
693 if (!request.params[1].isNull()) {
694 min_depth = request.params[1].getInt<
int>();
705 ?
bal.m_watchonly_trusted
713 "getunconfirmedbalance",
714 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
720 std::shared_ptr<CWallet>
const wallet =
730 pwallet->BlockUntilSyncedToCurrentChain();
742 "Send multiple times. Amounts are double-precision "
743 "floating point numbers." +
747 "Must be set to \"\" for backwards compatibility.",
749 .oneline_description =
"\"\""}},
754 "The addresses and amounts",
757 "The bitcoin address is the key, the numeric amount (can "
763 "Only use the balance confirmed at least this many times."},
771 " The fee will be equally deducted "
772 "from the amount of each selected address.\n"
773 " Those recipients will receive less "
774 "bitcoins than you enter in their corresponding amount field.\n"
775 " If no addresses are specified "
776 "here, the sender pays the fee.",
779 "Subtract fee from this address"},
784 "The transaction id for the send. Only 1 transaction is "
785 "created regardless of the number of addresses."},
787 "\nSend two amounts to two different addresses:\n" +
791 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
793 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
795 "\nSend two amounts to two different addresses setting the "
796 "confirmation and comment:\n" +
800 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
802 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
805 "\nSend two amounts to two different addresses, subtract fee "
810 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
812 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
814 "\"[\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\","
815 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\"]"
817 "\nAs a JSON-RPC call\n" +
821 "{\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\":0.01,"
822 "\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\":0.02}, "
827 std::shared_ptr<CWallet>
const wallet =
837 pwallet->BlockUntilSyncedToCurrentChain();
841 if (!request.params[0].isNull() &&
842 !request.params[0].get_str().empty()) {
844 "Dummy value must be set to \"\"");
849 if (!request.params[3].isNull() &&
850 !request.params[3].get_str().empty()) {
851 mapValue[
"comment"] = request.params[3].
get_str();
855 if (!request.params[4].isNull()) {
859 std::vector<CRecipient> recipients;
861 wallet->GetChainParams());
865 std::move(mapValue));
872 "addmultisigaddress",
873 "Add an nrequired-to-sign multisignature address to the wallet. "
874 "Requires a new wallet backup.\n"
875 "Each key is a Bitcoin address or hex-encoded public key.\n"
876 "This functionality is only intended for use with non-watchonly "
878 "See `importaddress` for watchonly p2sh address support.\n"
879 "If 'label' is specified (DEPRECATED), assign address to that label.\n"
880 "Note: This command is only compatible with legacy wallets.\n",
883 "The number of required signatures out of the n keys or "
889 "The bitcoin addresses or hex-encoded public keys",
892 "bitcoin address or hex-encoded public key"},
896 "A label to assign the addresses to."},
903 "The value of the new multisig address"},
905 "The string value of the hex-encoded redemption script"},
907 "The descriptor for this multisig"},
910 "\nAdd a multisig address from 2 addresses\n" +
913 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
914 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
915 "\nAs a JSON-RPC call\n" +
918 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
919 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")},
922 std::shared_ptr<CWallet>
const wallet =
935 if (!request.params[2].isNull()) {
939 int required = request.params[0].getInt<
int>();
943 std::vector<CPubKey> pubkeys;
965 std::unique_ptr<Descriptor> descriptor =
971 result.
pushKV(
"descriptor", descriptor->ToString());
979 int nConf{std::numeric_limits<int>::max()};
990 if (!params[0].isNull()) {
996 if (!params[1].isNull()) {
1007 if (!
by_label && params.size() > 3) {
1009 pwallet->GetChainParams())) {
1011 "address_filter parameter was invalid");
1019 std::map<CTxDestination, tallyitem>
mapTally;
1020 for (
const std::pair<const TxId, CWalletTx> &
pairWtx : pwallet->mapWallet) {
1027 int nDepth = pwallet->GetTxDepthInMainChain(wtx);
1032 for (
const CTxOut &txout : wtx.
tx->vout) {
1043 if (!(
mine & filter)) {
1063 auto start = pwallet->m_address_book.begin();
1064 auto end = pwallet->m_address_book.end();
1069 end = std::next(start);
1074 if (
item_it->second.IsChange()) {
1078 const std::string &label =
item_it->second.GetLabel();
1079 std::map<CTxDestination, tallyitem>::iterator it =
1086 int nConf = std::numeric_limits<int>::max();
1087 bool fIsWatchonly =
false;
1089 nAmount = (*it).second.nAmount;
1090 nConf = (*it).second.nConf;
1091 fIsWatchonly = (*it).second.fIsWatchonly;
1098 _item.fIsWatchonly = fIsWatchonly;
1102 obj.pushKV(
"involvesWatchonly",
true);
1105 obj.pushKV(
"amount", nAmount);
1106 obj.pushKV(
"confirmations",
1107 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1108 obj.pushKV(
"label", label);
1122 Amount nAmount = entry.second.nAmount;
1123 int nConf = entry.second.nConf;
1125 if (entry.second.fIsWatchonly) {
1126 obj.pushKV(
"involvesWatchonly",
true);
1128 obj.pushKV(
"amount", nAmount);
1129 obj.pushKV(
"confirmations",
1130 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1131 obj.pushKV(
"label", entry.first);
1141 "listreceivedbyaddress",
1142 "List balances by receiving address.\n",
1145 "The minimum number of confirmations before payments are "
1148 "Whether to include addresses that haven't received any "
1152 "true for watch-only wallets, otherwise false"},
1153 "Whether to include watch-only addresses (see 'importaddress')."},
1156 "If present, only return information on this address."},
1168 "Only returns true if imported addresses were involved "
1173 " received by the address"},
1175 "The number of confirmations of the most recent "
1176 "transaction included"},
1178 "The label of the receiving address. The default label "
1185 "The ids of transactions received with the address"},
1194 "listreceivedbyaddress",
1195 "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")},
1198 std::shared_ptr<CWallet>
const wallet =
1208 pwallet->BlockUntilSyncedToCurrentChain();
1212 return ListReceived(config, pwallet, request.params,
false);
1219 "listreceivedbylabel",
1220 "List received transactions by label.\n",
1223 "The minimum number of confirmations before payments are "
1226 "Whether to include labels that haven't received any payments."},
1229 "true for watch-only wallets, otherwise false"},
1230 "Whether to include watch-only addresses (see 'importaddress')."},
1242 "Only returns true if imported addresses were involved "
1245 "The total amount received by addresses with this label"},
1247 "The number of confirmations of the most recent "
1248 "transaction included"},
1250 "The label of the receiving address. The default label "
1259 std::shared_ptr<CWallet>
const wallet =
1269 pwallet->BlockUntilSyncedToCurrentChain();
1273 return ListReceived(config, pwallet, request.params,
true);
1317 entry.
pushKV(
"involvesWatchonly",
true);
1320 entry.
pushKV(
"category",
"send");
1321 entry.
pushKV(
"amount", -s.amount);
1323 pwallet->FindAddressBookEntry(s.destination);
1327 entry.
pushKV(
"vout", s.vout);
1328 entry.
pushKV(
"fee", -1 * nFee);
1332 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1333 ret.push_back(entry);
1339 pwallet->GetTxDepthInMainChain(wtx) >=
nMinDepth) {
1343 pwallet->FindAddressBookEntry(r.destination);
1353 entry.
pushKV(
"involvesWatchonly",
true);
1356 if (wtx.IsCoinBase()) {
1357 if (pwallet->GetTxDepthInMainChain(wtx) < 1) {
1358 entry.
pushKV(
"category",
"orphan");
1359 }
else if (pwallet->IsTxImmatureCoinBase(wtx)) {
1360 entry.
pushKV(
"category",
"immature");
1362 entry.
pushKV(
"category",
"generate");
1365 entry.
pushKV(
"category",
"receive");
1367 entry.
pushKV(
"amount", r.amount);
1369 entry.
pushKV(
"label", label);
1371 entry.
pushKV(
"vout", r.vout);
1375 ret.push_back(entry);
1383 "The number of confirmations for the transaction. Negative "
1384 "confirmations means the\n"
1385 "transaction conflicted that many blocks ago."},
1387 "Only present if transaction only input is a coinbase one."},
1389 "Only present if we consider transaction to be trusted and so safe to "
1392 "The block hash containing the transaction."},
1394 "The block height containing the transaction."},
1396 "The index of the transaction in the block that includes it."},
1402 "Conflicting transaction ids.",
1411 "If a comment is associated with the transaction, only present if not "
1420 "If a label name is provided, this will return only incoming "
1421 "transactions paying to addresses with the specified label.\n"
1422 "\nReturns up to 'count' most recent transactions skipping the first "
1423 "'from' transactions.\n",
1427 "If set, should be a valid label name to return only incoming "
1428 "transactions with the specified label, or \"*\" to disable "
1429 "filtering and return all transactions."},
1431 "The number of transactions to return"},
1433 "The number of transactions to skip"},
1436 "true for watch-only wallets, otherwise false"},
1437 "Include transactions to watch-only addresses (see "
1438 "'importaddress')"},
1446 Cat(
Cat<std::vector<RPCResult>>(
1449 "Only returns true if imported addresses were "
1450 "involved in transaction."},
1452 "The bitcoin address of the transaction."},
1454 "The transaction category.\n"
1455 "\"send\" Transactions sent.\n"
1456 "\"receive\" Non-coinbase "
1457 "transactions received.\n"
1458 "\"generate\" Coinbase transactions "
1459 "received with more than 100 confirmations.\n"
1460 "\"immature\" Coinbase transactions "
1461 "received with 100 or fewer confirmations.\n"
1462 "\"orphan\" Orphaned coinbase "
1463 "transactions received."},
1465 "The amount in " + ticker +
1466 ". This is negative for the 'send' category, "
1468 "for all other categories"},
1470 "A comment for the address/transaction, if any"},
1473 "The amount of the fee in " + ticker +
1474 ". This is negative and only available for "
1476 "'send' category of transactions."},
1481 "'true' if the transaction has been abandoned "
1482 "(inputs are respendable). Only available for the \n"
1483 "'send' category of transactions."},
1486 RPCExamples{
"\nList the most recent 10 transactions in the systems\n" +
1488 "\nList transactions 100 to 120\n" +
1490 "\nAs a JSON-RPC call\n" +
1494 std::shared_ptr<CWallet>
const wallet =
1504 pwallet->BlockUntilSyncedToCurrentChain();
1507 if (!request.params[0].isNull() &&
1508 request.params[0].get_str() !=
"*") {
1513 "Label argument must be a valid label name or \"*\".");
1517 if (!request.params[1].isNull()) {
1518 nCount = request.params[1].getInt<
int>();
1522 if (!request.params[2].isNull()) {
1523 nFrom = request.params[2].getInt<
int>();
1538 std::vector<UniValue>
ret;
1545 for (CWallet::TxItems::const_reverse_iterator it =
1579 "Get all transactions in blocks since block [blockhash], or all "
1580 "transactions if omitted.\n"
1581 "If \"blockhash\" is no longer a part of the main chain, transactions "
1582 "from the fork point onward are included.\n"
1583 "Additionally, if include_removed is set, transactions affecting the "
1584 "wallet which were removed are returned in the \"removed\" array.\n",
1588 "If set, the block hash to list transactions since, otherwise "
1589 "list all transactions."},
1591 "Return the nth block hash from the main chain. e.g. 1 would mean "
1592 "the best block hash. Note: this is not used as a filter, but "
1593 "only affects [lastblock] in the return value"},
1596 "true for watch-only wallets, otherwise false"},
1597 "Include transactions to watch-only addresses (see "
1598 "'importaddress')"},
1600 "Show transactions that were removed due to a reorg in the "
1601 "\"removed\" array\n"
1603 "guaranteed to work on pruned nodes)"},
1615 Cat(
Cat<std::vector<RPCResult>>(
1618 "Only returns true if imported addresses "
1619 "were involved in transaction."},
1621 "The bitcoin address of the transaction."},
1623 "The transaction category.\n"
1624 "\"send\" Transactions "
1626 "\"receive\" Non-coinbase "
1627 "transactions received.\n"
1628 "\"generate\" Coinbase "
1629 "transactions received with more than 100 "
1631 "\"immature\" Coinbase "
1632 "transactions received with 100 or fewer "
1634 "\"orphan\" Orphaned "
1635 "coinbase transactions received."},
1637 "The amount in " + ticker +
1638 ". This is negative for the 'send' "
1639 "category, and is positive\n"
1640 "for all other categories"},
1644 "The amount of the fee in " + ticker +
1645 ". This is negative and only available "
1647 "'send' category of transactions."},
1652 "'true' if the transaction has been abandoned "
1653 "(inputs are respendable). Only available for "
1655 "'send' category of transactions."},
1657 "If a comment is associated with the "
1660 "A comment for the address/transaction, if any"},
1662 "If a comment to is associated with the "
1668 "<structure is the same as \"transactions\" above, only "
1669 "present if include_removed=true>\n"
1670 "Note: transactions that were re-added in the active chain "
1671 "will appear as-is in this array, and may thus have a "
1672 "positive confirmation count.",
1677 "The hash of the block (target_confirmations-1) from the best "
1678 "block on the main chain, or the genesis hash if the "
1679 "referenced block does not exist yet. This is typically used "
1680 "to feed back into listsinceblock the next time you call it. "
1681 "So you would generally use a target_confirmations of say 6, "
1682 "so you will be continually re-notified of transactions until "
1683 "they've reached 6 confirmations plus any new ones"},
1687 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1688 "7d38571037cdb1a57f663ad\" 6") +
1690 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1691 "7d38571037cdb1a57f663ad\", 6")},
1694 std::shared_ptr<CWallet>
const pwallet =
1705 wallet.BlockUntilSyncedToCurrentChain();
1711 std::optional<int> height;
1720 if (!request.params[0].isNull() &&
1721 !request.params[0].get_str().empty()) {
1725 if (!
wallet.chain().findCommonAncestor(
1734 if (!request.params[1].isNull()) {
1739 "Invalid parameter");
1748 (request.params[3].isNull() || request.params[3].get_bool());
1750 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1754 for (
const std::pair<const TxId, CWalletTx> &
pairWtx :
1758 if (depth == -1 ||
wallet.GetTxDepthInMainChain(tx) < depth) {
1773 "Can't read block from disk");
1776 auto it =
wallet.mapWallet.find(tx->GetId());
1777 if (it !=
wallet.mapWallet.end()) {
1794 wallet.GetLastBlockHash(),
1814 "Get detailed information about in-wallet transaction <txid>\n",
1817 "The transaction id"},
1820 "true for watch-only wallets, otherwise false"},
1821 "Whether to include watch-only addresses in balance calculation "
1824 "Whether to include a `decoded` field containing the decoded "
1825 "transaction (equivalent to RPC decoderawtransaction)"},
1829 Cat(
Cat<std::vector<RPCResult>>(
1832 "The amount in " + ticker},
1834 "The amount of the fee in " + ticker +
1835 ". This is negative and only available for the\n"
1836 "'send' category of transactions."},
1849 "Only returns true if imported addresses were "
1850 "involved in transaction."},
1852 "The bitcoin address involved in the "
1855 "The transaction category.\n"
1856 "\"send\" Transactions sent.\n"
1857 "\"receive\" Non-coinbase "
1858 "transactions received.\n"
1859 "\"generate\" Coinbase "
1860 "transactions received with more than 100 "
1862 "\"immature\" Coinbase "
1863 "transactions received with 100 or fewer "
1865 "\"orphan\" Orphaned coinbase "
1866 "transactions received."},
1868 "The amount in " + ticker},
1870 "A comment for the address/transaction, if any"},
1873 "The amount of the fee in " + ticker +
1874 ". This is negative and only available for "
1876 "'send' category of transactions."},
1878 "'true' if the transaction has been abandoned "
1879 "(inputs are respendable). Only available for "
1881 "'send' category of transactions."},
1885 "Raw data for transaction"},
1888 "Optional, the decoded transaction (only present when "
1889 "`verbose` is passed)",
1892 "Equivalent to the RPC decoderawtransaction method, "
1893 "or the RPC getrawtransaction method when `verbose` "
1898 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1899 "5cf302fc80e9d5fbf5d48d\"") +
1901 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1902 "5cf302fc80e9d5fbf5d48d\" true") +
1904 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1905 "5cf302fc80e9d5fbf5d48d\" false true") +
1907 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1908 "5cf302fc80e9d5fbf5d48d\"")},
1911 std::shared_ptr<CWallet>
const wallet =
1921 pwallet->BlockUntilSyncedToCurrentChain();
1932 bool verbose = request.params[2].isNull()
1934 : request.params[2].get_bool();
1937 auto it = pwallet->mapWallet.find(txid);
1938 if (it == pwallet->mapWallet.end()) {
1940 "Invalid or non-wallet transaction id");
1953 entry.
pushKV(
"fee", nFee);
1961 entry.
pushKV(
"details", details);
1980 "abandontransaction",
1981 "Mark in-wallet transaction <txid> as abandoned\n"
1982 "This will mark this transaction and all its in-wallet descendants as "
1983 "abandoned which will allow\n"
1984 "for their inputs to be respent. It can be used to replace \"stuck\" "
1985 "or evicted transactions.\n"
1986 "It only works on transactions which are not included in a block and "
1987 "are not currently in the mempool.\n"
1988 "It has no effect on transactions which are already abandoned.\n",
1991 "The transaction id"},
1995 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1996 "5cf302fc80e9d5fbf5d48d\"") +
1998 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1999 "5cf302fc80e9d5fbf5d48d\"")},
2002 std::shared_ptr<CWallet>
const wallet =
2012 pwallet->BlockUntilSyncedToCurrentChain();
2018 if (!pwallet->mapWallet.count(txid)) {
2020 "Invalid or non-wallet transaction id");
2025 "Transaction not eligible for abandonment");
2039 "The new keypool size"},
2046 std::shared_ptr<CWallet>
const wallet =
2057 "Error: Private keys are disabled for this wallet");
2065 if (!request.params[0].isNull()) {
2066 if (request.params[0].getInt<
int>() < 0) {
2069 "Invalid parameter, expected valid size.");
2071 kpSize = (
unsigned int)request.params[0].getInt<
int>();
2079 "Error refreshing keypool.");
2090 "Updates list of temporarily unspendable outputs.\n"
2091 "Temporarily lock (unlock=false) or unlock (unlock=true) specified "
2092 "transaction outputs.\n"
2093 "If no transaction outputs are specified when unlocking then all "
2094 "current locked transaction outputs are unlocked.\n"
2095 "A locked transaction output will not be chosen by automatic coin "
2096 "selection, when spending bitcoins.\n"
2097 "Manually selected coins are automatically unlocked.\n"
2098 "Locks are stored in memory only. Nodes start with zero locked "
2099 "outputs, and the locked output list\n"
2100 "is always cleared (by virtue of process exit) when a node stops or "
2102 "Also see the listunspent call\n",
2105 "Whether to unlock (true) or lock (false) the specified "
2111 "The transaction outputs and within each, txid (string) vout "
2123 "The output number"},
2130 "Whether the command was successful or not"},
2132 "\nList the unspent transactions\n" +
2134 "\nLock an unspent transaction\n" +
2137 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2138 "b764ed838b5655e72f463568df1aadf0\\\""
2139 ",\\\"vout\\\":1}]\"") +
2140 "\nList the locked transactions\n" +
2142 "\nUnlock the transaction again\n" +
2145 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2146 "b764ed838b5655e72f463568df1aadf0\\\""
2147 ",\\\"vout\\\":1}]\"") +
2148 "\nAs a JSON-RPC call\n" +
2151 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2152 "b764ed838b5655e72f463568df1aadf0\\\""
2153 ",\\\"vout\\\":1}]\"")},
2156 std::shared_ptr<CWallet>
const wallet =
2166 pwallet->BlockUntilSyncedToCurrentChain();
2170 bool fUnlock = request.params[0].get_bool();
2172 if (request.params[1].isNull()) {
2183 std::vector<COutPoint> outputs;
2198 "Invalid parameter, vout cannot be negative");
2202 const auto it = pwallet->mapWallet.find(txid);
2203 if (it == pwallet->mapWallet.end()) {
2206 "Invalid parameter, unknown transaction");
2211 if (output.
GetN() >=
trans.tx->vout.size()) {
2214 "Invalid parameter, vout index out of bounds");
2217 if (pwallet->
IsSpent(output)) {
2220 "Invalid parameter, expected unspent output");
2227 "Invalid parameter, expected locked output");
2233 "Invalid parameter, output already locked");
2236 outputs.push_back(output);
2240 for (
const COutPoint &output : outputs) {
2256 "Returns list of temporarily unspendable outputs.\n"
2257 "See the lockunspent call to lock and unlock transactions for "
2269 "The transaction id locked"},
2274 "\nList the unspent transactions\n" +
2276 "\nLock an unspent transaction\n" +
2279 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2280 "b764ed838b5655e72f463568df1aadf0\\\""
2281 ",\\\"vout\\\":1}]\"") +
2282 "\nList the locked transactions\n" +
2284 "\nUnlock the transaction again\n" +
2287 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2288 "b764ed838b5655e72f463568df1aadf0\\\""
2289 ",\\\"vout\\\":1}]\"") +
2290 "\nAs a JSON-RPC call\n" +
HelpExampleRpc(
"listlockunspent",
"")},
2293 std::shared_ptr<CWallet>
const wallet =
2302 std::vector<COutPoint>
vOutpts;
2310 o.pushKV(
"txid", output.GetTxId().GetHex());
2311 o.pushKV(
"vout",
int(output.GetN()));
2323 "Set the transaction fee per kB for this wallet. Overrides the "
2324 "global -paytxfee command line parameter.\n"
2325 "Can be deactivated by passing 0 as the fee. In that case automatic "
2326 "fee selection will be used by default.\n",
2336 std::shared_ptr<CWallet>
const wallet =
2353 strprintf(
"txfee cannot be less than min relay tx fee (%s)",
2358 strprintf(
"txfee cannot be less than wallet min fee (%s)",
2364 "txfee cannot be more than wallet max tx fee (%s)",
2386 "balances from outputs that the wallet can sign",
2389 "trusted balance (outputs created by the wallet or "
2390 "confirmed outputs)"},
2392 "untrusted pending balance (outputs created by "
2393 "others that are in the mempool)"},
2395 "balance from immature coinbase outputs"},
2397 "(only present if avoid_reuse is set) balance from "
2398 "coins sent to addresses that were previously "
2399 "spent from (potentially privacy violating)"},
2403 "watchonly balances (not present if wallet does not "
2407 "trusted balance (outputs created by the wallet or "
2408 "confirmed outputs)"},
2410 "untrusted pending balance (outputs created by "
2411 "others that are in the mempool)"},
2413 "balance from immature coinbase outputs"},
2430 wallet.BlockUntilSyncedToCurrentChain();
2440 bal.m_mine_untrusted_pending);
2449 full_bal.m_mine_untrusted_pending -
2450 bal.m_mine_trusted -
2451 bal.m_mine_untrusted_pending);
2460 bal.m_watchonly_untrusted_pending);
2472 "Returns an object containing various wallet state info.\n",
2482 "DEPRECATED. Identical to getbalances().mine.trusted"},
2484 "DEPRECATED. Identical to "
2485 "getbalances().mine.untrusted_pending"},
2487 "DEPRECATED. Identical to getbalances().mine.immature"},
2489 "the total number of transactions in the wallet"},
2492 " of the oldest pre-generated key in the key pool. "
2493 "Legacy wallets only."},
2495 "how many new keys are pre-generated (only counts external "
2498 "how many new keys are pre-generated for internal use (used "
2499 "for change outputs, only appears if the wallet is using "
2500 "this feature, otherwise external keys are used)"},
2504 " until which the wallet is unlocked for transfers, or 0 "
2505 "if the wallet is locked (only present for "
2506 "passphrase-encrypted wallets)"},
2508 "the transaction fee configuration, set in " +
2511 "the Hash160 of the HD seed (only present when HD is "
2514 "false if privatekeys are disabled for this wallet (enforced "
2515 "watch-only wallet)"},
2518 "current scanning details, or false if no scan is in "
2522 "elapsed seconds since scan start"},
2524 "scanning progress percentage [0.0, 1.0]"},
2528 "whether this wallet tracks clean/dirty coins in terms of "
2531 "whether this wallet uses descriptors for scriptPubKey "
2539 std::shared_ptr<CWallet>
const wallet =
2549 pwallet->BlockUntilSyncedToCurrentChain();
2558 obj.pushKV(
"walletname", pwallet->
GetName());
2560 obj.pushKV(
"balance",
bal.m_mine_trusted);
2561 obj.pushKV(
"unconfirmed_balance",
bal.m_mine_untrusted_pending);
2562 obj.pushKV(
"immature_balance",
bal.m_mine_immature);
2563 obj.pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2574 obj.pushKV(
"hdseedid", seed_id.
GetHex());
2579 obj.pushKV(
"keypoolsize_hd_internal",
2583 obj.pushKV(
"unlocked_until", pwallet->nRelockTime);
2587 "private_keys_enabled",
2595 obj.pushKV(
"scanning",
false);
2597 obj.pushKV(
"avoid_reuse",
2599 obj.pushKV(
"descriptors",
2609 "Returns a list of wallets in the wallet directory.\n",
2635 wallet.pushKV(
"name", path.u8string());
2649 "Returns a list of currently loaded wallets.\n"
2650 "For full information on the wallet, use \"getwalletinfo\"\n",
2677 "Loads a wallet from a wallet file or directory."
2678 "\nNote that all wallet command-line options used when starting "
2680 "\napplied to the new wallet (eg -rescan, etc).\n",
2683 "The wallet directory or .dat file."},
2686 "Save wallet name to persistent settings and load on startup. "
2687 "True to add wallet to startup list, false to remove, null to "
2688 "leave unchanged."},
2695 "The wallet name if loaded successfully."},
2697 "Warning message if wallet was not loaded cleanly."},
2704 const std::string
name(request.params[0].get_str());
2719 std::string
flags =
"";
2722 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2727 "Change the state of the given wallet flag for a wallet.\n",
2730 "The name of the flag to change. Current available flags: " +
2740 "The name of the flag that was modified"},
2742 "The new state of the flag"},
2744 "Any warnings associated with the change"},
2750 std::shared_ptr<CWallet>
const wallet =
2757 std::string
flag_str = request.params[0].get_str();
2759 request.params[1].isNull() || request.params[1].get_bool();
2780 strprintf(
"Wallet flag is already set to %s: %s",
2781 value ?
"true" :
"false",
flag_str));
2785 res.pushKV(
"flag_state", value);
2805 "Creates and loads a new wallet.\n",
2808 "The name for the new wallet. If this is a path, the wallet will "
2809 "be created at the path location."},
2811 "Disable the possibility of private keys (only watchonlys are "
2812 "possible in this mode)."},
2814 "Create a blank wallet. A blank wallet has no keys or HD seed. "
2815 "One can be set using sethdseed."},
2817 "Encrypt the wallet with this passphrase."},
2819 "Keep track of coin reuse, and treat dirty and clean coins "
2820 "differently with privacy considerations in mind."},
2822 "Create a native descriptor wallet. The wallet will use "
2823 "descriptors internally to handle address creation"},
2826 "Save wallet name to persistent settings and load on startup. "
2827 "True to add wallet to startup list, false to remove, null to "
2828 "leave unchanged."},
2835 "The wallet name if created successfully. If the wallet "
2836 "was created using a full path, the wallet_name will be "
2839 "Warning message if wallet was not loaded cleanly."},
2845 {
"avoid_reuse",
true},
2846 {
"descriptors",
true},
2847 {
"load_on_startup",
true}}) +
2849 {
"avoid_reuse",
true},
2850 {
"descriptors",
true},
2851 {
"load_on_startup",
true}})},
2856 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2860 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2866 std::vector<bilingual_str>
warnings;
2867 if (!request.params[3].isNull()) {
2868 passphrase = request.params[3].get_str().c_str();
2872 "Empty string given as passphrase, wallet will "
2873 "not be encrypted."));
2877 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2880 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2883 "Wallet is an experimental descriptor wallet"));
2893 request.params[6].isNull()
2895 : std::make_optional<bool>(request.params[6].get_bool());
2896 std::shared_ptr<CWallet>
wallet =
2918 "Unloads the wallet referenced by the request endpoint otherwise "
2919 "unloads the wallet specified in the argument.\n"
2920 "Specifying the wallet name on a wallet endpoint is invalid.",
2924 "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."},
2944 if (!request.params[0].isNull()) {
2946 "Cannot unload the requested wallet");
2956 "Requested wallet does not exist or is not loaded");
2962 std::vector<bilingual_str>
warnings;
2964 request.params[1].isNull()
2966 : std::make_optional<bool>(request.params[1].get_bool());
2969 "Requested wallet already unloaded");
2986 "Returns array of unspent transaction outputs\n"
2987 "with between minconf and maxconf (inclusive) confirmations.\n"
2988 "Optionally filter to only include txouts paid to specified "
2992 "The minimum confirmations to filter"},
2994 "The maximum confirmations to filter"},
2999 "The bitcoin addresses to filter",
3006 "Include outputs that are not safe to spend\n"
3007 " See description of \"safe\" attribute below."},
3011 "JSON with query options",
3015 "Minimum value of each UTXO in " + ticker +
""},
3018 "Maximum value of each UTXO in " + ticker +
""},
3023 "Minimum sum value of all UTXOs in " + ticker +
""},
3040 "The associated label, or \"\" for the default label"},
3043 "the transaction output amount in " + ticker},
3045 "The number of confirmations"},
3048 "DEPRECATED: The number of in-mempool ancestor "
3049 "transactions, including this one (if transaction is in "
3050 "the mempool). Only displayed if the "
3051 "-deprecatedrpc=mempool_ancestors_descendants option is "
3054 "DEPRECATED: The virtual transaction size of in-mempool "
3055 " ancestors, including this one (if transaction is in "
3056 "the mempool). Only displayed if the "
3057 "-deprecatedrpc=mempool_ancestors_descendants option is "
3061 "DEPRECATED: The total fees of in-mempool ancestors "
3062 "(including this one) with fee deltas used for mining "
3065 " (if transaction is in the mempool). Only "
3067 "-deprecatedrpc=mempool_ancestors_descendants option "
3071 "The redeemScript if scriptPubKey is P2SH"},
3073 "Whether we have the private keys to spend this output"},
3075 "Whether we know how to spend this output, ignoring the "
3078 "(only present if avoid_reuse is set) Whether this "
3079 "output is reused/dirty (sent to an address that was "
3080 "previously spent from)"},
3082 "(only when solvable) A descriptor for spending this "
3085 "Whether this output is considered safe to spend. "
3086 "Unconfirmed transactions\n"
3087 "from outside keys are considered unsafe\n"
3088 "and are not eligible for spending by fundrawtransaction "
3089 "and sendtoaddress."},
3096 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3097 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3100 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3101 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3104 "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") +
3107 "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")},
3110 std::shared_ptr<CWallet>
const wallet =
3118 if (!request.params[0].isNull()) {
3119 nMinDepth = request.params[0].getInt<
int>();
3123 if (!request.params[1].isNull()) {
3124 nMaxDepth = request.params[1].getInt<
int>();
3128 if (!request.params[2].isNull()) {
3130 for (
size_t idx = 0; idx < inputs.
size(); idx++) {
3131 const UniValue &input = inputs[idx];
3137 std::string(
"Invalid Bitcoin address: ") +
3144 "Invalid parameter, duplicated address: ") +
3151 if (!request.params[3].isNull()) {
3160 if (!request.params[4].isNull()) {
3173 if (options.
exists(
"minimumAmount")) {
3177 if (options.
exists(
"maximumAmount")) {
3181 if (options.
exists(
"minimumSumAmount")) {
3186 if (options.
exists(
"maximumCount")) {
3194 pwallet->BlockUntilSyncedToCurrentChain();
3218 out.tx->tx->vout[out.i].scriptPubKey;
3229 entry.
pushKV(
"txid", out.tx->GetId().GetHex());
3230 entry.
pushKV(
"vout", out.i);
3241 std::unique_ptr<SigningProvider> provider =
3246 CScriptID(std::get<ScriptHash>(address));
3249 entry.
pushKV(
"redeemScript",
3257 entry.
pushKV(
"amount", out.tx->tx->vout[out.i].nValue);
3258 entry.
pushKV(
"confirmations", out.nDepth);
3259 entry.
pushKV(
"spendable", out.fSpendable);
3260 entry.
pushKV(
"solvable", out.fSolvable);
3261 if (out.fSolvable) {
3262 std::unique_ptr<SigningProvider> provider =
3267 entry.
pushKV(
"desc", descriptor->ToString());
3273 entry.
pushKV(
"safe", out.fSafe);
3287 pwallet->BlockUntilSyncedToCurrentChain();
3324 if (options.
exists(
"add_inputs")) {
3328 if (options.
exists(
"changeAddress") ||
3329 options.
exists(
"change_address")) {
3331 (options.
exists(
"change_address")
3332 ? options[
"change_address"]
3333 : options[
"changeAddress"])
3341 "Change address must be a valid bitcoin address");
3347 if (options.
exists(
"changePosition") ||
3348 options.
exists(
"change_position")) {
3350 ? options[
"change_position"]
3351 : options[
"changePosition"])
3356 options.
exists(
"include_watching") ? options[
"include_watching"]
3357 : options[
"includeWatching"];
3361 if (options.
exists(
"lockUnspents") ||
3362 options.
exists(
"lock_unspents")) {
3364 (options.
exists(
"lock_unspents") ? options[
"lock_unspents"]
3365 : options[
"lockUnspents"])
3369 if (options.
exists(
"include_unsafe")) {
3371 options[
"include_unsafe"].
get_bool();
3374 if (options.
exists(
"feeRate") || options.
exists(
"fee_rate")) {
3376 options.
exists(
"fee_rate") ? options[
"fee_rate"]
3377 : options[
"feeRate"]));
3381 if (options.
exists(
"subtractFeeFromOutputs") ||
3382 options.
exists(
"subtract_fee_from_outputs")) {
3384 (options.
exists(
"subtract_fee_from_outputs")
3385 ? options[
"subtract_fee_from_outputs"]
3386 : options[
"subtractFeeFromOutputs"])
3396 if (tx.
vout.size() == 0) {
3398 "TX must have at least one output");
3405 "changePosition out of bounds");
3413 strprintf(
"Invalid parameter, duplicated position: %d", pos));
3418 strprintf(
"Invalid parameter, negative position: %d", pos));
3420 if (pos >=
int(tx.
vout.size())) {
3423 strprintf(
"Invalid parameter, position too large: %d", pos));
3440 "fundrawtransaction",
3441 "If the transaction has no inputs, they will be automatically selected "
3442 "to meet its out value.\n"
3443 "It will add at most one change output to the outputs.\n"
3444 "No existing outputs will be modified unless "
3445 "\"subtractFeeFromOutputs\" is specified.\n"
3446 "Note that inputs which were signed may need to be resigned after "
3447 "completion since in/outputs have been added.\n"
3448 "The inputs added will not be signed, use signrawtransactionwithkey or "
3449 "signrawtransactionwithwallet for that.\n"
3450 "Note that all existing inputs must have their previous output "
3451 "transaction be in the wallet.\n"
3452 "Note that all inputs selected must be of standard form and P2SH "
3454 "in the wallet using importaddress or addmultisigaddress (to calculate "
3456 "You can see whether this is the case by checking the \"solvable\" "
3457 "field in the listunspent output.\n"
3458 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently "
3459 "supported for watch-only\n",
3462 "The hex string of the raw transaction"},
3466 "For backward compatibility: passing in a true instead of an "
3467 "object will result in {\"includeWatching\":true}",
3470 "For a transaction with existing inputs, automatically "
3471 "include more if they are not enough."},
3473 "Include inputs that are not safe to spend (unconfirmed "
3474 "transactions from outside keys).\n"
3475 "Warning: the resulting transaction may become invalid if "
3476 "one of the unsafe inputs disappears.\n"
3477 "If that happens, you will need to fund the transaction with "
3478 "different inputs and republish it."},
3481 "The bitcoin address to receive the change"},
3484 "The index of the change output"},
3487 "true for watch-only wallets, otherwise false"},
3488 "Also select inputs which are watch only.\n"
3489 "Only solvable inputs can be used. Watch-only destinations "
3490 "are solvable if the public key and/or output script was "
3492 "e.g. with 'importpubkey' or 'importmulti' with the "
3493 "'pubkeys' or 'desc' field."},
3495 "Lock selected unspent outputs"},
3498 "not set: makes wallet determine the fee"},
3499 "Set a specific fee rate in " + ticker +
"/kB",
3502 "subtractFeeFromOutputs",
3506 " The fee will be equally "
3507 "deducted from the amount of each specified output.\n"
3508 " Those recipients will "
3509 "receive less bitcoins than you enter in their "
3510 "corresponding amount field.\n"
3511 " If no outputs are "
3512 "specified here, the sender pays the fee.",
3516 "The zero-based output index, before a change output "
3522 .oneline_description =
"options"}},
3529 "The resulting raw transaction (hex-encoded string)"},
3531 "Fee in " + ticker +
" the resulting transaction pays"},
3533 "The position of the added change output, or -1"},
3536 "\nCreate a transaction with no inputs\n" +
3538 "\"[]\" \"{\\\"myaddress\\\":10000}\"") +
3539 "\nAdd sufficient unsigned inputs to meet the output value\n" +
3541 "\nSign the transaction\n" +
3543 "\"fundedtransactionhex\"") +
3544 "\nSend the transaction\n" +
3545 HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")},
3548 std::shared_ptr<CWallet>
const wallet =
3557 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
3559 "TX decode failed");
3573 result.
pushKV(
"fee", fee);
3583 "signrawtransactionwithwallet",
3584 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
3585 "The second optional argument (may be null) is an array of previous "
3586 "transaction outputs that\n"
3587 "this transaction depends on but may not yet be in the block chain.\n" +
3591 "The transaction hex string"},
3596 "The previous dependent transaction outputs",
3607 "The output number"},
3619 "The signature hash type. Must be one of\n"
3621 " \"NONE|FORKID\"\n"
3622 " \"SINGLE|FORKID\"\n"
3623 " \"ALL|FORKID|ANYONECANPAY\"\n"
3624 " \"NONE|FORKID|ANYONECANPAY\"\n"
3625 " \"SINGLE|FORKID|ANYONECANPAY\""},
3633 "The hex-encoded raw transaction with signature(s)"},
3635 "If the transaction has a complete set of signatures"},
3639 "Script verification errors (if there are any)",
3646 "The hash of the referenced, previous transaction"},
3648 "The index of the output to spent and used as "
3651 "The hex-encoded signature script"},
3653 "Script sequence number"},
3655 "Verification or signing error related to the "
3665 std::shared_ptr<CWallet>
const wallet =
3675 "TX decode failed");
3683 std::map<COutPoint, Coin> coins;
3686 coins[
txin.prevout];
3696 "Signature must use SIGHASH_FORKID");
3715 "Rescan the local blockchain for wallet related transactions.\n"
3716 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3719 "block height where the rescan should start"},
3722 "the last block height that should be scanned"},
3730 "The block height where the rescan started (the requested "
3733 "The height of the last rescanned block. May be null in rare "
3734 "cases if there was a reorg and the call didn't scan any "
3735 "blocks because they were already scanned in the background."},
3741 std::shared_ptr<CWallet>
const wallet =
3751 "Wallet is currently rescanning. Abort "
3752 "existing rescan or wait.");
3762 if (!request.params[0].isNull()) {
3766 "Invalid start_height");
3770 if (!request.params[1].isNull()) {
3774 "Invalid stop_height");
3778 "stop_height must be greater than start_height");
3788 "Can't rescan beyond pruned data. Use RPC call "
3789 "getblockchaininfo to determine your pruned height.");
3806 "Rescan failed. Potentially corrupted data files.");
3845 if (
subobj.exists(
"pubkey")) {
3848 obj.pushKV(
"embedded", std::move(
subobj));
3860 obj.pushKV(
"pubkeys", std::move(pubkeys));
3876 obj.pushKV(
"pubkey",
HexStr(vchPubKey));
3898 std::unique_ptr<SigningProvider> provider =
nullptr;
3902 ret.pushKVs(detail);
3921 "Return information about the given bitcoin address.\n"
3922 "Some of the information will only be present if the address is in the "
3926 "The bitcoin address for which to get information."},
3934 "The bitcoin address validated."},
3936 "The hex-encoded scriptPubKey generated by the address."},
3939 "If the address is watchonly."},
3941 "If we know how to spend coins sent to this address, ignoring "
3942 "the possible lack of private keys."},
3944 "A descriptor for spending coins sent to this address (only "
3948 "If the address was used for change output."},
3950 "The output script type. Only if isscript is true and the "
3951 "redeemscript is known. Possible\n"
3953 "types: nonstandard, pubkey, pubkeyhash, scripthash, "
3954 "multisig, nulldata."},
3956 "The redeemscript for the p2sh address."},
3960 "Array of pubkeys associated with the known redeemscript "
3961 "(only if script is multisig).",
3966 "The number of signatures required to spend multisig output "
3967 "(only if script is multisig)."},
3969 "The hex value of the raw public key for single-key addresses "
3970 "(possibly embedded in P2SH)."},
3974 "Information about the address embedded in P2SH, if "
3975 "relevant and known.",
3978 "Includes all getaddressinfo output fields for the "
3979 "embedded address excluding metadata (timestamp, "
3980 "hdkeypath, hdseedid)\n"
3981 "and relation to the wallet (ismine, iswatchonly)."},
3984 "If the pubkey is compressed."},
3986 "The creation time of the key, if available, expressed in " +
3989 "The HD keypath, if the key is HD and available."},
3991 "The Hash160 of the HD seed."},
3993 true,
"The fingerprint of the master key."},
3996 "Array of labels associated with the address. Currently "
3997 "limited to one label but returned\n"
3998 "as an array to keep the API stable if multiple labels are "
3999 "enabled in the future.",
4002 "Label name (defaults to \"\")."},
4009 std::shared_ptr<CWallet>
const wallet =
4020 wallet->GetChainParams());
4031 ret.pushKV(
"scriptPubKey",
HexStr(scriptPubKey));
4033 std::unique_ptr<SigningProvider> provider =
4051 ret.pushKVs(detail);
4058 if (
const std::unique_ptr<CKeyMetadata>
meta =
4060 ret.pushKV(
"timestamp",
meta->nCreateTime);
4061 if (
meta->has_key_origin) {
4062 ret.pushKV(
"hdkeypath",
4064 ret.pushKV(
"hdseedid",
meta->hd_seed_id.GetHex());
4065 ret.pushKV(
"hdmasterfingerprint",
4082 ret.pushKV(
"labels", std::move(
labels));
4091 "getaddressesbylabel",
4092 "Returns the list of addresses assigned the specified label.\n",
4098 "json object with addresses as keys",
4102 "Information about address",
4105 "Purpose of address (\"send\" for sending address, "
4106 "\"receive\" for receiving address)"},
4113 std::shared_ptr<CWallet>
const wallet =
4127 for (
const std::pair<const CTxDestination, CAddressBookData> &item :
4128 pwallet->m_address_book) {
4129 if (item.second.IsChange()) {
4132 if (item.second.GetLabel() == label) {
4142 ret.pushKVEnd(address,
4150 std::string(
"No addresses with label " + label));
4161 "Returns the list of all labels, or labels that are assigned to "
4162 "addresses with a specific purpose.\n",
4165 "Address purpose to list labels for ('send','receive'). An empty "
4166 "string is the same as not providing this argument."},
4175 "\nList labels that have receiving addresses\n" +
4177 "\nList labels that have sending addresses\n" +
4179 "\nAs a JSON-RPC call\n" +
4183 std::shared_ptr<CWallet>
const wallet =
4192 std::string purpose;
4193 if (!request.params[0].isNull()) {
4194 purpose = request.params[0].get_str();
4200 for (
const std::pair<const CTxDestination, CAddressBookData>
4201 &entry : pwallet->m_address_book) {
4202 if (entry.second.IsChange()) {
4205 if (purpose.empty() || entry.second.purpose == purpose) {
4206 label_set.insert(entry.second.GetLabel());
4223 "EXPERIMENTAL warning: this call may be changed in future releases.\n"
4224 "\nSend a transaction.\n",
4229 "A JSON array with outputs (key-value pairs), where none of "
4230 "the keys are duplicated.\n"
4231 "That is, each address can only appear once and there can only "
4232 "be one 'data' object.\n"
4233 "For convenience, a dictionary, which holds the key-value "
4234 "pairs directly, is also accepted.",
4243 "A key-value pair. The key (string) is the "
4244 "bitcoin address, the value (float or string) is "
4256 "A key-value pair. The key must be \"data\", the "
4257 "value is hex-encoded data"},
4268 "If inputs are specified, automatically include more if they "
4271 "Include inputs that are not safe to spend (unconfirmed "
4272 "transactions from outside keys).\n"
4273 "Warning: the resulting transaction may become invalid if "
4274 "one of the unsafe inputs disappears.\n"
4275 "If that happens, you will need to fund the transaction with "
4276 "different inputs and republish it."},
4278 "When false, returns a serialized transaction which will not "
4279 "be added to the wallet or broadcast"},
4282 "The bitcoin address to receive the change"},
4285 "The index of the change output"},
4288 "not set: makes wallet determine the fee"},
4294 "true for watch-only wallets, otherwise false"},
4295 "Also select inputs which are watch only.\n"
4296 "Only solvable inputs can be used. Watch-only destinations "
4297 "are solvable if the public key and/or output script was "
4299 "e.g. with 'importpubkey' or 'importmulti' with the "
4300 "'pubkeys' or 'desc' field."},
4305 "Specify inputs instead of adding them automatically. A "
4306 "JSON array of JSON objects",
4309 "The transaction id"},
4311 "The output number"},
4313 "The sequence number"},
4317 "Raw locktime. Non-0 value also locktime-activates inputs"},
4319 "Lock selected unspent outputs"},
4321 "Always return a PSBT, implies add_to_wallet=false."},
4323 "subtract_fee_from_outputs",
4326 "Outputs to subtract the fee from, specified as integer "
4328 "The fee will be equally deducted from the amount of each "
4329 "specified output.\n"
4330 "Those recipients will receive less bitcoins than you "
4331 "enter in their corresponding amount field.\n"
4332 "If no outputs are specified here, the sender pays the "
4337 "The zero-based output index, before a change output "
4349 "If the transaction has a complete set of signatures"},
4351 "The transaction id for the send. Only 1 transaction is created "
4352 "regardless of the number of addresses."},
4354 "If add_to_wallet is false, the hex-encoded raw transaction with "
4357 "If more signatures are needed, or if add_to_wallet is false, "
4358 "the base64-encoded (partially) signed transaction"}}},
4361 "\nSend with a fee rate of 10 XEC/kB\n" +
4363 "\": 100000}' '{\"fee_rate\": 10}'\n") +
4364 "\nCreate a transaction with a specific input, and return "
4365 "result without adding to wallet or broadcasting to the "
4369 "\": 100000}' '{\"add_to_wallet\": "
4370 "false, \"inputs\": "
4372 "\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b565"
4373 "5e72f463568df1aadf0\", \"vout\":1}]}'")},
4376 std::shared_ptr<CWallet>
const wallet =
4383 UniValue options = request.params[1];
4384 if (options.
exists(
"changeAddress")) {
4387 if (options.
exists(
"changePosition")) {
4389 "Use change_position");
4391 if (options.
exists(
"includeWatching")) {
4393 "Use include_watching");
4395 if (options.
exists(
"lockUnspents")) {
4398 if (options.
exists(
"subtractFeeFromOutputs")) {
4400 "Use subtract_fee_from_outputs");
4402 if (options.
exists(
"feeRate")) {
4412 wallet->GetChainParams(), options[
"inputs"], request.params[0],
4413 options[
"locktime"]);
4422 if (options.
exists(
"add_to_wallet")) {
4430 bool complete =
true;
4453 result.
pushKV(
"txid", tx->GetHash().GetHex());
4457 result.
pushKV(
"hex", hex);
4460 result.
pushKV(
"complete", complete);
4469 "Set or generate a new HD wallet seed. Non-HD wallets will not be "
4470 "upgraded to being a HD wallet. Wallets that are already\n"
4471 "HD will have a new HD seed set so that new keys added to the keypool "
4472 "will be derived from this new seed.\n"
4473 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after "
4474 "setting the HD wallet seed.\n" +
4476 "Note: This command is only compatible with legacy wallets.\n",
4479 "Whether to flush old unused addresses, including change "
4480 "addresses, from the keypool and regenerate it.\n"
4481 " If true, the next address from "
4482 "getnewaddress and change address from getrawchangeaddress will "
4483 "be from this new seed.\n"
4484 " If false, addresses (including "
4485 "change addresses if the wallet already had HD Chain Split "
4486 "enabled) from the existing\n"
4487 " keypool will be used until it has "
4490 "The WIF private key to use as the new HD seed.\n"
4491 " The seed value can be retrieved "
4492 "using the dumpwallet command. It is the private key marked "
4502 std::shared_ptr<CWallet>
const wallet =
4514 "Cannot set a HD seed to a wallet with "
4515 "private keys disabled");
4524 "Cannot set a HD seed on a non-HD wallet. Use the "
4525 "upgradewallet RPC in order to upgrade a non-HD wallet "
4532 if (!request.params[0].isNull()) {
4537 if (request.params[1].isNull()) {
4543 "Invalid private key");
4549 "Already have this key (either as an HD seed or "
4550 "as a loose private key)");
4568 "walletprocesspsbt",
4569 "Update a PSBT with input information from our wallet and then sign "
4570 "inputs that we can sign for." +
4574 "The transaction base64 string"},
4576 "Also sign the transaction when updating"},
4578 "The signature hash type to sign with if not specified by "
4579 "the PSBT. Must be one of\n"
4581 " \"NONE|FORKID\"\n"
4582 " \"SINGLE|FORKID\"\n"
4583 " \"ALL|FORKID|ANYONECANPAY\"\n"
4584 " \"NONE|FORKID|ANYONECANPAY\"\n"
4585 " \"SINGLE|FORKID|ANYONECANPAY\""},
4587 "Includes the BIP 32 derivation paths for public keys if we know "
4595 "The base64-encoded partially signed transaction"},
4597 "If the transaction has a complete set of signatures"},
4602 std::shared_ptr<CWallet>
const wallet =
4621 "Signature must use SIGHASH_FORKID");
4625 bool sign = request.params[1].isNull()
4627 : request.params[1].get_bool();
4630 : request.params[3].get_bool();
4631 bool complete =
true;
4642 result.
pushKV(
"complete", complete);
4652 "walletcreatefundedpsbt",
4653 "Creates and funds a transaction in the Partially Signed Transaction "
4655 "Implements the Creator and Updater roles.\n",
4661 "Leave empty to add inputs automatically. See add_inputs "
4673 "The output number"},
4676 "depends on the value of the 'locktime' and "
4677 "'options.replaceable' arguments"},
4678 "The sequence number"},
4686 "The outputs (key-value pairs), where none of "
4687 "the keys are duplicated.\n"
4688 "That is, each address can only appear once and there can only "
4689 "be one 'data' object.\n"
4690 "For compatibility reasons, a dictionary, which holds the "
4691 "key-value pairs directly, is also\n"
4692 " accepted as second parameter.",
4701 "A key-value pair. The key (string) is the "
4702 "bitcoin address, the value (float or string) is "
4714 "A key-value pair. The key must be \"data\", the "
4715 "value is hex-encoded data"},
4721 "Raw locktime. Non-0 value also locktime-activates inputs\n"
4722 " Allows this transaction to be "
4723 "replaced by a transaction with higher fees. If provided, it is "
4724 "an error if explicit sequence numbers are incompatible."},
4731 "If inputs are specified, automatically include more if they "
4734 "Include inputs that are not safe to spend (unconfirmed "
4735 "transactions from outside keys).\n"
4736 "Warning: the resulting transaction may become invalid if "
4737 "one of the unsafe inputs disappears.\n"
4738 "If that happens, you will need to fund the transaction with "
4739 "different inputs and republish it."},
4742 "The bitcoin address to receive the change"},
4745 "The index of the change output"},
4748 "true for watch-only wallets, otherwise false"},
4749 "Also select inputs which are watch only"},
4751 "Lock selected unspent outputs"},
4754 "not set: makes wallet determine the fee"},
4755 "Set a specific fee rate in " + ticker +
"/kB",
4758 "subtractFeeFromOutputs",
4761 "The outputs to subtract the fee from.\n"
4762 " The fee will be equally "
4763 "deducted from the amount of each specified output.\n"
4764 " Those recipients will "
4765 "receive less bitcoins than you enter in their "
4766 "corresponding amount field.\n"
4767 " If no outputs are "
4768 "specified here, the sender pays the fee.",
4772 "The zero-based output index, before a change output "
4779 "Includes the BIP 32 derivation paths for public keys if we know "
4787 "The resulting raw transaction (base64-encoded string)"},
4789 "Fee in " + ticker +
" the resulting transaction pays"},
4791 "The position of the added change output, or -1"},
4794 "\nCreate a transaction with no inputs\n" +
4796 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" "
4797 "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
4800 std::shared_ptr<CWallet>
const wallet =
4810 wallet->GetChainParams(), request.params[0], request.params[1],
4825 : request.params[4].get_bool();
4826 bool complete =
true;
4840 result.
pushKV(
"fee", fee);
4850 "Upgrade the wallet. Upgrades to the latest version if no "
4851 "version number is specified\n"
4852 "New keys may be generated and a new wallet backup will need to "
4855 "The version number to upgrade to. Default is the latest "
4862 std::shared_ptr<CWallet>
const wallet =
4872 if (!request.params[0].isNull()) {
4873 version = request.params[0].getInt<
int>();
4879 return error.original;
4888 "createwallettransaction",
4889 "Create a transaction sending an amount to a given address.\n" +
4893 "The bitcoin address to send to."},
4900 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
4902 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 100000")},
4905 std::shared_ptr<CWallet>
const wallet =
4915 pwallet->BlockUntilSyncedToCurrentChain();
4922 const std::string address = request.params[0].get_str();
4926 std::vector<CRecipient> recipients;
4928 wallet->GetChainParams());
4970 {
"wallet",
send, },
static constexpr Amount MAX_MONEY
No amount larger than this (in satoshi) is valid.
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
#define CHECK_NONFATAL(condition)
Identity function.
const std::string & GetLabel() const
std::vector< CTransactionRef > vtx
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
bool m_add_inputs
If false, only selected inputs are used.
bool m_avoid_address_reuse
Forbids inclusion of dirty (previously used) addresses.
Double ended buffer combining vector and stream-like interfaces.
Fee rate in satoshis per kilobyte: Amount / kB.
std::string ToString() const
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
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 outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
bool IsCompressed() const
Check whether this is a compressed public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Serialized script, used inside transaction inputs and outputs.
bool IsPayToScriptHash() const
A reference to a CScript: the Hash160 of its serialization (see script.h)
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
An output of a transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
BlockHash GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
double ScanningProgress() const
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
int64_t ScanningDuration() const
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.
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
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
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
const UniValue & get_array() const
bool exists(const std::string &key) const
void pushKV(std::string key, UniValue val)
void push_backV(const std::vector< UniValue > &vec)
RAII object to check and reserve a wallet rescan.
std::string GetHex() const
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual int rpcSerializationFlags()=0
Current RPC serialization flags.
virtual bool findBlock(const BlockHash &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
virtual const CChainParams & params() const =0
This Chain's parameters.
virtual void findCoins(std::map< COutPoint, Coin > &coins)=0
Look up unspent output information.
virtual bool hasBlocks(const BlockHash &block_hash, int min_height=0, std::optional< int > max_height={})=0
Return true if data is available for all blocks in the specified range of blocks.
virtual bool findAncestorByHeight(const BlockHash &block_hash, int ancestor_height, const FoundBlock &ancestor_out={})=0
Find ancestor of block at specified height and optionally return ancestor information.
virtual CFeeRate relayMinFee()=0
Relay current minimum fee (from -minrelaytxfee settings).
Helper for findBlock to selectively return pieces of block data.
const Config & GetConfig()
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
SigHashType ParseSighashString(const UniValue &sighash)
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsLockedCoin(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool TopUpKeyPool(unsigned int kpSize=0)
TransactionError FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=true) const
Fills out a PSBT with information from the wallet.
int64_t GetOldestKeyPoolTime() const
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string > > orderForm, bool broadcast=true)
Add the transaction to the wallet and maybe attempt to broadcast it.
void 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.
isminetype
IsMine() return codes.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
CKey DecodeSecret(const std::string &str)
bool error(const char *fmt, const Args &...args)
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
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.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
void SignTransactionResultToJSON(CMutableTransaction &mtx, bool complete, const std::map< COutPoint, Coin > &coins, const std::map< int, std::string > &input_errors, UniValue &result)
CMutableTransaction ConstructTransaction(const CChainParams ¶ms, const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime)
Create a transaction from univalue parameters.
void ParsePrevouts(const UniValue &prevTxsUnival, FillableSigningProvider *keystore, std::map< COutPoint, Coin > &coins)
Parse a prevtxs UniValue array and get the map of coins from it.
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)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
Amount AmountFromValue(const UniValue &value)
const std::string EXAMPLE_ADDRESS
Example CashAddr address used in multiple RPCExamples.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
CPubKey HexToPubKey(const std::string &hex_in)
CPubKey AddrToPubKey(const CChainParams &chainparams, const FillableSigningProvider &keystore, const std::string &addr_in)
uint256 ParseHashO(const UniValue &o, std::string strKey)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
Check for expected keys/value types in an Object.
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
UniValue DescribeAddress(const CTxDestination &dest)
static RPCHelpMan createwallet()
static RPCHelpMan getnewaddress()
static RPCHelpMan sethdseed()
static RPCHelpMan listreceivedbylabel()
static RPCHelpMan sendtoaddress()
Span< const CRPCCommand > GetWalletRPCCommands()
static RPCHelpMan listunspent()
static RPCHelpMan getrawchangeaddress()
static const std::vector< RPCResult > TransactionDescriptionString()
static RPCHelpMan walletprocesspsbt()
static void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx, int nMinDepth, bool fLong, Vec &ret, const isminefilter &filter_ismine, const std::string *filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
List transactions based on the given criteria.
static RPCHelpMan fundrawtransaction()
static RPCHelpMan gettransaction()
static UniValue ListReceived(const Config &config, const CWallet *const pwallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static UniValue AddressBookDataToJSON(const CAddressBookData &data, const bool verbose)
Convert CAddressBookData to JSON record.
static RPCHelpMan listaddressgroupings()
static void WalletTxToJSON(const CWallet &wallet, const CWalletTx &wtx, UniValue &entry) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan addmultisigaddress()
RPCHelpMan getaddressesbylabel()
static RPCHelpMan listlockunspent()
static Amount GetReceived(const CWallet &wallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan getunconfirmedbalance()
static RPCHelpMan listwallets()
RPCHelpMan rescanblockchain()
static RPCHelpMan upgradewallet()
static RPCHelpMan unloadwallet()
static RPCHelpMan walletcreatefundedpsbt()
static RPCHelpMan getbalances()
static RPCHelpMan listwalletdir()
static RPCHelpMan keypoolrefill()
bool HaveKey(const SigningProvider &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
RPCHelpMan getaddressinfo()
static RPCHelpMan getwalletinfo()
static RPCHelpMan lockunspent()
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.
bool CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, CTransactionRef &tx, Amount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, bool sign)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
void AvailableCoins(const CWallet &wallet, std::vector< COutput > &vCoins, const CCoinControl *coinControl, const Amount nMinimumAmount, const Amount nMaximumAmount, const Amount nMinimumSumAmount, const uint64_t nMaximumCount)
populate vCoins with vector of available COutputs.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
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.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
CKeyID ToKeyID(const PKHash &key_hash)
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeBase64(Span< const uint8_t > input)
bool IsHex(const std::string &str)
Returns true if each character in str is a hex character, and has an even number of hex digits.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
static constexpr Amount zero() noexcept
Amount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
A BlockHash is a unqiue identifier for a block.
std::optional< int > last_scanned_height
enum CWallet::ScanResult::@20 status
static const Currency & get()
SecureString create_passphrase
A version of CTransaction with the PSBT format.
@ STR_HEX
Special type that is a STR with only hex chars.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
@ OBJ_NAMED_PARAMS
Special type that behaves almost exactly like OBJ, defining an options object with a list of pre-defi...
std::string DefaultHint
Hint for default value.
@ OMITTED
The arg is optional for one of two reasons:
std::string oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
bool also_positional
If set allows a named-parameter field in an OBJ_NAMED_PARAM options object to have the same name as a...
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ ARR_FIXED
Special array that has a fixed number of entries.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
A TxId is the identifier of a transaction.
Wrapper for UniValue::VType, which includes typeAny: used to denote don't care type.
WalletContext struct containing references to state shared between CWallet instances,...
interfaces::Chain * chain
std::vector< uint256 > txids
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
const UniValue NullUniValue
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
static const int PROTOCOL_VERSION
network protocol versioning
void EnsureWalletIsUnlocked(const CWallet *pwallet)
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
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::tuple< std::shared_ptr< CWallet >, std::vector< bilingual_str > > LoadWalletHelper(WalletContext &context, UniValue load_on_start_param, const std::string wallet_name)
std::map< std::string, std::string > mapValue_t
static constexpr uint64_t MUTABLE_WALLET_FLAGS
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
std::shared_ptr< CWallet > GetWallet(const std::string &name)
std::vector< std::shared_ptr< CWallet > > GetWallets()
std::shared_ptr< CWallet > CreateWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
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,...