| 384 | } |
| 385 | |
| 386 | void 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); |
nothing calls this directly
no test coverage detected