update wallet section
This commit is contained in:
@@ -2,20 +2,20 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "base58.h"
|
||||
#include "chain.h"
|
||||
#include "dstencode.h"
|
||||
#include "rpc/server.h"
|
||||
#include "init.h"
|
||||
#include "main.h"
|
||||
#include "script/script.h"
|
||||
#include "script/standard.h"
|
||||
#include "sync.h"
|
||||
#include "util.h"
|
||||
#include "utiltime.h"
|
||||
#include "wallet.h"
|
||||
#include "merkleblock.h"
|
||||
#include "core_io.h"
|
||||
#include <base58.h>
|
||||
#include <chain.h>
|
||||
#include <dstencode.h>
|
||||
#include <rpc/server.h>
|
||||
#include <init.h>
|
||||
#include <main.h>
|
||||
#include <script/script.h>
|
||||
#include <script/standard.h>
|
||||
#include <sync.h>
|
||||
#include <util.h>
|
||||
#include <utiltime.h>
|
||||
#include <wallet/wallet.h>
|
||||
#include <merkleblock.h>
|
||||
#include <core_io.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <stdint.h>
|
||||
@@ -25,8 +25,6 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void EnsureWalletIsUnlocked();
|
||||
@@ -51,7 +49,7 @@ int64_t static DecodeDumpTime(const std::string &str) {
|
||||
|
||||
std::string static EncodeDumpString(const std::string &str) {
|
||||
std::stringstream ret;
|
||||
BOOST_FOREACH(unsigned char c, str) {
|
||||
for(unsigned char c: str) {
|
||||
if (c <= 32 || c >= 128 || c == '%') {
|
||||
ret << '%' << HexStr(&c, &c + 1);
|
||||
} else {
|
||||
@@ -66,7 +64,7 @@ std::string DecodeDumpString(const std::string &str) {
|
||||
for (unsigned int pos = 0; pos < str.length(); pos++) {
|
||||
unsigned char c = str[pos];
|
||||
if (c == '%' && pos+2 < str.length()) {
|
||||
c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) |
|
||||
c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) |
|
||||
((str[pos+2]>>6)*9+((str[pos+2]-'0')&15));
|
||||
pos += 2;
|
||||
}
|
||||
@@ -79,13 +77,13 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() < 1 || params.size() > 3)
|
||||
throw runtime_error(
|
||||
"importprivkey \"bitcoinprivkey\" ( \"label\" rescan )\n"
|
||||
"importprivkey \"blackcoinprivkey\" ( \"label\" rescan )\n"
|
||||
"\nAdds a private key (as returned by dumpprivkey) to your wallet.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"bitcoinprivkey\" (string, required) The private key (see dumpprivkey)\n"
|
||||
"1. \"blackcoinprivkey\" (string, required) The private key (see dumpprivkey)\n"
|
||||
"2. \"label\" (string, optional, default=\"\") An optional label\n"
|
||||
"3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n"
|
||||
"\nNote: This call can take minutes to complete if rescan is true.\n"
|
||||
@@ -213,7 +211,7 @@ UniValue importaddress(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() < 1 || params.size() > 4)
|
||||
throw runtime_error(
|
||||
"importaddress \"address\" ( \"label\" rescan p2sh )\n"
|
||||
@@ -258,11 +256,8 @@ UniValue importaddress(const UniValue& params, bool fHelp)
|
||||
|
||||
CTxDestination dest = DecodeDestination(params[0].get_str());
|
||||
if (IsValidDestination(dest)) {
|
||||
if (fP2SH) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY,
|
||||
"Cannot use the p2sh flag with an address - use "
|
||||
"a script instead");
|
||||
}
|
||||
if (fP2SH)
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Cannot use the p2sh flag with an address - use a script instead");
|
||||
ImportAddress(dest, strLabel);
|
||||
} else if (IsHex(params[0].get_str())) {
|
||||
std::vector<uint8_t> data(ParseHex(params[0].get_str()));
|
||||
@@ -438,7 +433,7 @@ UniValue importwallet(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"importwallet \"filename\"\n"
|
||||
@@ -493,8 +488,7 @@ UniValue importwallet(const UniValue& params, bool fHelp)
|
||||
assert(key.VerifyPubKey(pubkey));
|
||||
CKeyID keyid = pubkey.GetID();
|
||||
if (pwalletMain->HaveKey(keyid)) {
|
||||
LogPrintf("Skipping import of %s (key already present)\n",
|
||||
EncodeDestination(keyid));
|
||||
LogPrintf("Skipping import of %s (key already present)\n", EncodeDestination(keyid));
|
||||
continue;
|
||||
}
|
||||
int64_t nTime = DecodeDumpTime(vstr[1]);
|
||||
@@ -546,7 +540,7 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"dumpprivkey \"blackcoinaddress\"\n"
|
||||
@@ -589,7 +583,7 @@ UniValue dumpwallet(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"dumpwallet \"filename\"\n"
|
||||
@@ -624,13 +618,13 @@ UniValue dumpwallet(const UniValue& params, bool fHelp)
|
||||
std::sort(vKeyBirth.begin(), vKeyBirth.end());
|
||||
|
||||
// produce output
|
||||
file << strprintf("# Wallet dump created by Bitcoin %s\n", CLIENT_BUILD);
|
||||
file << strprintf("# Wallet dump created by Blackcoin %s\n", CLIENT_BUILD);
|
||||
file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime()));
|
||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
|
||||
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime()));
|
||||
file << "\n";
|
||||
|
||||
// add the base58check encoded extended master if the wallet uses HD
|
||||
// add the base58check encoded extended master if the wallet uses HD
|
||||
CKeyID masterKeyID = pwalletMain->GetHDChain().masterKeyID;
|
||||
if (!masterKeyID.IsNull())
|
||||
{
|
||||
@@ -646,7 +640,6 @@ UniValue dumpwallet(const UniValue& params, bool fHelp)
|
||||
file << "# extended private masterkey: " << b58extkey.ToString() << "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
|
||||
const CKeyID &keyid = it->second;
|
||||
std::string strTime = EncodeDumpTime(it->first);
|
||||
|
||||
Reference in New Issue
Block a user