mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
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:
@@ -1909,7 +1909,13 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
|
||||
int witnessversion = 0;
|
||||
std::vector<unsigned char> 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