File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -143,8 +143,8 @@ class CTxOut
143
143
// to spend something, then we consider it dust.
144
144
// A typical spendable txout is 34 bytes big, and will
145
145
// need a CTxIn of at least 148 bytes to spend:
146
- // so dust is a spendable txout less than 546 satoshis
147
- // with default minRelayTxFee.
146
+ // so dust is a spendable txout less than
147
+ // 546*minRelayTxFee/1000 (in satoshis)
148
148
if (scriptPubKey.IsUnspendable ())
149
149
return 0 ;
150
150
Original file line number Diff line number Diff line change @@ -342,11 +342,26 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
342
342
string reason;
343
343
BOOST_CHECK (IsStandardTx (t, reason));
344
344
345
- t.vout [0 ].nValue = 501 ; // dust
345
+ // Check dust with default relay fee:
346
+ CAmount nDustThreshold = 182 * minRelayTxFee.GetFeePerK ()/1000 * 3 ;
347
+ BOOST_CHECK_EQUAL (nDustThreshold, 546 );
348
+ // dust:
349
+ t.vout [0 ].nValue = nDustThreshold - 1 ;
346
350
BOOST_CHECK (!IsStandardTx (t, reason));
351
+ // not dust:
352
+ t.vout [0 ].nValue = nDustThreshold;
353
+ BOOST_CHECK (IsStandardTx (t, reason));
347
354
348
- t.vout [0 ].nValue = 2730 ; // not dust
355
+ // Check dust with odd relay fee to verify rounding:
356
+ // nDustThreshold = 182 * 1234 / 1000 * 3
357
+ minRelayTxFee = CFeeRate (1234 );
358
+ // dust:
359
+ t.vout [0 ].nValue = 672 - 1 ;
360
+ BOOST_CHECK (!IsStandardTx (t, reason));
361
+ // not dust:
362
+ t.vout [0 ].nValue = 672 ;
349
363
BOOST_CHECK (IsStandardTx (t, reason));
364
+ minRelayTxFee = CFeeRate (1000 );
350
365
351
366
t.vout [0 ].scriptPubKey = CScript () << OP_1;
352
367
BOOST_CHECK (!IsStandardTx (t, reason));
You can’t perform that action at this time.
0 commit comments