Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
rpcdump.cpp
Go to the documentation of this file.
84 "\nAdds a private key (as returned by dumpprivkey) to your wallet. Requires a new wallet backup.\n"
89 "\nNote: This call can take minutes to complete if rescan is true, during that time, other rpc calls\n"
90 "may report that the imported key exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
125 throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
134 if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range");
190 void ImportScript(CWallet * const pwallet, const CScript& script, const std::string& strLabel, bool isRedeemScript)
193 throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
215 void ImportAddress(CWallet * const pwallet, const CTxDestination& dest, const std::string& strLabel)
234 "\nAdds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n"
240 "\nNote: This call can take minutes to complete if rescan is true, during that time, other rpc calls\n"
241 "may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
243 "\nNote: If you import a non-standard raw script in hex form, outputs sending to it will be treated\n"
269 throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
283 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Cannot use the p2sh flag with an address - use a script instead");
312 "\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.\n"
314 "1. \"rawtransaction\" (string, required) A raw transaction in hex funding an already-existing address in wallet\n"
315 "2. \"txoutproof\" (string, required) The hex output from gettxoutproof that contains the transaction\n"
336 if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()]))
360 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No addresses in wallet correspond to included transaction");
373 "\nDeletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will affect wallet balances.\n"
377 + HelpExampleCli("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"") +
379 + HelpExampleRpc("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"")
411 "\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n"
416 "\nNote: This call can take minutes to complete if rescan is true, during that time, other rpc calls\n"
417 "may report that the imported pubkey exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
442 throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
478 "\nImports keys from a wallet dump file (see dumpwallet). Requires a new wallet backup to include imported keys.\n"
495 throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
517 pwallet->ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100))));
604 "1. \"filename\" (string, required) The Electrum wallet export file, should be in csv or json format\n"
605 "2. index (numeric, optional, default=0) Rescan the wallet for transactions starting from this block index\n"
645 pwallet->ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100))));
721 throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
768 throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");
787 " \"mnemonicpassphrase\": \"passphrase\", (string) The mnemonic passphrase for this HD wallet (bip39)\n"
827 "\nDumps all wallet keys in a human-readable format to a server-side file. This does not allow overwriting existing files.\n"
828 "Imported scripts are included in the dumpfile too, their corresponding addresses will be added automatically by importwallet.\n"
829 "Note that if your wallet contains keys which are not derived from your HD seed (e.g. imported keys), these are not covered by\n"
830 "only backing up the seed itself, and must be backed up too (e.g. ensure you back up the whole dumpfile).\n"
851 throw JSONRPCError(RPC_INVALID_PARAMETER, filepath.string() + " already exists. If you are sure this is what you want, move it out of the way first");
879 file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
934 for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
948 file << strprintf(" # addr=%s%s\n", strAddr, (pwallet->mapHdPubKeys.count(keyid) ? " hdkeypath="+pwallet->mapHdPubKeys[keyid].GetKeyPath() : ""));
970 std::string strWarning = strprintf(_("%s file contains all private keys from this wallet. Do not share it with anyone!"), request.params[0].get_str().c_str());
988 if (!(scriptPubKey.getType() == UniValue::VOBJ && scriptPubKey.exists("address")) && !(scriptPubKey.getType() == UniValue::VSTR)) {
993 const std::string& strRedeemScript = data.exists("redeemscript") ? data["redeemscript"].get_str() : "";
1002 const std::string& output = isScript ? scriptPubKey.get_str() : scriptPubKey["address"].get_str();
1075 throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
1166 throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
1184 throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
1239 throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
1256 throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
1301 throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Expected number or \"now\" timestamp value for key. got type %s", uvTypeName(timestamp.type())));
1317 "Import addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning all addresses in one-shot-only (rescan can be disabled via options). Requires a new wallet backup.\n\n"
1322 " \"scriptPubKey\": \"<script>\" | { \"address\":\"<address>\" }, (string / json, required) Type of scriptPubKey (string for script, json for address)\n"
1323 " \"timestamp\": timestamp | \"now\" , (integer / string, required) Creation time of the key in seconds since epoch (Jan 1 1970 GMT),\n"
1324 " or the string \"now\" to substitute the current synced blockchain time. The timestamp of the oldest\n"
1325 " key will determine how far back blockchain rescans need to begin for missing wallet transactions.\n"
1326 " \"now\" can be specified to bypass scanning, for keys which are known to never have been used, and\n"
1327 " 0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest key\n"
1329 " \"redeemscript\": \"<script>\" , (string, optional) Allowed only if the scriptPubKey is a P2SH address or a P2SH scriptPubKey\n"
1330 " \"pubkeys\": [\"<pubKey>\", ... ] , (array, optional) Array of strings giving pubkeys that must occur in the output or redeemscript\n"
1331 " \"keys\": [\"<key>\", ... ] , (array, optional) Array of strings giving private keys whose corresponding public keys must occur in the output or redeemscript\n"
1332 " \"internal\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be treated as not incoming payments\n"
1333 " \"watchonly\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be considered watched even when they're not spendable, only allowed if keys are empty\n"
1334 " \"label\": <label> , (string, optional, default: '') Label to assign to the address (aka account name, for now), only allowed with internal=false\n"
1340 " \"rescan\": <false>, (boolean, optional, default: true) Stating if should rescan the blockchain after all imports\n"
1342 "\nNote: This call can take minutes to complete if rescan is true, during that time, other rpc calls\n"
1343 "may report that the imported keys, addresses or scripts exists but related transactions are still missing.\n"
1345 HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }, "
1346 "{ \"scriptPubKey\": { \"address\": \"<my 2nd address>\" }, \"label\": \"example 2\", \"timestamp\": 1455191480 }]'") +
1347 HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }]' '{ \"rescan\": false}'") +
1350 " [{ \"success\": true } , { \"success\": false, \"error\": { \"code\": -1, \"message\": \"Internal Server Error\"} }, ... ]\n");
1371 throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
static std::string EncodeDumpString(const std::string &str)
Definition: rpcdump.cpp:48
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:80
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:158
void GetKeyBirthTimes(std::map< CTxDestination, int64_t > &mapKeyBirth) const
Definition: wallet.cpp:4856
const std::map< CKeyID, int64_t > & GetAllReserveKeys() const
Definition: wallet.h:1122
std::map< CTxDestination, CAddressBookData > mapAddressBook
Definition: wallet.h:906
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
Definition: key.cpp:207
bool EnsureWalletIsAvailable(CWallet *const pwallet, bool avoidException)
Definition: rpcwallet.cpp:66
Definition: protocol.h:44
bool HaveCScript(const CScriptID &hash) const override
Definition: keystore.cpp:74
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
Definition: utiltime.cpp:93
std::set< CScriptID > GetCScripts() const override
Definition: keystore.cpp:80
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override
Adds a key to the store, and saves it to disk.
Definition: wallet.cpp:405
bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
Definition: keystore.cpp:90
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
Definition: standard.cpp:281
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
Definition: utilstrencodings.h:100
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:57
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
Definition: standard.cpp:264
Definition: univalue.h:20
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: server.cpp:583
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:103
Definition: univalue.h:22
UniValue importelectrumwallet(const JSONRPCRequest &request)
Definition: rpcdump.cpp:593
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
Definition: core_read.cpp:90
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Definition: pubkey.h:149
bool AddWatchOnly(const CScript &dest) override
Private version of AddWatchOnly method which does not accept a timestamp, and which will reset the wa...
Definition: wallet.cpp:490
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValue::VType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
Definition: server.cpp:54
std::map< CScriptID, CKeyMetadata > m_script_metadata
Definition: wallet.h:856
Definition: hdchain.h:10
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition: wallet.cpp:4277
Definition: univalue.h:22
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
Definition: merkleblock.h:127
bool AddCScript(const CScript &redeemScript) override
Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki.
Definition: wallet.cpp:467
bool GetKey(const CKeyID &address, CKey &keyOut) const override
GetKey implementation that can derive a HD private key on the fly.
Definition: wallet.cpp:300
void ImportScript(CWallet *const pwallet, const CScript &script, const std::string &strLabel, bool isRedeemScript)
Definition: rpcdump.cpp:190
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
Definition: chain.h:471
std::vector< unsigned char, secure_allocator< unsigned char > > SecureVector
Definition: secure.h:59
UniValue removeprunedfunds(const JSONRPCRequest &request)
Definition: rpcdump.cpp:363
virtual bool GetHDChain(CHDChain &hdChainRet) const override
Definition: crypter.cpp:539
Definition: univalue.h:22
void UpdateTimeFirstKey(int64_t nCreateTime)
Update wallet first key creation time.
Definition: wallet.cpp:455
bool pushKV(const std::string &key, const UniValue &val)
Definition: univalue.cpp:135
UniValue ProcessImport(CWallet *const pwallet, const UniValue &data, const int64_t timestamp)
Definition: rpcdump.cpp:979
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut)
Definition: wallet.cpp:4220
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:256
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: server.cpp:578
static std::pair< std::string, UniValue > Pair(const char *cKey, const char *cVal)
Definition: univalue.h:185
bool AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose=true)
Definition: wallet.cpp:1094
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:280
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string strName)
Definition: server.cpp:138
CBlockIndex * ScanForWalletTransactions(CBlockIndex *pindexStart, CBlockIndex *pindexStop, const WalletRescanReserver &reserver, bool fUpdate=false)
Scan the block chain (starting in pindexStart) for transactions from or to us.
Definition: wallet.cpp:2030
int64_t GetImportTimestamp(const UniValue &data, int64_t now)
Definition: rpcdump.cpp:1292
bool GetMnemonic(SecureVector &vchMnemonicRet, SecureVector &vchMnemonicPassphraseRet) const
Definition: hdchain.cpp:107
Definition: hdchain.h:28
std::string EncodeDestination(const CTxDestination &dest)
Definition: base58.cpp:329
Definition: ismine.h:25
Definition: walletdb.h:51
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
Definition: chain.h:453
Definition: server.h:37
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:715
bool GetAccount(uint32_t nAccountIndex, CHDAccount &hdAccountRet)
Definition: hdchain.cpp:184
CWallet * GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
Definition: rpcwallet.cpp:45
void SetMaster(const unsigned char *seed, unsigned int nSeedLen)
Definition: key.cpp:276
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:1200
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:22
void ImportAddress(CWallet *, const CTxDestination &dest, const std::string &strLabel)
Definition: rpcdump.cpp:215
bool HaveWatchOnly(const CScript &dest) const override
Definition: keystore.cpp:138
Definition: pubkey.h:200
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
Definition: wallet.cpp:1993
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
Definition: validation.cpp:217
bool GetDecryptedHDChain(CHDChain &hdChainRet)
Definition: wallet.cpp:1826
Definition: serialize.h:160
Definition: base58.h:114
const std::string CLIENT_BUILD
static const int64_t TIMESTAMP_WINDOW
Timestamp window used as a grace period by code that compares external timestamps (such as timestamps...
Definition: chain.h:29
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
Definition: ismine.cpp:28
UniValue importprunedfunds(const JSONRPCRequest &request)
Definition: rpcdump.cpp:302
bool HaveKey(const CKeyID &address) const override
HaveKey implementation that also checks the mapHdPubKeys.
Definition: wallet.cpp:328
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Definition: util.h:92
Error parsing or validating structure in raw format.
Definition: protocol.h:55
void EnsureWalletIsUnlocked(CWallet *const pwallet)
Definition: rpcwallet.cpp:83