Skip to content

Commit 6f797b7

Browse files
committed
fix(wallet): reuse first input as change address for DRTs
1 parent d9165ff commit 6f797b7

File tree

1 file changed

+6
-1
lines changed
  • wallet/src/repository/wallet

1 file changed

+6
-1
lines changed

wallet/src/repository/wallet/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,12 @@ where
12931293
max_weight,
12941294
)?;
12951295

1296-
let change_pkh = self.calculate_change_address(state, None)?;
1296+
// For data requests, this will set the change address to the one from the first input.
1297+
// For any other transaction type, a fresh address is generated in the internal keychain.
1298+
let change_pkh = self.calculate_change_address(
1299+
state,
1300+
dr_output.and_then(|_| inputs.pointers.get(0).cloned().map(Input::new)),
1301+
)?;
12971302

12981303
let mut outputs = outputs;
12991304
insert_change_output(

0 commit comments

Comments
 (0)