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

Method updateLabels

src/qt/coincontroldialog.cpp:386–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *model, QDialog* dialog)
387{
388 if (!model)
389 return;
390
391 // nPayAmount
392 CAmount nPayAmount = 0;
393 bool fDust = false;
394 for (const CAmount &amount : CoinControlDialog::payAmounts)
395 {
396 nPayAmount += amount;
397
398 if (amount > 0)
399 {
400 // Assumes a p2pkh script size
401 CTxOut txout(::policyAsset, amount, CScript() << std::vector<unsigned char>(24, 0));
402 fDust |= IsDust(txout, model->node().getDustRelayFee());
403 }
404 }
405
406 CAmount nAmount = 0;
407 CAmount nPayFee = 0;
408 CAmount nAfterFee = 0;
409 CAmount nChange = 0;
410 unsigned int nBytes = 0;
411 unsigned int nBytesInputs = 0;
412 unsigned int nQuantity = 0;
413 bool fWitness = false;
414
415 std::vector<COutPoint> vCoinControl;
416 m_coin_control.ListSelected(vCoinControl);
417
418 size_t i = 0;
419 for (const auto& out : model->wallet().getCoins(vCoinControl)) {
420 if (out.depth_in_main_chain < 0) continue;
421
422 // unselect already spent, very unlikely scenario, this could happen
423 // when selected are spent elsewhere, like rpc or another computer
424 const COutPoint& outpt = vCoinControl[i++];
425 if (out.is_spent)
426 {
427 m_coin_control.UnSelect(outpt);
428 continue;
429 }
430
431 // Quantity
432 nQuantity++;
433
434 // Amount
435 nAmount += out.txout.nValue.GetAmount();
436
437 // Bytes
438 CTxDestination address;
439 int witnessversion = 0;
440 std::vector<unsigned char> witnessprogram;
441 if (out.txout.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram))
442 {
443 nBytesInputs += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);

Callers

nothing calls this directly

Calls 15

IsDustFunction · 0.85
ExtractDestinationFunction · 0.85
ToKeyIDFunction · 0.85
getDustRelayFeeMethod · 0.80
ListSelectedMethod · 0.80
getCoinsMethod · 0.80
UnSelectMethod · 0.80
GetAmountMethod · 0.80
IsWitnessProgramMethod · 0.80
getPubKeyMethod · 0.80
getMinimumFeeMethod · 0.80
getDisplayUnitMethod · 0.80

Tested by

no test coverage detected