Skip to content

Commit 6dbe4d1

Browse files
committed
Use BECH32M for tr() desc, WitV1Taproot, and WitUnknown CTxDests
The tr() descriptor, WitnessV1Taproot CTxDestination, and WitnessUnknown CTxDestination are OutputType::BECH32M so they should report as such.
1 parent 699dfcd commit 6dbe4d1

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/script/descriptor.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,13 @@ static std::optional<OutputType> OutputTypeFromDestination(const CTxDestination&
646646
return OutputType::LEGACY;
647647
}
648648
if (std::holds_alternative<WitnessV0KeyHash>(dest) ||
649-
std::holds_alternative<WitnessV0ScriptHash>(dest) ||
650-
std::holds_alternative<WitnessV1Taproot>(dest) ||
651-
std::holds_alternative<WitnessUnknown>(dest)) {
649+
std::holds_alternative<WitnessV0ScriptHash>(dest)) {
652650
return OutputType::BECH32;
653651
}
652+
if (std::holds_alternative<WitnessV1Taproot>(dest) ||
653+
std::holds_alternative<WitnessUnknown>(dest)) {
654+
return OutputType::BECH32M;
655+
}
654656
return std::nullopt;
655657
}
656658

@@ -874,7 +876,7 @@ class TRDescriptor final : public DescriptorImpl
874876
{
875877
assert(m_subdescriptor_args.size() == m_depths.size());
876878
}
877-
std::optional<OutputType> GetOutputType() const override { return OutputType::BECH32; }
879+
std::optional<OutputType> GetOutputType() const override { return OutputType::BECH32M; }
878880
bool IsSingleType() const final { return true; }
879881
};
880882

test/functional/wallet_taproot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def do_test_addr(self, comment, pattern, privmap, treefn, keys):
226226
result = self.addr_gen.importdescriptors([{"desc": desc_pub, "active": True, "timestamp": "now"}])
227227
assert(result[0]['success'])
228228
for i in range(4):
229-
addr_g = self.addr_gen.getnewaddress(address_type='bech32')
229+
addr_g = self.addr_gen.getnewaddress(address_type='bech32m')
230230
if treefn is not None:
231231
addr_r = self.make_addr(treefn, keys, i)
232232
assert_equal(addr_g, addr_r)
@@ -259,7 +259,7 @@ def do_test_sendtoaddress(self, comment, pattern, privmap, treefn, keys_pay, key
259259
result = self.rpc_online.importdescriptors([{"desc": desc_change, "active": True, "timestamp": "now", "internal": True}])
260260
assert(result[0]['success'])
261261
for i in range(4):
262-
addr_g = self.rpc_online.getnewaddress(address_type='bech32')
262+
addr_g = self.rpc_online.getnewaddress(address_type='bech32m')
263263
if treefn is not None:
264264
addr_r = self.make_addr(treefn, keys_pay, i)
265265
assert_equal(addr_g, addr_r)
@@ -290,7 +290,7 @@ def do_test_psbt(self, comment, pattern, privmap, treefn, keys_pay, keys_change)
290290
result = self.psbt_offline.importdescriptors([{"desc": desc_change, "active": True, "timestamp": "now", "internal": True}])
291291
assert(result[0]['success'])
292292
for i in range(4):
293-
addr_g = self.psbt_online.getnewaddress(address_type='bech32')
293+
addr_g = self.psbt_online.getnewaddress(address_type='bech32m')
294294
if treefn is not None:
295295
addr_r = self.make_addr(treefn, keys_pay, i)
296296
assert_equal(addr_g, addr_r)

0 commit comments

Comments
 (0)