Previously we failed to remove the change output if the wallet has
no internal keychain which caused tx building to fail at the new
higher feerate. Fix this by mapping the internal keychain to the
de-facto change keychain so that the drain output can be
recalculated.
if tx.output.len() > 1 {
let mut change_index = None;
for (index, txout) in tx.output.iter().enumerate() {
- let change_keychain = KeychainKind::Internal;
+ let change_keychain = self.map_keychain(KeychainKind::Internal);
match txout_index.index_of_spk(txout.script_pubkey.clone()) {
Some((keychain, _)) if *keychain == change_keychain => {
change_index = Some(index)