Opportunistically use bech32m change addresses if available
If a transaction as a segwit output, use a bech32m change address if they are available. If not, fallback to bech32. If bech32 change addresses are unavailable, fallback to the default address type.
This commit is contained in:
1 parent
0262536c34
commit
699dfcd8ad
1 file changed
+7
-1
@@ -1909,7 +1909,13 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
|
|||||||
int witnessversion = 0;
|
int witnessversion = 0;
|
||||||
std::vector<unsigned char> witnessprogram;
|
std::vector<unsigned char> witnessprogram;
|
||||||
if (recipient.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
|
if (recipient.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
|
||||||
return OutputType::BECH32;
|
if (GetScriptPubKeyMan(OutputType::BECH32M, true)) {
|
||||||
|
return OutputType::BECH32M;
|
||||||
|
} else if (GetScriptPubKeyMan(OutputType::BECH32, true)) {
|
||||||
|
return OutputType::BECH32;
|
||||||
|
} else {
|
||||||
|
return m_default_address_type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user