Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show All 15 Lines | |||||
#include <node/transaction.h> | #include <node/transaction.h> | ||||
#include <outputtype.h> | #include <outputtype.h> | ||||
#include <policy/fees.h> | #include <policy/fees.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <rpc/mining.h> | #include <rpc/mining.h> | ||||
#include <rpc/rawtransaction_util.h> | #include <rpc/rawtransaction_util.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <rpc/util.h> | #include <rpc/util.h> | ||||
#include <script/descriptor.h> | |||||
#include <shutdown.h> | #include <shutdown.h> | ||||
#include <timedata.h> | #include <timedata.h> | ||||
#include <util/error.h> | #include <util/error.h> | ||||
#include <util/moneystr.h> | #include <util/moneystr.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/url.h> | #include <util/url.h> | ||||
#include <util/validation.h> | #include <util/validation.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
▲ Show 20 Lines • Show All 3,316 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 5) { | ||||
" \"confirmations\" : n, (numeric) The number of " | " \"confirmations\" : n, (numeric) The number of " | ||||
"confirmations\n" | "confirmations\n" | ||||
" \"redeemScript\" : n (string) The redeemScript if " | " \"redeemScript\" : n (string) The redeemScript if " | ||||
"scriptPubKey is P2SH\n" | "scriptPubKey is P2SH\n" | ||||
" \"spendable\" : xxx, (bool) Whether we have the " | " \"spendable\" : xxx, (bool) Whether we have the " | ||||
"private keys to spend this output\n" | "private keys to spend this output\n" | ||||
" \"solvable\" : xxx, (bool) Whether we know how to " | " \"solvable\" : xxx, (bool) Whether we know how to " | ||||
"spend this output, ignoring the lack of keys\n" | "spend this output, ignoring the lack of keys\n" | ||||
" \"desc\" : xxx, (string, only when solvable) " | |||||
"A descriptor for spending this output\n" | |||||
" \"safe\" : xxx (bool) Whether this output is " | " \"safe\" : xxx (bool) Whether this output is " | ||||
"considered safe to spend. Unconfirmed transactions\n" | "considered safe to spend. Unconfirmed transactions\n" | ||||
" from outside keys are " | " from outside keys are " | ||||
"considered unsafe and are not eligible for spending by\n" | "considered unsafe and are not eligible for spending by\n" | ||||
" fundrawtransaction and " | " fundrawtransaction and " | ||||
"sendtoaddress.\n" | "sendtoaddress.\n" | ||||
" }\n" | " }\n" | ||||
" ,...\n" | " ,...\n" | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | for (const COutput &out : vecOutputs) { | ||||
} | } | ||||
entry.pushKV("scriptPubKey", | entry.pushKV("scriptPubKey", | ||||
HexStr(scriptPubKey.begin(), scriptPubKey.end())); | HexStr(scriptPubKey.begin(), scriptPubKey.end())); | ||||
entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue)); | entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue)); | ||||
entry.pushKV("confirmations", out.nDepth); | entry.pushKV("confirmations", out.nDepth); | ||||
entry.pushKV("spendable", out.fSpendable); | entry.pushKV("spendable", out.fSpendable); | ||||
entry.pushKV("solvable", out.fSolvable); | entry.pushKV("solvable", out.fSolvable); | ||||
if (out.fSolvable) { | |||||
auto descriptor = InferDescriptor(scriptPubKey, *pwallet); | |||||
entry.pushKV("desc", descriptor->ToString()); | |||||
} | |||||
entry.pushKV("safe", out.fSafe); | entry.pushKV("safe", out.fSafe); | ||||
results.push_back(entry); | results.push_back(entry); | ||||
} | } | ||||
return results; | return results; | ||||
} | } | ||||
void FundTransaction(CWallet *const pwallet, CMutableTransaction &tx, | void FundTransaction(CWallet *const pwallet, CMutableTransaction &tx, | ||||
▲ Show 20 Lines • Show All 657 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
" \"address\" : \"address\", (string) The bitcoin " | " \"address\" : \"address\", (string) The bitcoin " | ||||
"address validated\n" | "address validated\n" | ||||
" \"scriptPubKey\" : \"hex\", (string) The hex-encoded " | " \"scriptPubKey\" : \"hex\", (string) The hex-encoded " | ||||
"scriptPubKey generated by the address\n" | "scriptPubKey generated by the address\n" | ||||
" \"ismine\" : true|false, (boolean) If the address is " | " \"ismine\" : true|false, (boolean) If the address is " | ||||
"yours or not\n" | "yours or not\n" | ||||
" \"iswatchonly\" : true|false, (boolean) If the address is " | " \"iswatchonly\" : true|false, (boolean) If the address is " | ||||
"watchonly\n" | "watchonly\n" | ||||
" \"solvable\" : true|false, (boolean) Whether we know " | |||||
"how to spend coins sent to this address, ignoring the " | |||||
"possible lack of private keys\n" | |||||
" \"desc\" : \"desc\", (string, optional) A " | |||||
"descriptor for spending coins sent to this address (only when " | |||||
"solvable)\n" | |||||
" \"isscript\" : true|false, (boolean) If the key is a " | " \"isscript\" : true|false, (boolean) If the key is a " | ||||
"script\n" | "script\n" | ||||
" \"ischange\" : true|false, (boolean) If the address " | " \"ischange\" : true|false, (boolean) If the address " | ||||
"was used for change output\n" | "was used for change output\n" | ||||
" \"script\" : \"type\" (string, optional) The " | " \"script\" : \"type\" (string, optional) The " | ||||
"output script type. Only if \"isscript\" is true and the " | "output script type. Only if \"isscript\" is true and the " | ||||
"redeemscript is known. Possible types: nonstandard, pubkey, " | "redeemscript is known. Possible types: nonstandard, pubkey, " | ||||
"pubkeyhash, scripthash, multisig, nulldata\n" | "pubkeyhash, scripthash, multisig, nulldata\n" | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | UniValue getaddressinfo(const Config &config, const JSONRPCRequest &request) { | ||||
ret.pushKV("address", currentAddress); | ret.pushKV("address", currentAddress); | ||||
CScript scriptPubKey = GetScriptForDestination(dest); | CScript scriptPubKey = GetScriptForDestination(dest); | ||||
ret.pushKV("scriptPubKey", | ret.pushKV("scriptPubKey", | ||||
HexStr(scriptPubKey.begin(), scriptPubKey.end())); | HexStr(scriptPubKey.begin(), scriptPubKey.end())); | ||||
isminetype mine = IsMine(*pwallet, dest); | isminetype mine = IsMine(*pwallet, dest); | ||||
ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE)); | ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE)); | ||||
bool solvable = IsSolvable(*pwallet, scriptPubKey); | |||||
ret.pushKV("solvable", solvable); | |||||
if (solvable) { | |||||
ret.pushKV("desc", InferDescriptor(scriptPubKey, *pwallet)->ToString()); | |||||
} | |||||
ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); | ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); | ||||
UniValue detail = DescribeWalletAddress(pwallet, dest); | UniValue detail = DescribeWalletAddress(pwallet, dest); | ||||
ret.pushKVs(detail); | ret.pushKVs(detail); | ||||
if (pwallet->mapAddressBook.count(dest)) { | if (pwallet->mapAddressBook.count(dest)) { | ||||
ret.pushKV("label", pwallet->mapAddressBook[dest].name); | ret.pushKV("label", pwallet->mapAddressBook[dest].name); | ||||
} | } | ||||
ret.pushKV("ischange", pwallet->IsChange(scriptPubKey)); | ret.pushKV("ischange", pwallet->IsChange(scriptPubKey)); | ||||
const CKeyMetadata *meta = nullptr; | const CKeyMetadata *meta = nullptr; | ||||
▲ Show 20 Lines • Show All 608 Lines • Show Last 20 Lines |