Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 622 Lines • ▼ Show 20 Lines | static UniValue signmessage(const Config &config, | ||||
std::string strMessage = request.params[1].get_str(); | std::string strMessage = request.params[1].get_str(); | ||||
CTxDestination dest = | CTxDestination dest = | ||||
DecodeDestination(strAddress, config.GetChainParams()); | DecodeDestination(strAddress, config.GetChainParams()); | ||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); | throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); | ||||
} | } | ||||
const CKeyID *keyID = boost::get<CKeyID>(&dest); | const PKHash *pkhash = boost::get<PKHash>(&dest); | ||||
if (!keyID) { | if (!pkhash) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); | throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); | ||||
} | } | ||||
CKey key; | CKey key; | ||||
if (!pwallet->GetKey(*keyID, key)) { | CKeyID keyID(*pkhash); | ||||
if (!pwallet->GetKey(keyID, key)) { | |||||
throw JSONRPCError(RPC_WALLET_ERROR, "Private key not available"); | throw JSONRPCError(RPC_WALLET_ERROR, "Private key not available"); | ||||
} | } | ||||
CHashWriter ss(SER_GETHASH, 0); | CHashWriter ss(SER_GETHASH, 0); | ||||
ss << strMessageMagic; | ss << strMessageMagic; | ||||
ss << strMessage; | ss << strMessage; | ||||
std::vector<uint8_t> vchSig; | std::vector<uint8_t> vchSig; | ||||
▲ Show 20 Lines • Show All 2,796 Lines • ▼ Show 20 Lines | for (const COutput &out : vecOutputs) { | ||||
entry.pushKV("address", EncodeDestination(address, config)); | entry.pushKV("address", EncodeDestination(address, config)); | ||||
auto i = pwallet->mapAddressBook.find(address); | auto i = pwallet->mapAddressBook.find(address); | ||||
if (i != pwallet->mapAddressBook.end()) { | if (i != pwallet->mapAddressBook.end()) { | ||||
entry.pushKV("label", i->second.name); | entry.pushKV("label", i->second.name); | ||||
} | } | ||||
if (scriptPubKey.IsPayToScriptHash()) { | if (scriptPubKey.IsPayToScriptHash()) { | ||||
const CScriptID &hash = boost::get<CScriptID>(address); | const CScriptID &hash = | ||||
CScriptID(boost::get<ScriptHash>(address)); | |||||
CScript redeemScript; | CScript redeemScript; | ||||
if (pwallet->GetCScript(hash, redeemScript)) { | if (pwallet->GetCScript(hash, redeemScript)) { | ||||
entry.pushKV("redeemScript", HexStr(redeemScript.begin(), | entry.pushKV("redeemScript", HexStr(redeemScript.begin(), | ||||
redeemScript.end())); | redeemScript.end())); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 578 Lines • ▼ Show 20 Lines | public: | ||||
explicit DescribeWalletAddressVisitor(CWallet *_pwallet) | explicit DescribeWalletAddressVisitor(CWallet *_pwallet) | ||||
: pwallet(_pwallet) {} | : pwallet(_pwallet) {} | ||||
UniValue operator()(const CNoDestination &dest) const { | UniValue operator()(const CNoDestination &dest) const { | ||||
return UniValue(UniValue::VOBJ); | return UniValue(UniValue::VOBJ); | ||||
} | } | ||||
UniValue operator()(const CKeyID &keyID) const { | UniValue operator()(const PKHash &pkhash) const { | ||||
CKeyID keyID(pkhash); | |||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
if (pwallet && pwallet->GetPubKey(keyID, vchPubKey)) { | if (pwallet && pwallet->GetPubKey(keyID, vchPubKey)) { | ||||
obj.pushKV("pubkey", HexStr(vchPubKey)); | obj.pushKV("pubkey", HexStr(vchPubKey)); | ||||
obj.pushKV("iscompressed", vchPubKey.IsCompressed()); | obj.pushKV("iscompressed", vchPubKey.IsCompressed()); | ||||
} | } | ||||
return obj; | return obj; | ||||
} | } | ||||
UniValue operator()(const CScriptID &scriptID) const { | UniValue operator()(const ScriptHash &scripthash) const { | ||||
CScriptID scriptID(scripthash); | |||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
CScript subscript; | CScript subscript; | ||||
if (pwallet && pwallet->GetCScript(scriptID, subscript)) { | if (pwallet && pwallet->GetCScript(scriptID, subscript)) { | ||||
ProcessSubScript(subscript, obj); | ProcessSubScript(subscript, obj); | ||||
} | } | ||||
return obj; | return obj; | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 739 Lines • Show Last 20 Lines |