mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Fix for calling GetAmount on potentially blinded output
Introduced in 103069c46c
for Bitcoin PR bitcoin/bitcoin#22100
This commit is contained in:
parent
941940e946
commit
b958e586ef
2 changed files with 6 additions and 22 deletions
|
|
@ -113,27 +113,12 @@ bool ScriptIsChange(const CWallet& wallet, const CScript& script)
|
|||
return false;
|
||||
}
|
||||
|
||||
CAmountMap OutputGetChange(const CWallet& wallet, const CTxOut& txout)
|
||||
{
|
||||
AssertLockHeld(wallet.cs_wallet);
|
||||
|
||||
CAmountMap change;
|
||||
change[txout.nAsset.GetAsset()] = txout.nValue.GetAmount();
|
||||
if (!MoneyRange(change))
|
||||
throw std::runtime_error(std::string(__func__) + ": value out of range");
|
||||
return (OutputIsChange(wallet, txout) ? change : CAmountMap());
|
||||
}
|
||||
|
||||
CAmountMap TxGetChange(const CWallet& wallet, const CTransaction& tx)
|
||||
CAmountMap TxGetChange(const CWallet& wallet, const CWalletTx& wtx)
|
||||
{
|
||||
LOCK(wallet.cs_wallet);
|
||||
CAmountMap nChange;
|
||||
for (const CTxOut& txout : tx.vout)
|
||||
{
|
||||
nChange += OutputGetChange(wallet, txout);
|
||||
if (!MoneyRange(nChange))
|
||||
throw std::runtime_error(std::string(__func__) + ": value out of range");
|
||||
}
|
||||
CAmountMap nChange = GetChange(wallet, wtx);
|
||||
if (!MoneyRange(nChange))
|
||||
throw std::runtime_error(std::string(__func__) + ": value out of range");
|
||||
return nChange;
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +188,7 @@ CAmountMap CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx)
|
|||
{
|
||||
if (wtx.fChangeCached)
|
||||
return wtx.nChangeCached;
|
||||
wtx.nChangeCached = TxGetChange(wallet, *wtx.tx);
|
||||
wtx.nChangeCached = TxGetChange(wallet, wtx);
|
||||
wtx.fChangeCached = true;
|
||||
return wtx.nChangeCached;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,8 @@ CAmountMap TxGetCredit(const CWallet& wallet, const CTransaction& tx, const ismi
|
|||
|
||||
bool ScriptIsChange(const CWallet& wallet, const CScript& script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
||||
bool OutputIsChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
||||
CAmountMap OutputGetChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
||||
CAmountMap TxGetChange(const CWallet& wallet, const CTransaction& tx);
|
||||
// ELEMENTS:
|
||||
CAmountMap TxGetChange(const CWallet& wallet, const CWalletTx& wtx);
|
||||
CAmountMap GetCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
||||
CAmountMap GetChange(const CWallet& wallet, const CWalletTx& wtx) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue