MCPcopy Create free account
hub / github.com/ElementsProject/elements / useAvailableBalance

Method useAvailableBalance

src/qt/sendcoinsdialog.cpp:808–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

806}
807
808void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)
809{
810 // Include watch-only for wallets without private key
811 m_coin_control->fAllowWatchOnly = model->wallet().privateKeysDisabled() && !model->wallet().hasExternalSigner();
812
813 SendAssetsRecipient recipient = entry->getValue();
814 // Calculate available amount to send.
815 CAmount amount = valueFor(model->wallet().getAvailableBalance(*m_coin_control), recipient.asset);
816 for (int i = 0; i < ui->entries->count(); ++i) {
817 SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
818 if (e && !e->isHidden() && e != entry && e->getValue().asset == recipient.asset) {
819 amount -= e->getValue().asset_amount;
820 }
821 }
822
823 if (amount > 0) {
824 if (recipient.asset == ::policyAsset) {
825 entry->checkSubtractFeeFromAmount();
826 }
827 recipient.asset_amount = amount;
828 } else {
829 recipient.asset_amount = 0;
830 }
831 entry->setValue(recipient);
832}
833
834void SendCoinsDialog::updateFeeSectionControls()
835{

Callers

nothing calls this directly

Calls 9

valueForFunction · 0.85
privateKeysDisabledMethod · 0.80
hasExternalSignerMethod · 0.80
getValueMethod · 0.80
getAvailableBalanceMethod · 0.80
countMethod · 0.80
walletMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected