MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / getAvailableBalance

Method getAvailableBalance

src/wallet/interfaces.cpp:396–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394 }
395 CAmount getBalance() override { return GetBalance(*m_wallet).m_mine_trusted; }
396 CAmount getAvailableBalance(const CCoinControl& coin_control) override
397 {
398 LOCK(m_wallet->cs_wallet);
399 CAmount total_amount = 0;
400 // Fetch selected coins total amount
401 if (coin_control.HasSelected()) {
402 FastRandomContext rng{};
403 CoinSelectionParams params(rng);
404 // Note: for now, swallow any error.
405 if (auto res = FetchSelectedInputs(*m_wallet, coin_control, params)) {
406 total_amount += res->GetTotalAmount();
407 }
408 }
409
410 // And fetch the wallet available coins
411 if (coin_control.m_allow_other_inputs) {
412 total_amount += AvailableCoins(*m_wallet, &coin_control).GetTotalAmount();
413 }
414
415 return total_amount;
416 }
417 bool txinIsMine(const CTxIn& txin) override
418 {
419 LOCK(m_wallet->cs_wallet);

Callers

nothing calls this directly

Calls 4

FetchSelectedInputsFunction · 0.85
HasSelectedMethod · 0.80
GetTotalAmountMethod · 0.80
AvailableCoinsFunction · 0.70

Tested by

no test coverage detected