Skip to content

Commit

Permalink
Merge pull request #6444
Browse files Browse the repository at this point in the history
0aad1f1 Exempt unspendable transaction outputs from dust checks (zathras-crypto)
  • Loading branch information
laanwj committed Jul 21, 2015
2 parents 6d6b11e + 0aad1f1 commit 24ce77d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 16 additions & 0 deletions qa/rpc-tests/fundrawtransaction.py
Expand Up @@ -524,6 +524,22 @@ def run_test(self):
self.sync_all()
assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward

#####################################################
# test fundrawtransaction with OP_RETURN and no vin #
#####################################################

rawtx = "0100000000010000000000000000066a047465737400000000"
dec_tx = self.nodes[2].decoderawtransaction(rawtx)

assert_equal(len(dec_tx['vin']), 0)
assert_equal(len(dec_tx['vout']), 1)

rawtxfund = self.nodes[2].fundrawtransaction(rawtx)
dec_tx = self.nodes[2].decoderawtransaction(rawtxfund['hex'])

assert_greater_than(len(dec_tx['vin']), 0) # at least one vin
assert_equal(len(dec_tx['vout']), 2) # one change output added


if __name__ == '__main__':
RawTransactionsTest().main()
7 changes: 5 additions & 2 deletions src/primitives/transaction.h
Expand Up @@ -141,10 +141,13 @@ class CTxOut
// which has units satoshis-per-kilobyte.
// If you'd pay more than 1/3 in fees
// to spend something, then we consider it dust.
// A typical txout is 34 bytes big, and will
// A typical spendable txout is 34 bytes big, and will
// need a CTxIn of at least 148 bytes to spend:
// so dust is a txout less than 546 satoshis
// so dust is a spendable txout less than 546 satoshis
// with default minRelayTxFee.
if (scriptPubKey.IsUnspendable())
return 0;

size_t nSize = GetSerializeSize(SER_DISK,0)+148u;
return 3*minRelayTxFee.GetFee(nSize);
}
Expand Down

0 comments on commit 24ce77d

Please sign in to comment.