wallet: avoid reuse flags

Add m_avoid_address_reuse flag to coin control object.
Add avoid_reuse wallet flag and accompanying strings/caveats.
This commit is contained in:
Karl-Johan Alm
2018-07-25 16:24:55 +09:00
parent 58928098c2
commit eec15662fa
5 changed files with 40 additions and 1 deletions

View File

@@ -47,6 +47,17 @@
static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
static inline bool GetAvoidReuseFlag(CWallet * const pwallet, const UniValue& param) {
bool can_avoid_reuse = pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE);
bool avoid_reuse = param.isNull() ? can_avoid_reuse : param.get_bool();
if (avoid_reuse && !can_avoid_reuse) {
throw JSONRPCError(RPC_WALLET_ERROR, "wallet does not have the \"avoid reuse\" feature enabled");
}
return avoid_reuse;
}
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request, std::string& wallet_name)
{
if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == WALLET_ENDPOINT_BASE) {