From 6609624fe0e3b4279e060b87dc56a093db43b06c Mon Sep 17 00:00:00 2001 From: ecdsa Date: Mon, 8 Apr 2013 16:18:40 +0200 Subject: [PATCH] mktx: send change to one of the accounts involved in the tx --- lib/wallet.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/lib/wallet.py b/lib/wallet.py index eab1a6b..7d7151f 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -594,10 +594,14 @@ class Wallet: change_amount = total - ( amount + fee ) if change_amount != 0: if not change_addr: + if account is None: + # send change to one of the accounts involved in the tx + address = inputs[0].get('address') + account, _ = self.get_address_index(address) + if not self.use_change or account == -1: change_addr = inputs[-1]['address'] else: - if account is None: account = 0 change_addr = self.accounts[account][1][-self.gap_limit_for_change] # Insert the change output at a random position in the outputs -- 1.7.1