Skip to content

Commit fecc1be

Browse files
committed
Merge bitcoin#16884: wallet: Change default address type to bech32
71d4edd Add release note for bech32 by default in wallet (Gregory Sanders) b34f018 Revert "gui: Generate bech32 addresses by default (take 2, fixup)" (Gregory Sanders) f50785a Change default address type to bech32 (Gregory Sanders) Pull request description: ACKs for top commit: MarcoFalke: re-ACK 71d4edd (only change is restore mimick behavior) laanwj: ACK 71d4edd Tree-SHA512: 3c49a1b51c49f3a762ad08985167ca1b89b0177ae20ab6d5883f1f74dde7a155921c1b855a842199bbf32f563c56b33f8b603bc842637bdcb121001023d454b6
2 parents ccaef6c + 71d4edd commit fecc1be

11 files changed

+16
-21
lines changed

doc/release-notes-16884.md

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

src/interfaces/node.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ class NodeImpl : public Node
201201
return GuessVerificationProgress(Params().TxData(), tip);
202202
}
203203
bool isInitialBlockDownload() override { return ::ChainstateActive().IsInitialBlockDownload(); }
204-
bool isAddressTypeSet() override { return !::gArgs.GetArg("-addresstype", "").empty(); }
205204
bool getReindex() override { return ::fReindex; }
206205
bool getImporting() override { return ::fImporting; }
207206
void setNetworkActive(bool active) override

src/interfaces/node.h

-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ class Node
155155
//! Is initial block download.
156156
virtual bool isInitialBlockDownload() = 0;
157157

158-
//! Is -addresstype set.
159-
virtual bool isAddressTypeSet() = 0;
160-
161158
//! Get reindex.
162159
virtual bool getReindex() = 0;
163160

src/qt/receivecoinsdialog.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <qt/receivecoinsdialog.h>
88
#include <qt/forms/ui_receivecoinsdialog.h>
99

10-
#include <interfaces/node.h>
1110
#include <qt/addresstablemodel.h>
1211
#include <qt/optionsmodel.h>
1312
#include <qt/platformstyle.h>
@@ -93,16 +92,10 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model)
9392
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
9493
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this);
9594

96-
if (model->node().isAddressTypeSet()) {
97-
// user explicitly set the type, use it
98-
if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
99-
ui->useBech32->setCheckState(Qt::Checked);
100-
} else {
101-
ui->useBech32->setCheckState(Qt::Unchecked);
102-
}
103-
} else {
104-
// Always fall back to bech32 in the gui
95+
if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
10596
ui->useBech32->setCheckState(Qt::Checked);
97+
} else {
98+
ui->useBech32->setCheckState(Qt::Unchecked);
10699
}
107100

108101
// Set the button to be enabled or disabled based on whether the wallet can give out new addresses.

src/wallet/wallet.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ enum WalletFeature
120120
};
121121

122122
//! Default for -addresstype
123-
constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::P2SH_SEGWIT};
123+
constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::BECH32};
124124

125125
//! Default for -changetype
126126
constexpr OutputType DEFAULT_CHANGE_TYPE{OutputType::CHANGE_AUTO};

test/functional/feature_bip68_sequence.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
class BIP68Test(BitcoinTestFramework):
3030
def set_test_params(self):
3131
self.num_nodes = 2
32+
# TODO remove output type argument and fix resulting "tx-size-small" errors
3233
self.extra_args = [
33-
["-acceptnonstdtxn=1"],
34-
["-acceptnonstdtxn=0"],
34+
["-acceptnonstdtxn=1", "-addresstype=p2sh-segwit"],
35+
["-acceptnonstdtxn=0", "-addresstype=p2sh-segwit"],
3536
]
3637

3738
def skip_test_if_missing_module(self):

test/functional/feature_rbf.py

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def make_utxo(node, amount, confirmed=True, scriptPubKey=CScript([1])):
6565
class ReplaceByFeeTest(BitcoinTestFramework):
6666
def set_test_params(self):
6767
self.num_nodes = 1
68+
# TODO remove output type argument and fix resulting "tx-size-small" errors
6869
self.extra_args = [
6970
[
7071
"-acceptnonstdtxn=1",
@@ -73,6 +74,7 @@ def set_test_params(self):
7374
"-limitancestorsize=101",
7475
"-limitdescendantcount=200",
7576
"-limitdescendantsize=101",
77+
"-addresstype=p2sh-segwit",
7678
],
7779
]
7880

test/functional/wallet_address_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def run_test(self):
345345
self.sync_blocks()
346346
assert_equal(self.nodes[4].getbalance(), 1)
347347

348-
self.log.info("Nodes with addresstype=legacy never use a P2WPKH change output")
348+
self.log.info("Nodes with addresstype=legacy never use a P2WPKH change output (unless changetype is set otherwise):")
349349
self.test_change_output_type(0, [to_address_bech32_1], 'legacy')
350350

351351
self.log.info("Nodes with addresstype=p2sh-segwit only use a P2WPKH change output if any destination address is bech32:")

test/functional/wallet_basic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def run_test(self):
317317
assert_raises_rpc_error(-5, "Invalid private key encoding", self.nodes[0].importprivkey, "invalid")
318318

319319
# This will raise an exception for importing an address with the PS2H flag
320-
temp_address = self.nodes[1].getnewaddress()
320+
temp_address = self.nodes[1].getnewaddress("", "p2sh-segwit")
321321
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)
322322

323323
# This will raise an exception for attempting to dump the private key of an address you do not own

test/functional/wallet_bumpfee.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def set_test_params(self):
3838
"-walletrbf={}".format(i),
3939
"-mintxfee=0.00002",
4040
"-deprecatedrpc=totalFee",
41+
"-addresstype=p2sh-segwit", # TODO update constants in test and remove
4142
] for i in range(self.num_nodes)]
4243

4344
def skip_test_if_missing_module(self):

test/functional/wallet_import_with_label.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def run_test(self):
100100
"Test importprivkey won't label new dests with the same "
101101
"label as others labeled dests for the same key."
102102
)
103-
self.log.info("Import a watch-only legacy address with a label.")
104-
address4 = self.nodes[0].getnewaddress()
103+
self.log.info("Import a watch-only p2sh-segwit address with a label.")
104+
address4 = self.nodes[0].getnewaddress("", "p2sh-segwit")
105105
label4_addr = "Test Label 4 for importaddress"
106106
self.nodes[1].importaddress(address4, label4_addr)
107107
test_address(self.nodes[1],

0 commit comments

Comments
 (0)