Skip to content

Commit 8c9268c

Browse files
authored
Merge pull request ElementsProject#1223 from andreabonel/qt_use_available_balance_from_the_currently_selected_asset
Elements-qt: Use available balance from the currently selected asset
2 parents 63d79dd + 7a98c29 commit 8c9268c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/qt/sendcoinsdialog.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,21 +777,25 @@ void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)
777777
// Include watch-only for wallets without private key
778778
m_coin_control->fAllowWatchOnly = model->wallet().privateKeysDisabled() && !model->wallet().hasExternalSigner();
779779

780+
SendAssetsRecipient recipient = entry->getValue();
780781
// Calculate available amount to send.
781-
CAmount amount = valueFor(model->wallet().getAvailableBalance(*m_coin_control), ::policyAsset);
782+
CAmount amount = valueFor(model->wallet().getAvailableBalance(*m_coin_control), recipient.asset);
782783
for (int i = 0; i < ui->entries->count(); ++i) {
783784
SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
784-
if (e && !e->isHidden() && e != entry && e->getValue().asset == ::policyAsset) {
785+
if (e && !e->isHidden() && e != entry && e->getValue().asset == recipient.asset) {
785786
amount -= e->getValue().asset_amount;
786787
}
787788
}
788789

789790
if (amount > 0) {
790-
entry->checkSubtractFeeFromAmount();
791-
entry->setAmount(amount);
791+
if (recipient.asset == ::policyAsset) {
792+
entry->checkSubtractFeeFromAmount();
793+
}
794+
recipient.asset_amount = amount;
792795
} else {
793-
entry->setAmount(0);
796+
recipient.asset_amount = 0;
794797
}
798+
entry->setValue(recipient);
795799
}
796800

797801
void SendCoinsDialog::updateFeeSectionControls()

0 commit comments

Comments
 (0)