mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
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:
parent
58928098c2
commit
eec15662fa
5 changed files with 40 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ void CCoinControl::SetNull()
|
||||||
fAllowOtherInputs = false;
|
fAllowOtherInputs = false;
|
||||||
fAllowWatchOnly = false;
|
fAllowWatchOnly = false;
|
||||||
m_avoid_partial_spends = gArgs.GetBoolArg("-avoidpartialspends", DEFAULT_AVOIDPARTIALSPENDS);
|
m_avoid_partial_spends = gArgs.GetBoolArg("-avoidpartialspends", DEFAULT_AVOIDPARTIALSPENDS);
|
||||||
|
m_avoid_address_reuse = false;
|
||||||
setSelected.clear();
|
setSelected.clear();
|
||||||
m_feerate.reset();
|
m_feerate.reset();
|
||||||
fOverrideFeeRate = false;
|
fOverrideFeeRate = false;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ public:
|
||||||
boost::optional<bool> m_signal_bip125_rbf;
|
boost::optional<bool> m_signal_bip125_rbf;
|
||||||
//! Avoid partial use of funds sent to a given address
|
//! Avoid partial use of funds sent to a given address
|
||||||
bool m_avoid_partial_spends;
|
bool m_avoid_partial_spends;
|
||||||
|
//! Forbids inclusion of dirty (previously used) addresses
|
||||||
|
bool m_avoid_address_reuse;
|
||||||
//! Fee estimation mode to control arguments to estimateSmartFee
|
//! Fee estimation mode to control arguments to estimateSmartFee
|
||||||
FeeEstimateMode m_fee_mode;
|
FeeEstimateMode m_fee_mode;
|
||||||
//! Minimum chain depth value for coin availability
|
//! Minimum chain depth value for coin availability
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,17 @@
|
||||||
|
|
||||||
static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
|
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)
|
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request, std::string& wallet_name)
|
||||||
{
|
{
|
||||||
if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == WALLET_ENDPOINT_BASE) {
|
if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == WALLET_ENDPOINT_BASE) {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,14 @@
|
||||||
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
|
||||||
|
const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS{
|
||||||
|
{WALLET_FLAG_AVOID_REUSE,
|
||||||
|
"You need to rescan the blockchain in order to correctly mark used "
|
||||||
|
"destinations in the past. Until this is done, some destinations may "
|
||||||
|
"be considered unused, even if the opposite is the case."
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
static const size_t OUTPUT_GROUP_MAX_ENTRIES = 10;
|
static const size_t OUTPUT_GROUP_MAX_ENTRIES = 10;
|
||||||
|
|
||||||
static CCriticalSection cs_wallets;
|
static CCriticalSection cs_wallets;
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,10 @@ enum WalletFlags : uint64_t {
|
||||||
// wallet flags in the upper section (> 1 << 31) will lead to not opening the wallet if flag is unknown
|
// wallet flags in the upper section (> 1 << 31) will lead to not opening the wallet if flag is unknown
|
||||||
// unknown wallet flags in the lower section <= (1 << 31) will be tolerated
|
// unknown wallet flags in the lower section <= (1 << 31) will be tolerated
|
||||||
|
|
||||||
|
// will categorize coins as clean (not reused) and dirty (reused), and handle
|
||||||
|
// them with privacy considerations in mind
|
||||||
|
WALLET_FLAG_AVOID_REUSE = (1ULL << 0),
|
||||||
|
|
||||||
// Indicates that the metadata has already been upgraded to contain key origins
|
// Indicates that the metadata has already been upgraded to contain key origins
|
||||||
WALLET_FLAG_KEY_ORIGIN_METADATA = (1ULL << 1),
|
WALLET_FLAG_KEY_ORIGIN_METADATA = (1ULL << 1),
|
||||||
|
|
||||||
|
|
@ -139,7 +143,20 @@ enum WalletFlags : uint64_t {
|
||||||
WALLET_FLAG_BLANK_WALLET = (1ULL << 33),
|
WALLET_FLAG_BLANK_WALLET = (1ULL << 33),
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr uint64_t KNOWN_WALLET_FLAGS = WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_BLANK_WALLET | WALLET_FLAG_KEY_ORIGIN_METADATA;
|
static constexpr uint64_t KNOWN_WALLET_FLAGS =
|
||||||
|
WALLET_FLAG_AVOID_REUSE
|
||||||
|
| WALLET_FLAG_BLANK_WALLET
|
||||||
|
| WALLET_FLAG_KEY_ORIGIN_METADATA
|
||||||
|
| WALLET_FLAG_DISABLE_PRIVATE_KEYS;
|
||||||
|
|
||||||
|
static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
|
||||||
|
{"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
|
||||||
|
{"blank", WALLET_FLAG_BLANK_WALLET},
|
||||||
|
{"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
|
||||||
|
{"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS;
|
||||||
|
|
||||||
/** A key from a CWallet's keypool
|
/** A key from a CWallet's keypool
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue