mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
Define dust transaction outputs, and make them non-standard
This commit is contained in:
@@ -1162,7 +1162,12 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW
|
||||
double dPriority = 0;
|
||||
// vouts to the payees
|
||||
BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)
|
||||
wtxNew.vout.push_back(CTxOut(s.second, s.first));
|
||||
{
|
||||
CTxOut txout(s.second, s.first);
|
||||
if (txout.IsDust())
|
||||
return false;
|
||||
wtxNew.vout.push_back(txout);
|
||||
}
|
||||
|
||||
// Choose coins to use
|
||||
set<pair<const CWalletTx*,unsigned int> > setCoins;
|
||||
@@ -1208,9 +1213,21 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW
|
||||
CScript scriptChange;
|
||||
scriptChange.SetDestination(vchPubKey.GetID());
|
||||
|
||||
// Insert change txn at random position:
|
||||
vector<CTxOut>::iterator position = wtxNew.vout.begin()+GetRandInt(wtxNew.vout.size()+1);
|
||||
wtxNew.vout.insert(position, CTxOut(nChange, scriptChange));
|
||||
CTxOut newTxOut(nChange, scriptChange);
|
||||
|
||||
// Never create dust outputs; if we would, just
|
||||
// add the dust to the fee.
|
||||
if (newTxOut.IsDust())
|
||||
{
|
||||
nFeeRet += nChange;
|
||||
reservekey.ReturnKey();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Insert change txn at random position:
|
||||
vector<CTxOut>::iterator position = wtxNew.vout.begin()+GetRandInt(wtxNew.vout.size()+1);
|
||||
wtxNew.vout.insert(position, newTxOut);
|
||||
}
|
||||
}
|
||||
else
|
||||
reservekey.ReturnKey();
|
||||
|
||||
Reference in New Issue
Block a user