aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2018-03-19 15:57:11 -0400
committerRussell Yanofsky <russ@yanofsky.org>2018-04-05 12:19:35 -0400
commit1e46d8ae897aded3367a2dd63a76991882d170fa (patch)
treeb3738f95b2c05a6e712576a9c6d08a128391fe65 /src/wallet/wallet.h
parent5f0c6a7b0e47e03f848dc992d37fe209dd9c6975 (diff)
downloadbitcoin-1e46d8ae897aded3367a2dd63a76991882d170fa.tar.xz
Get rid of ambiguous OutputType::NONE value
Based on suggestion by Pieter Wuille <pieter.wuille@gmail.com> at https://github.com/bitcoin/bitcoin/pull/12119#issuecomment-357982763 After #12119, the NONE output type was overloaded to refer to either an output type that couldn't be parsed, or to an automatic change output mode. This change drops the NONE enum and uses a simple bool indicate parse failure, and a new CHANGE_AUTO enum to refer the change output type. This change is almost a pure refactoring except it makes RPCs reject empty string ("") address types instead of treating them like they were unset. This simplifies the parsing code a little bit and could prevent RPC usage mistakes. It's noted in the release notes.
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 898c32c708..1d85fbcea1 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -99,15 +99,24 @@ enum WalletFeature
};
enum class OutputType {
- NONE,
LEGACY,
P2SH_SEGWIT,
BECH32,
+
+ /**
+ * Special output type for change outputs only. Automatically choose type
+ * based on address type setting and the types other of non-change outputs
+ * (see -changetype option documentation and implementation in
+ * CWallet::TransactionChangeType for details).
+ */
+ CHANGE_AUTO,
};
//! Default for -addresstype
constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::P2SH_SEGWIT};
+//! Default for -changetype
+constexpr OutputType DEFAULT_CHANGE_TYPE{OutputType::CHANGE_AUTO};
/** A key pool entry */
class CKeyPool
@@ -988,7 +997,7 @@ public:
static CFeeRate fallbackFee;
static CFeeRate m_discard_rate;
OutputType m_default_address_type{DEFAULT_ADDRESS_TYPE};
- OutputType m_default_change_type{OutputType::NONE}; // Default to OutputType::NONE if not set by -changetype
+ OutputType m_default_change_type{DEFAULT_CHANGE_TYPE};
bool NewKeyPool();
size_t KeypoolCountExternalKeys();
@@ -1232,7 +1241,7 @@ public:
}
};
-OutputType ParseOutputType(const std::string& str, OutputType default_type);
+bool ParseOutputType(const std::string& str, OutputType& output_type);
const std::string& FormatOutputType(OutputType type);
/**