Skip to content

Commit 24ce77d

Browse files
committed
Merge pull request #6444
0aad1f1 Exempt unspendable transaction outputs from dust checks (zathras-crypto)
2 parents 6d6b11e + 0aad1f1 commit 24ce77d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

qa/rpc-tests/fundrawtransaction.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,22 @@ def run_test(self):
524524
self.sync_all()
525525
assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward
526526

527+
#####################################################
528+
# test fundrawtransaction with OP_RETURN and no vin #
529+
#####################################################
530+
531+
rawtx = "0100000000010000000000000000066a047465737400000000"
532+
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
533+
534+
assert_equal(len(dec_tx['vin']), 0)
535+
assert_equal(len(dec_tx['vout']), 1)
536+
537+
rawtxfund = self.nodes[2].fundrawtransaction(rawtx)
538+
dec_tx = self.nodes[2].decoderawtransaction(rawtxfund['hex'])
539+
540+
assert_greater_than(len(dec_tx['vin']), 0) # at least one vin
541+
assert_equal(len(dec_tx['vout']), 2) # one change output added
542+
527543

528544
if __name__ == '__main__':
529545
RawTransactionsTest().main()

src/primitives/transaction.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,13 @@ class CTxOut
141141
// which has units satoshis-per-kilobyte.
142142
// If you'd pay more than 1/3 in fees
143143
// to spend something, then we consider it dust.
144-
// A typical txout is 34 bytes big, and will
144+
// A typical spendable txout is 34 bytes big, and will
145145
// need a CTxIn of at least 148 bytes to spend:
146-
// so dust is a txout less than 546 satoshis
146+
// so dust is a spendable txout less than 546 satoshis
147147
// with default minRelayTxFee.
148+
if (scriptPubKey.IsUnspendable())
149+
return 0;
150+
148151
size_t nSize = GetSerializeSize(SER_DISK,0)+148u;
149152
return 3*minRelayTxFee.GetFee(nSize);
150153
}

0 commit comments

Comments
 (0)