diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-01-24 15:22:24 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-01-24 15:22:42 +0100 |
commit | 95941396fff81f60d75fc8cca70716b26efe820e (patch) | |
tree | 1a1ed10eb683048f9b78f1b50adcabad8e0aa410 /src/wallet/rpcwallet.cpp | |
parent | 126000ba9e7ff16271be2f4eef3df99ade8d624f (diff) | |
parent | 596c44633fd03e76cc12f2fd37452e223ba43115 (diff) | |
download | bitcoin-95941396fff81f60d75fc8cca70716b26efe820e.tar.xz |
Merge #12119: [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH
596c446 [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH (Sjors Provoost)
Pull request description:
If `-changetype` is not explicitly set, then regardless of `-addresstype`, the wallet will use a ~`bech32` change address~ `P2WPKH` change output if any destination is `P2WPKH` or `P2WSH`.
This seems more intuitive to me and more in line with the spirit of [BIP-69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki).
When combined with #11991 a QT user could opt to use `bech32` exclusively without having to figure out how to launch with `-changetype=bech32`, although so would #11937.
Tree-SHA512: 9238d3ccd1f3be8dfdd43444ccf45d6bdc6584ced3172a3045f3ecfec4a7cc8999db0cdb76ae49236492a84e6dbf3a1fdf18544d3eaf6d518e1f8bd241db33e7
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r-- | src/wallet/rpcwallet.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a77a886428..6849671dcf 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -257,9 +257,9 @@ UniValue getrawchangeaddress(const JSONRPCRequest& request) pwallet->TopUpKeyPool(); } - OutputType output_type = g_change_type; + OutputType output_type = g_change_type != OUTPUT_TYPE_NONE ? g_change_type : g_address_type; if (!request.params[0].isNull()) { - output_type = ParseOutputType(request.params[0].get_str(), g_change_type); + output_type = ParseOutputType(request.params[0].get_str(), output_type); if (output_type == OUTPUT_TYPE_NONE) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str())); } |