Merge pull request #553 from leofidus/1.7-nozerofee

Don't send feeless transactions
This commit is contained in:
langerhans 2014-06-29 15:28:35 +02:00
commit 85f1d69e0a
4 changed files with 16 additions and 13 deletions

View file

@ -107,7 +107,7 @@ B2ADDRESS=$( $CLI $B2ARGS getnewaddress )
TXID_C=$( $CLI $B1ARGS sendtoaddress $B1ADDRESS 500000.0)
# Transaction D: spends B and C
TXID_D=$( $CLI $B1ARGS sendtoaddress $B2ADDRESS 1000000.0)
TXID_D=$( $CLI $B1ARGS sendtoaddress $B2ADDRESS 999998.0)
CheckBalance "$B1ARGS" 0
@ -133,9 +133,9 @@ WaitPeers "$B1ARGS" 1
$CLI $B2ARGS setgenerate true 1
WaitBlocks
# B1 should still be able to spend 1000000, because D is conflicted
# B1 should still be able to spend 1000000 (-1 DOGE fee for the successful transaction), because D is conflicted
# so does not count as a spend of B
CheckBalance "$B1ARGS" 1000000
CheckBalance "$B1ARGS" "1000000-1"
$CLI $B2ARGS stop > /dev/null 2>&1
wait $B2PID

View file

@ -97,7 +97,7 @@ B2ADDRESS=$( $CLI $B2ARGS getaccountaddress "from1" )
$CLI $B1ARGS move "" "foo" 10.0 > /dev/null
$CLI $B1ARGS move "" "bar" 10.0 > /dev/null
TXID1=$( $CLI $B1ARGS sendfrom foo $B2ADDRESS 1.0 0)
TXID2=$( $CLI $B1ARGS sendfrom bar $B2ADDRESS 2.0 0)
TXID2=$( $CLI $B1ARGS sendfrom bar $B2ADDRESS 5.0 0)
# Mutate TXID1 and add it to B2's memory pool:
RAWTX1=$( $CLI $B1ARGS getrawtransaction $TXID1 )
@ -130,12 +130,12 @@ $CLI $B2ARGS addnode 127.0.0.1:11000 onetry
$CLI $B2ARGS setgenerate true 1
WaitBlocks
# B1 should have 499999 DOGE; the 2 DOGE send is
# B1 should have 499998 DOGE; the 5 DOGE send is
# conflicted, and should not count in
# balances.
CheckBalance "$B1ARGS" 499999
CheckBalance "$B1ARGS" 499999 "*"
CheckBalance "$B1ARGS" 9 "foo"
CheckBalance "$B1ARGS" 499998
CheckBalance "$B1ARGS" 499998 "*"
CheckBalance "$B1ARGS" 8 "foo"
CheckBalance "$B1ARGS" 10 "bar"
# B2 should have 500001 DOGE

View file

@ -791,7 +791,7 @@ int64_t GetMinFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree,
int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee;
if (fAllowFree)
if (fAllowFree && mode != GMF_SEND)
{
// Free transaction area
if (nBytes < 26000)

View file

@ -214,7 +214,7 @@ BOOST_AUTO_TEST_CASE(GetMinFee_relayfree_test)
BOOST_CHECK(GetMinFee(tx, MAX_STANDARD_TX_SIZE, true, GMF_RELAY) == (1+(MAX_STANDARD_TX_SIZE/1000))*CTransaction::nMinRelayTxFee);
}
BOOST_AUTO_TEST_CASE(GetMinFee_createFree_test)
BOOST_AUTO_TEST_CASE(GetMinFee_createNoFree_test)
{
uint64_t value = 1000 * COIN;
@ -225,9 +225,12 @@ BOOST_AUTO_TEST_CASE(GetMinFee_createFree_test)
if(CTransaction::nMinTxFee == CTransaction::nMinRelayTxFee)
CTransaction::nMinTxFee++;
BOOST_CHECK(GetMinFee(tx, 100, true, GMF_SEND) == 0);
BOOST_CHECK(GetMinFee(tx, 1000, true, GMF_SEND) == 0);
BOOST_CHECK(GetMinFee(tx, 25999, true, GMF_SEND) == 0);
BOOST_CHECK(GetMinFee(tx, 100, true, GMF_SEND) > 0);
BOOST_CHECK(GetMinFee(tx, 100, true, GMF_SEND) == GetMinFee(tx, 100, false, GMF_SEND));
BOOST_CHECK(GetMinFee(tx, 1000, true, GMF_SEND) > 0);
BOOST_CHECK(GetMinFee(tx, 1000, true, GMF_SEND) == GetMinFee(tx, 1000, false, GMF_SEND));
BOOST_CHECK(GetMinFee(tx, 25999, true, GMF_SEND) > 0);
BOOST_CHECK(GetMinFee(tx, 25999, true, GMF_SEND) == GetMinFee(tx, 25999, false, GMF_SEND));
BOOST_CHECK(GetMinFee(tx, 26000, true, GMF_SEND) > 0);
BOOST_CHECK(GetMinFee(tx, 26000, true, GMF_SEND) == GetMinFee(tx, 26000, false, GMF_SEND));