* Throwing recoverable error when transaction amount is too small to pay the MWEB recipient

* Checking ismine filter for pegouts in GetCredit
This commit is contained in:
David Burkett 2022-04-13 16:40:35 -04:00 committed by Loshan T
parent 405b1ec5ca
commit 82ab2849c9
2 changed files with 5 additions and 1 deletions

View File

@ -105,6 +105,10 @@ void Transact::AddMWEBTx(InProcessTx& new_tx)
recipient_amount -= new_tx.total_fee;
}
if (recipient_amount < 0) {
throw CreateTxError(_("The transaction amount is too small to pay the fee"));
}
if (recipient.IsMWEB()) {
receivers.push_back(mw::Recipient{recipient_amount, recipient.GetMWEBAddress()});
} else {

View File

@ -1647,7 +1647,7 @@ CAmount CWallet::GetCredit(const CTransaction& tx, const boost::optional<MWEB::W
if (!has_my_inputs) {
for (const PegOutCoin& pegout : tx.mweb_tx.GetPegOuts()) {
LOCK(cs_wallet);
if (IsMine(DestinationAddr(pegout.GetScriptPubKey()))) {
if (!(IsMine(DestinationAddr(pegout.GetScriptPubKey())) & filter)) {
nCredit += pegout.GetAmount();
if (!MoneyRange(nCredit))
throw std::runtime_error(std::string(__func__) + ": value out of range");