Skip to content

Commit

Permalink
Merge pull request #8156 from Rogach/pr/fix-spend-from-address
Browse files Browse the repository at this point in the history
fix adding coins to coincontrol from address list (fixes #8155)
  • Loading branch information
ecdsa committed Jan 18, 2023
2 parents 3c1e4ba + eed48a8 commit 93e3a7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion electrum/gui/qt/address_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ def create_menu(self, position):

coins = self.wallet.get_spendable_coins(addrs)
if coins:
menu.addAction(_("Spend from"), lambda: self.parent.utxo_list.set_spend_list(coins))
if self.parent.utxo_list.are_in_coincontrol(coins):
menu.addAction(_("Remove from coin control"), lambda: self.parent.utxo_list.remove_from_coincontrol(coins))
else:
menu.addAction(_("Add to coin control"), lambda: self.parent.utxo_list.add_to_coincontrol(coins))

run_hook('receive_menu', menu, addrs, self.wallet)
menu.exec_(self.viewport().mapToGlobal(position))
Expand Down
5 changes: 4 additions & 1 deletion electrum/gui/qt/utxo_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def _filter_frozen_coins(self, coins: List[PartialTxInput]) -> List[PartialTxInp
not self.wallet.is_frozen_coin(utxo))]
return coins

def are_in_coincontrol(self, coins: List[PartialTxInput]) -> bool:
return all([utxo.prevout.to_str() in self._spend_set for utxo in coins])

def add_to_coincontrol(self, coins: List[PartialTxInput]):
coins = self._filter_frozen_coins(coins)
for utxo in coins:
Expand Down Expand Up @@ -192,7 +195,7 @@ def create_menu(self, position):
coins = [self._utxo_dict[name] for name in selected]
# coin control
if coins:
if all([utxo.prevout.to_str() in self._spend_set for utxo in coins]):
if self.are_in_coincontrol(coins):
menu.addAction(_("Remove from coin control"), lambda: self.remove_from_coincontrol(coins))
else:
menu.addAction(_("Add to coin control"), lambda: self.add_to_coincontrol(coins))
Expand Down

0 comments on commit 93e3a7b

Please sign in to comment.