Merge #16884: wallet: Change default address type to bech32

71d4eddf42 Add release note for bech32 by default in wallet (Gregory Sanders)
b34f0180e3 Revert "gui: Generate bech32 addresses by default (take 2, fixup)" (Gregory Sanders)
f50785ab56 Change default address type to bech32 (Gregory Sanders)

Pull request description:

ACKs for top commit:
  MarcoFalke:
    re-ACK 71d4eddf42 (only change is restore mimick behavior)
  laanwj:
    ACK 71d4eddf42

Tree-SHA512: 3c49a1b51c49f3a762ad08985167ca1b89b0177ae20ab6d5883f1f74dde7a155921c1b855a842199bbf32f563c56b33f8b603bc842637bdcb121001023d454b6
pull/764/head
Wladimir J. van der Laan 5 years ago
commit fecc1be231
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D

@ -0,0 +1,2 @@
The wallet now by default uses bech32 addresses when using RPC, and creates native segwit
change outputs.

@ -201,7 +201,6 @@ public:
return GuessVerificationProgress(Params().TxData(), tip);
}
bool isInitialBlockDownload() override { return ::ChainstateActive().IsInitialBlockDownload(); }
bool isAddressTypeSet() override { return !::gArgs.GetArg("-addresstype", "").empty(); }
bool getReindex() override { return ::fReindex; }
bool getImporting() override { return ::fImporting; }
void setNetworkActive(bool active) override

@ -155,9 +155,6 @@ public:
//! Is initial block download.
virtual bool isInitialBlockDownload() = 0;
//! Is -addresstype set.
virtual bool isAddressTypeSet() = 0;
//! Get reindex.
virtual bool getReindex() = 0;

@ -7,7 +7,6 @@
#include <qt/receivecoinsdialog.h>
#include <qt/forms/ui_receivecoinsdialog.h>
#include <interfaces/node.h>
#include <qt/addresstablemodel.h>
#include <qt/optionsmodel.h>
#include <qt/platformstyle.h>
@ -93,16 +92,10 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model)
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this);
if (model->node().isAddressTypeSet()) {
// user explicitly set the type, use it
if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
ui->useBech32->setCheckState(Qt::Checked);
} else {
ui->useBech32->setCheckState(Qt::Unchecked);
}
} else {
// Always fall back to bech32 in the gui
if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
ui->useBech32->setCheckState(Qt::Checked);
} else {
ui->useBech32->setCheckState(Qt::Unchecked);
}
// Set the button to be enabled or disabled based on whether the wallet can give out new addresses.

@ -120,7 +120,7 @@ enum WalletFeature
};
//! Default for -addresstype
constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::P2SH_SEGWIT};
constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::BECH32};
//! Default for -changetype
constexpr OutputType DEFAULT_CHANGE_TYPE{OutputType::CHANGE_AUTO};

@ -29,9 +29,10 @@ NOT_FINAL_ERROR = "non-BIP68-final (code 64)"
class BIP68Test(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
# TODO remove output type argument and fix resulting "tx-size-small" errors
self.extra_args = [
["-acceptnonstdtxn=1"],
["-acceptnonstdtxn=0"],
["-acceptnonstdtxn=1", "-addresstype=p2sh-segwit"],
["-acceptnonstdtxn=0", "-addresstype=p2sh-segwit"],
]
def skip_test_if_missing_module(self):

@ -65,6 +65,7 @@ def make_utxo(node, amount, confirmed=True, scriptPubKey=CScript([1])):
class ReplaceByFeeTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
# TODO remove output type argument and fix resulting "tx-size-small" errors
self.extra_args = [
[
"-acceptnonstdtxn=1",
@ -73,6 +74,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
"-limitancestorsize=101",
"-limitdescendantcount=200",
"-limitdescendantsize=101",
"-addresstype=p2sh-segwit",
],
]

@ -345,7 +345,7 @@ class AddressTypeTest(BitcoinTestFramework):
self.sync_blocks()
assert_equal(self.nodes[4].getbalance(), 1)
self.log.info("Nodes with addresstype=legacy never use a P2WPKH change output")
self.log.info("Nodes with addresstype=legacy never use a P2WPKH change output (unless changetype is set otherwise):")
self.test_change_output_type(0, [to_address_bech32_1], 'legacy')
self.log.info("Nodes with addresstype=p2sh-segwit only use a P2WPKH change output if any destination address is bech32:")

@ -317,7 +317,7 @@ class WalletTest(BitcoinTestFramework):
assert_raises_rpc_error(-5, "Invalid private key encoding", self.nodes[0].importprivkey, "invalid")
# This will raise an exception for importing an address with the PS2H flag
temp_address = self.nodes[1].getnewaddress()
temp_address = self.nodes[1].getnewaddress("", "p2sh-segwit")
assert_raises_rpc_error(-5, "Cannot use the p2sh flag with an address - use a script instead", self.nodes[0].importaddress, temp_address, "label", False, True)
# This will raise an exception for attempting to dump the private key of an address you do not own

@ -38,6 +38,7 @@ class BumpFeeTest(BitcoinTestFramework):
"-walletrbf={}".format(i),
"-mintxfee=0.00002",
"-deprecatedrpc=totalFee",
"-addresstype=p2sh-segwit", # TODO update constants in test and remove
] for i in range(self.num_nodes)]
def skip_test_if_missing_module(self):

@ -100,8 +100,8 @@ class ImportWithLabel(BitcoinTestFramework):
"Test importprivkey won't label new dests with the same "
"label as others labeled dests for the same key."
)
self.log.info("Import a watch-only legacy address with a label.")
address4 = self.nodes[0].getnewaddress()
self.log.info("Import a watch-only p2sh-segwit address with a label.")
address4 = self.nodes[0].getnewaddress("", "p2sh-segwit")
label4_addr = "Test Label 4 for importaddress"
self.nodes[1].importaddress(address4, label4_addr)
test_address(self.nodes[1],

Loading…
Cancel
Save