Auto merge of #4916 - daira:reduce-fee, r=nuttycom
Reduce default fee to 1000 zatoshis Per ZIP 313. This also ensures that transactions that pay the default fee will always be relayed, and not rate-limited.
This commit is contained in:
commit
2c0f6df168
|
@ -210,6 +210,10 @@ def main():
|
|||
# in the ALL_SCRIPTS list. Accept the name with or without .py extension.
|
||||
test_list = [t for t in ALL_SCRIPTS if
|
||||
(t in tests or re.sub(".py$", "", t) in tests)]
|
||||
|
||||
print("Running individually selected tests: ")
|
||||
for t in test_list:
|
||||
print("\t" + t)
|
||||
else:
|
||||
# No individual tests have been specified. Run base tests, and
|
||||
# optionally ZMQ tests and extended tests.
|
||||
|
|
|
@ -10,6 +10,7 @@ from test_framework.util import (
|
|||
fail,
|
||||
start_nodes,
|
||||
wait_and_assert_operationid_status,
|
||||
DEFAULT_FEE
|
||||
)
|
||||
|
||||
from decimal import Decimal
|
||||
|
@ -61,16 +62,16 @@ class MempoolLimit(BitcoinTestFramework):
|
|||
zaddr3 = self.nodes[0].z_getnewaddress('sapling')
|
||||
|
||||
print("Filling mempool...")
|
||||
opid1 = self.nodes[1].z_sendmany(get_coinbase_address(self.nodes[1]), [{"address": zaddr1, "amount": Decimal('9.999')}])
|
||||
opid1 = self.nodes[1].z_sendmany(get_coinbase_address(self.nodes[1]), [{"address": zaddr1, "amount": Decimal('10.0') - DEFAULT_FEE}])
|
||||
wait_and_assert_operationid_status(self.nodes[1], opid1)
|
||||
opid2 = self.nodes[2].z_sendmany(get_coinbase_address(self.nodes[2]), [{"address": zaddr2, "amount": Decimal('9.999')}])
|
||||
opid2 = self.nodes[2].z_sendmany(get_coinbase_address(self.nodes[2]), [{"address": zaddr2, "amount": Decimal('10.0') - DEFAULT_FEE}])
|
||||
wait_and_assert_operationid_status(self.nodes[2], opid2)
|
||||
self.sync_all()
|
||||
|
||||
self.check_mempool_sizes(2)
|
||||
|
||||
print("Adding one more transaction...")
|
||||
opid3 = self.nodes[3].z_sendmany(get_coinbase_address(self.nodes[3]), [{"address": zaddr3, "amount": Decimal('9.999')}])
|
||||
opid3 = self.nodes[3].z_sendmany(get_coinbase_address(self.nodes[3]), [{"address": zaddr3, "amount": Decimal('10.0') - DEFAULT_FEE}])
|
||||
wait_and_assert_operationid_status(self.nodes[3], opid3)
|
||||
# The mempools are no longer guaranteed to be in a consistent state, so we cannot sync
|
||||
sleep(5)
|
||||
|
@ -88,9 +89,9 @@ class MempoolLimit(BitcoinTestFramework):
|
|||
print("Checking mempool size reset after block mined...")
|
||||
self.check_mempool_sizes(0)
|
||||
zaddr4 = self.nodes[0].z_getnewaddress('sapling')
|
||||
opid4 = self.nodes[0].z_sendmany(zaddr1, [{"address": zaddr4, "amount": Decimal('9.998')}])
|
||||
opid4 = self.nodes[0].z_sendmany(zaddr1, [{"address": zaddr4, "amount": Decimal('10.0') - 2*DEFAULT_FEE}])
|
||||
wait_and_assert_operationid_status(self.nodes[0], opid4)
|
||||
opid5 = self.nodes[0].z_sendmany(zaddr2, [{"address": zaddr4, "amount": Decimal('9.998')}])
|
||||
opid5 = self.nodes[0].z_sendmany(zaddr2, [{"address": zaddr4, "amount": Decimal('10.0') - 2*DEFAULT_FEE}])
|
||||
wait_and_assert_operationid_status(self.nodes[0], opid5)
|
||||
self.sync_all()
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
#
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, start_node
|
||||
from test_framework.util import assert_equal, start_node, DEFAULT_FEE
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
# Create one-input, one-output, no-fee transaction:
|
||||
|
@ -55,7 +57,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
|
|||
blocks = []
|
||||
blocks.extend(self.nodes[0].generate(1))
|
||||
|
||||
spends2_raw = [ self.create_tx(txid, node0_address, 9.999) for txid in spends1_id ]
|
||||
spends2_raw = [ self.create_tx(txid, node0_address, Decimal('10.0') - DEFAULT_FEE) for txid in spends1_id ]
|
||||
spends2_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends2_raw ]
|
||||
|
||||
blocks.extend(self.nodes[0].generate(1))
|
||||
|
|
|
@ -11,7 +11,7 @@ from test_framework.authproxy import JSONRPCException
|
|||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, \
|
||||
connect_nodes_bi, sync_blocks, start_nodes, \
|
||||
wait_and_assert_operationid_status
|
||||
wait_and_assert_operationid_status, DEFAULT_FEE
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -75,7 +75,7 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
assert_equal(set(self.nodes[2].getrawmempool()), set())
|
||||
|
||||
## Shield one of Alice's coinbase funds to her zaddr
|
||||
res = self.nodes[0].z_shieldcoinbase("*", z_alice, 0.0001, 1)
|
||||
res = self.nodes[0].z_shieldcoinbase("*", z_alice, DEFAULT_FEE, 1)
|
||||
wait_and_assert_operationid_status(self.nodes[0], res['opid'])
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -83,14 +83,14 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
# Get balance on node 0
|
||||
bal = self.nodes[0].z_gettotalbalance()
|
||||
print("Balance before zsend, after shielding 10: ", bal)
|
||||
assert_equal(Decimal(bal["private"]), Decimal("9.9999"))
|
||||
assert_equal(Decimal(bal["private"]), Decimal('10.0') - DEFAULT_FEE)
|
||||
|
||||
print("Splitting network...")
|
||||
self.split_network()
|
||||
|
||||
# Create transactions
|
||||
blockheight = self.nodes[0].getblockchaininfo()['blocks']
|
||||
zsendamount = Decimal('1.0') - Decimal('0.0001')
|
||||
zsendamount = Decimal('1.0') - DEFAULT_FEE
|
||||
recipients = []
|
||||
recipients.append({"address": z_bob, "amount": zsendamount})
|
||||
myopid = self.nodes[0].z_sendmany(z_alice, recipients)
|
||||
|
@ -216,7 +216,7 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
print("Ensure balance of node 0 is correct")
|
||||
bal = self.nodes[0].z_gettotalbalance()
|
||||
print("Balance after expire_shielded has expired: ", bal)
|
||||
assert_equal(Decimal(bal["private"]), Decimal("7.9999"))
|
||||
assert_equal(Decimal(bal["private"]), Decimal('8.0') - DEFAULT_FEE)
|
||||
|
||||
print("Splitting network...")
|
||||
self.split_network()
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, connect_nodes_bi, fail, \
|
||||
initialize_chain_clean, start_node, sync_blocks, sync_mempools, \
|
||||
wait_and_assert_operationid_status
|
||||
wait_and_assert_operationid_status, DEFAULT_FEE
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -159,7 +159,7 @@ class MergeToAddressHelper:
|
|||
"Cannot send from both Sprout and Sapling addresses using z_mergetoaddress",
|
||||
lambda: test.nodes[0].z_mergetoaddress(["ANY_SPROUT", "ANY_SAPLING"], mytaddr))
|
||||
|
||||
# Merge UTXOs from node 0 of value 30, standard fee of 0.00010000
|
||||
# Merge UTXOs from node 0 of value 30, default fee
|
||||
result = test.nodes[0].z_mergetoaddress([mytaddr, mytaddr2, mytaddr3], myzaddr)
|
||||
wait_and_assert_operationid_status(test.nodes[0], result['opid'])
|
||||
test.sync_all()
|
||||
|
@ -169,7 +169,7 @@ class MergeToAddressHelper:
|
|||
# Confirm balances and that do_not_shield_taddr containing funds of 10 was left alone
|
||||
assert_equal(test.nodes[0].getbalance(), 10)
|
||||
assert_equal(test.nodes[0].z_getbalance(do_not_shield_taddr), Decimal('10.0'))
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr), Decimal('39.99990000'))
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr), Decimal('40.0') - DEFAULT_FEE)
|
||||
assert_equal(test.nodes[1].getbalance(), 40)
|
||||
assert_equal(test.nodes[2].getbalance(), 30)
|
||||
|
||||
|
@ -187,7 +187,7 @@ class MergeToAddressHelper:
|
|||
|
||||
assert_equal(len(test.nodes[0].getblock(blockhash[0])['tx']), 2)
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr), 0)
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr2), Decimal('39.99990000'))
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr2), Decimal('40.0') - DEFAULT_FEE)
|
||||
|
||||
# Shield coinbase UTXOs from any node 2 taddr, and set fee to 0
|
||||
result = test.nodes[2].z_shieldcoinbase("*", myzaddr, 0)
|
||||
|
@ -198,7 +198,7 @@ class MergeToAddressHelper:
|
|||
|
||||
assert_equal(test.nodes[0].getbalance(), 10)
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr), Decimal('30'))
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr2), Decimal('39.99990000'))
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr2), Decimal('40.0') - DEFAULT_FEE)
|
||||
assert_equal(test.nodes[1].getbalance(), 60)
|
||||
assert_equal(test.nodes[2].getbalance(), 0)
|
||||
|
||||
|
@ -209,9 +209,9 @@ class MergeToAddressHelper:
|
|||
test.nodes[1].generate(1)
|
||||
test.sync_all()
|
||||
|
||||
assert_equal(test.nodes[0].getbalance(), Decimal('79.99990000'))
|
||||
assert_equal(test.nodes[0].getbalance(), Decimal('80.0') - DEFAULT_FEE)
|
||||
assert_equal(test.nodes[0].z_getbalance(do_not_shield_taddr), Decimal('10.0'))
|
||||
assert_equal(test.nodes[0].z_getbalance(mytaddr), Decimal('69.99990000'))
|
||||
assert_equal(test.nodes[0].z_getbalance(mytaddr), Decimal('70.0') - DEFAULT_FEE)
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr), 0)
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr2), 0)
|
||||
assert_equal(test.nodes[1].getbalance(), 70)
|
||||
|
@ -230,8 +230,8 @@ class MergeToAddressHelper:
|
|||
assert_equal(test.nodes[0].z_getbalance(do_not_shield_taddr), 0)
|
||||
assert_equal(test.nodes[0].z_getbalance(mytaddr), 0)
|
||||
assert_equal(test.nodes[0].z_getbalance(myzaddr), 0)
|
||||
assert_equal(test.nodes[1].getbalance(), Decimal('159.99990000'))
|
||||
assert_equal(test.nodes[1].z_getbalance(n1taddr), Decimal('79.99990000'))
|
||||
assert_equal(test.nodes[1].getbalance(), Decimal('160.0') - DEFAULT_FEE)
|
||||
assert_equal(test.nodes[1].z_getbalance(n1taddr), Decimal('80.0') - DEFAULT_FEE)
|
||||
assert_equal(test.nodes[2].getbalance(), 0)
|
||||
|
||||
# Generate self.utxos_to_generate regular UTXOs on node 0, and 20 regular UTXOs on node 2
|
||||
|
@ -288,7 +288,7 @@ class MergeToAddressHelper:
|
|||
expected_to_merge = 20
|
||||
expected_remaining = 0
|
||||
|
||||
result = test.nodes[2].z_mergetoaddress([n2taddr], myzaddr, Decimal('0.0001'), 0)
|
||||
result = test.nodes[2].z_mergetoaddress([n2taddr], myzaddr, DEFAULT_FEE, 0)
|
||||
assert_equal(result["mergingUTXOs"], expected_to_merge)
|
||||
assert_equal(result["remainingUTXOs"], expected_remaining)
|
||||
assert_equal(result["mergingNotes"], Decimal('0'))
|
||||
|
@ -304,7 +304,7 @@ class MergeToAddressHelper:
|
|||
test.nodes[1].sendtoaddress(mytaddr, 1)
|
||||
test.nodes[1].generate(1)
|
||||
test.sync_all()
|
||||
result = test.nodes[0].z_mergetoaddress([mytaddr], myzaddr, Decimal('0.0001'))
|
||||
result = test.nodes[0].z_mergetoaddress([mytaddr], myzaddr, DEFAULT_FEE)
|
||||
assert_equal(result["mergingUTXOs"], Decimal('50'))
|
||||
assert_equal(result["remainingUTXOs"], Decimal('50'))
|
||||
assert_equal(result["mergingNotes"], Decimal('0'))
|
||||
|
@ -313,7 +313,7 @@ class MergeToAddressHelper:
|
|||
wait_and_assert_operationid_status(test.nodes[0], result['opid'])
|
||||
|
||||
# Verify maximum number of UTXOs which node 0 can shield can be set by the limit parameter
|
||||
result = test.nodes[0].z_mergetoaddress([mytaddr], myzaddr, Decimal('0.0001'), 33)
|
||||
result = test.nodes[0].z_mergetoaddress([mytaddr], myzaddr, DEFAULT_FEE, 33)
|
||||
assert_equal(result["mergingUTXOs"], Decimal('33'))
|
||||
assert_equal(result["remainingUTXOs"], Decimal('17'))
|
||||
assert_equal(result["mergingNotes"], Decimal('0'))
|
||||
|
@ -331,8 +331,8 @@ class MergeToAddressHelper:
|
|||
|
||||
# myzaddr will have 5 notes if testing before to Sapling activation and 4 otherwise
|
||||
num_notes = len(test.nodes[0].z_listunspent(0))
|
||||
result1 = test.nodes[0].z_mergetoaddress([myzaddr], myzaddr, 0.0001, 50, 2)
|
||||
result2 = test.nodes[0].z_mergetoaddress([myzaddr], myzaddr, 0.0001, 50, 2)
|
||||
result1 = test.nodes[0].z_mergetoaddress([myzaddr], myzaddr, DEFAULT_FEE, 50, 2)
|
||||
result2 = test.nodes[0].z_mergetoaddress([myzaddr], myzaddr, DEFAULT_FEE, 50, 2)
|
||||
|
||||
# First merge should select from all notes
|
||||
assert_equal(result1["mergingUTXOs"], Decimal('0'))
|
||||
|
|
|
@ -7,7 +7,7 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, \
|
||||
start_node, connect_nodes_bi, wait_and_assert_operationid_status, \
|
||||
get_coinbase_address
|
||||
get_coinbase_address, DEFAULT_FEE
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -68,8 +68,8 @@ class PaymentDisclosureTest (BitcoinTestFramework):
|
|||
errorString = e.error['message']
|
||||
assert("No information available about transaction" in errorString)
|
||||
|
||||
# Shield coinbase utxos from node 0 of value 40, standard fee of 0.00010000
|
||||
recipients = [{"address":myzaddr, "amount":Decimal('40.0')-Decimal('0.0001')}]
|
||||
# Shield coinbase utxos from node 0 of value 40, default fee
|
||||
recipients = [{"address": myzaddr, "amount": Decimal('40.0') - DEFAULT_FEE}]
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
txid = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
||||
|
@ -164,7 +164,7 @@ class PaymentDisclosureTest (BitcoinTestFramework):
|
|||
pd = self.nodes[0].z_getpaymentdisclosure(txid, 0, 1)
|
||||
result = self.nodes[0].z_validatepaymentdisclosure(pd)
|
||||
output_value_sum += Decimal(result["value"])
|
||||
assert_equal(output_value_sum, Decimal('39.99990000'))
|
||||
assert_equal(output_value_sum, Decimal('40.0') - DEFAULT_FEE)
|
||||
|
||||
# Create a z->z transaction, sending shielded funds from node 0 to node 1
|
||||
node1zaddr = self.nodes[1].z_getnewaddress('sprout')
|
||||
|
|
|
@ -20,6 +20,7 @@ HAS_CANOPY = ['-nurejectoldversions=false',
|
|||
nuparams(HEARTWOOD_BRANCH_ID, 210),
|
||||
nuparams(CANOPY_BRANCH_ID, 220),
|
||||
]
|
||||
|
||||
class RemoveSproutShieldingTest (BitcoinTestFramework):
|
||||
|
||||
def setup_nodes(self):
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, initialize_chain_clean, start_node
|
||||
from test_framework.util import assert_equal, assert_true, initialize_chain_clean, start_node, DEFAULT_FEE
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class SignOfflineTest (BitcoinTestFramework):
|
||||
# Setup Methods
|
||||
def setup_chain(self):
|
||||
|
@ -35,7 +38,7 @@ class SignOfflineTest (BitcoinTestFramework):
|
|||
create_inputs = [{'txid': txid, 'vout': 0}]
|
||||
sign_inputs = [{'txid': txid, 'vout': 0, 'scriptPubKey': scriptpubkey, 'amount': 10}]
|
||||
|
||||
create_hex = self.nodes[0].createrawtransaction(create_inputs, {taddr: 9.9999})
|
||||
create_hex = self.nodes[0].createrawtransaction(create_inputs, {taddr: Decimal('10.0') - DEFAULT_FEE})
|
||||
|
||||
# An offline regtest node does not rely on the approx release height of the software
|
||||
# to determine the consensus rules to be used for signing.
|
||||
|
|
|
@ -7,7 +7,7 @@ from decimal import Decimal
|
|||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, get_coinbase_address, \
|
||||
start_nodes, wait_and_assert_operationid_status, \
|
||||
wait_and_assert_operationid_status_result
|
||||
wait_and_assert_operationid_status_result, DEFAULT_FEE
|
||||
|
||||
SAPLING_ADDR = 'zregtestsapling1ssqj3f3majnl270985gqcdqedd9t4nlttjqskccwevj2v20sc25deqspv3masufnwcdy67cydyy'
|
||||
SAPLING_KEY = 'secret-extended-key-regtest1qv62zt2fqyqqpqrh2qzc08h7gncf4447jh9kvnnnhjg959fkwt7mhw9j8e9at7attx8z6u3953u86vcnsujdc2ckdlcmztjt44x3uxpah5mxtncxd0mqcnz9eq8rghh5m4j44ep5d9702sdvvwawqassulktfegrcp4twxgqdxx4eww3lau0mywuaeztpla2cmvagr5nj98elt45zh6fjznadl6wz52n2uyhdwcm2wlsu8fnxstrk6s4t55t8dy6jkgx5g0cwpchh5qffp8x5'
|
||||
|
@ -125,7 +125,7 @@ class SproutSaplingMigration(BitcoinTestFramework):
|
|||
# Check that unmigrated amount + unfinalized = starting balance - fee
|
||||
status = node.z_getmigrationstatus()
|
||||
print("status: {}".format(status))
|
||||
assert_equal(Decimal('9.9999'), Decimal(status['unmigrated_amount']) + Decimal(status['unfinalized_migrated_amount']))
|
||||
assert_equal(Decimal('10.0') - DEFAULT_FEE, Decimal(status['unmigrated_amount']) + Decimal(status['unfinalized_migrated_amount']))
|
||||
|
||||
# The transaction in the mempool should be the one listed in migration_txids,
|
||||
# and it should expire at the next 450 % 500.
|
||||
|
@ -144,7 +144,7 @@ class SproutSaplingMigration(BitcoinTestFramework):
|
|||
print("sprout balance: {}, sapling balance: {}".format(sprout_balance, sapling_balance))
|
||||
assert_true(sprout_balance < Decimal('10'), "Should have less Sprout funds")
|
||||
assert_true(sapling_balance > Decimal('0'), "Should have more Sapling funds")
|
||||
assert_true(sprout_balance + sapling_balance, Decimal('9.9999'))
|
||||
assert_true(sprout_balance + sapling_balance, Decimal('10.0') - DEFAULT_FEE)
|
||||
|
||||
check_migration_status(node, saplingAddr, DURING_MIGRATION)
|
||||
# At 10 % 500 the transactions will be considered 'finalized'
|
||||
|
|
|
@ -27,6 +27,9 @@ import errno
|
|||
from . import coverage
|
||||
from .authproxy import AuthServiceProxy, JSONRPCException
|
||||
|
||||
DEFAULT_FEE = Decimal('0.00001')
|
||||
DEFAULT_FEE_ZATS = 1000
|
||||
|
||||
COVERAGE_DIR = None
|
||||
PRE_BLOSSOM_BLOCK_TARGET_SPACING = 150
|
||||
POST_BLOSSOM_BLOCK_TARGET_SPACING = 75
|
||||
|
|
|
@ -8,7 +8,7 @@ from test_framework.authproxy import JSONRPCException
|
|||
from test_framework.util import assert_equal, assert_greater_than, \
|
||||
start_nodes, start_node, connect_nodes_bi, \
|
||||
stop_nodes, sync_blocks, sync_mempools, wait_and_assert_operationid_status, \
|
||||
wait_bitcoinds
|
||||
wait_bitcoinds, DEFAULT_FEE
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -51,7 +51,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert_equal(self.nodes[1].getbalance("*"), 10)
|
||||
assert_equal(self.nodes[2].getbalance("*"), 0)
|
||||
|
||||
# Send 21 BTC from 0 to 2 using sendtoaddress call.
|
||||
# Send 21 ZEC from 0 to 2 using sendtoaddress call.
|
||||
# Second transaction will be child of first, and will require a fee
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
|
||||
|
@ -71,8 +71,8 @@ class WalletTest (BitcoinTestFramework):
|
|||
self.nodes[1].generate(100)
|
||||
self.sync_all()
|
||||
|
||||
# node0 should end up with 50 btc in block rewards plus fees, but
|
||||
# minus the 21 plus fees sent to node2
|
||||
# node0 should end up with 50 ZEC in block rewards plus fees, but
|
||||
# minus the 21 ZEC plus fees sent to node2
|
||||
assert_equal(self.nodes[0].getbalance(), 50-21)
|
||||
assert_equal(self.nodes[2].getbalance(), 21)
|
||||
assert_equal(self.nodes[0].getbalance("*"), 50-21)
|
||||
|
@ -97,8 +97,8 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert_equal(sum(int(uxto["generated"] is True) for uxto in node2utxos), 0)
|
||||
|
||||
# Catch an attempt to send a transaction with an absurdly high fee.
|
||||
# Send 1.0 from an utxo of value 10.0 but don't specify a change output, so then
|
||||
# the change of 9.0 becomes the fee, which is greater than estimated fee of 0.0021.
|
||||
# Send 1.0 ZEC from an utxo of value 10.0 ZEC but don't specify a change output, so then
|
||||
# the change of 9.0 ZEC becomes the fee, which is greater than estimated fee of 0.0021 ZEC.
|
||||
inputs = []
|
||||
outputs = {}
|
||||
for utxo in node2utxos:
|
||||
|
@ -141,9 +141,9 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert_equal(self.nodes[0].getbalance("*"), 0)
|
||||
assert_equal(self.nodes[2].getbalance("*"), 50)
|
||||
|
||||
# Send 10 BTC normal
|
||||
# Send 10 ZEC normally
|
||||
address = self.nodes[0].getnewaddress("")
|
||||
self.nodes[2].settxfee(Decimal('0.001'))
|
||||
self.nodes[2].settxfee(Decimal('0.001')) # not the default
|
||||
self.nodes[2].sendtoaddress(address, 10, "", "", False)
|
||||
self.sync_all()
|
||||
self.nodes[2].generate(1)
|
||||
|
@ -153,7 +153,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert_equal(self.nodes[2].getbalance("*"), Decimal('39.99900000'))
|
||||
assert_equal(self.nodes[0].getbalance("*"), Decimal('10.00000000'))
|
||||
|
||||
# Send 10 BTC with subtract fee from amount
|
||||
# Send 10 ZEC with subtract fee from amount
|
||||
self.nodes[2].sendtoaddress(address, 10, "", "", True)
|
||||
self.sync_all()
|
||||
self.nodes[2].generate(1)
|
||||
|
@ -163,7 +163,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert_equal(self.nodes[2].getbalance("*"), Decimal('29.99900000'))
|
||||
assert_equal(self.nodes[0].getbalance("*"), Decimal('19.99900000'))
|
||||
|
||||
# Sendmany 10 BTC
|
||||
# Sendmany 10 ZEC
|
||||
self.nodes[2].sendmany("", {address: 10}, 0, "", [])
|
||||
self.sync_all()
|
||||
self.nodes[2].generate(1)
|
||||
|
@ -173,7 +173,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert_equal(self.nodes[2].getbalance("*"), Decimal('19.99800000'))
|
||||
assert_equal(self.nodes[0].getbalance("*"), Decimal('29.99900000'))
|
||||
|
||||
# Sendmany 10 BTC with subtract fee from amount
|
||||
# Sendmany 10 ZEC with subtract fee from amount
|
||||
self.nodes[2].sendmany("", {address: 10}, 0, "", [address])
|
||||
self.sync_all()
|
||||
self.nodes[2].generate(1)
|
||||
|
@ -340,7 +340,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
|
||||
# check balances
|
||||
zsendmanynotevalue = Decimal('7.0')
|
||||
zsendmanyfee = Decimal('0.0001')
|
||||
zsendmanyfee = DEFAULT_FEE
|
||||
node2utxobalance = Decimal('23.998') - zsendmanynotevalue - zsendmanyfee
|
||||
|
||||
# check shielded balance status with getwalletinfo
|
||||
|
@ -375,8 +375,12 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert_equal(mytxdetails["valueBalance"], -zsendmanynotevalue)
|
||||
|
||||
# send from private note to node 0 and node 2
|
||||
node0balance = self.nodes[0].getbalance() # 25.99794745
|
||||
node2balance = self.nodes[2].getbalance() # 16.99790000
|
||||
node0balance = self.nodes[0].getbalance()
|
||||
# The following assertion fails nondeterministically
|
||||
# assert_equal(node0balance, Decimal('25.99798873'))
|
||||
node2balance = self.nodes[2].getbalance()
|
||||
# The following assertion might fail nondeterministically
|
||||
# assert_equal(node2balance, Decimal('16.99799000'))
|
||||
|
||||
recipients = []
|
||||
recipients.append({"address":self.nodes[0].getnewaddress(), "amount":1})
|
||||
|
|
|
@ -9,7 +9,7 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
initialize_datadir, start_nodes, start_node, connect_nodes_bi, \
|
||||
bitcoind_processes, wait_and_assert_operationid_status, \
|
||||
get_coinbase_address
|
||||
get_coinbase_address, DEFAULT_FEE
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -53,7 +53,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
|
|||
|
||||
# Send 10 coins to our zaddr.
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr, "amount":Decimal('10.0') - Decimal('0.0001')})
|
||||
recipients.append({"address":myzaddr, "amount":Decimal('10.0') - DEFAULT_FEE})
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
self.nodes[0].generate(1)
|
||||
|
@ -69,7 +69,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
|
|||
|
||||
# Confirm the balance on node 0.
|
||||
resp = self.nodes[0].z_getbalance(myzaddr)
|
||||
assert_equal(Decimal(resp), Decimal('10.0') - Decimal('0.0001'))
|
||||
assert_equal(Decimal(resp), Decimal('10.0') - DEFAULT_FEE)
|
||||
|
||||
# Export the key for the zaddr from node 0.
|
||||
key = self.nodes[0].z_exportkey(myzaddr)
|
||||
|
@ -96,7 +96,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
|
|||
# Confirm that the balance on node 1 is valid now (node 1 must
|
||||
# have rescanned)
|
||||
resp = self.nodes[1].z_getbalance(myzaddr)
|
||||
assert_equal(Decimal(resp), Decimal('10.0') - Decimal('0.0001'))
|
||||
assert_equal(Decimal(resp), Decimal('10.0') - DEFAULT_FEE)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -7,7 +7,7 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes, stop_nodes, connect_nodes_bi, \
|
||||
wait_and_assert_operationid_status, wait_bitcoinds, get_coinbase_address, \
|
||||
sync_blocks, sync_mempools
|
||||
sync_blocks, sync_mempools, DEFAULT_FEE
|
||||
from decimal import Decimal
|
||||
|
||||
class WalletAnchorForkTest (BitcoinTestFramework):
|
||||
|
@ -48,7 +48,7 @@ class WalletAnchorForkTest (BitcoinTestFramework):
|
|||
mytaddr0 = get_coinbase_address(self.nodes[0])
|
||||
myzaddr0 = self.nodes[0].z_getnewaddress()
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr0, "amount": Decimal('10.0') - Decimal('0.0001')})
|
||||
recipients.append({"address":myzaddr0, "amount": Decimal('10.0') - DEFAULT_FEE})
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr0, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
||||
|
@ -72,7 +72,7 @@ class WalletAnchorForkTest (BitcoinTestFramework):
|
|||
|
||||
# Partition A, node 0 creates a joinsplit transaction
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr0, "amount": Decimal('10.0') - Decimal('0.0001')})
|
||||
recipients.append({"address":myzaddr0, "amount": Decimal('10.0') - DEFAULT_FEE})
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr0, recipients)
|
||||
txid = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
rawhex = self.nodes[0].getrawtransaction(txid)
|
||||
|
|
|
@ -8,6 +8,7 @@ from test_framework.util import (
|
|||
assert_equal,
|
||||
get_coinbase_address,
|
||||
wait_and_assert_operationid_status,
|
||||
DEFAULT_FEE
|
||||
)
|
||||
|
||||
from decimal import Decimal
|
||||
|
@ -30,7 +31,7 @@ class WalletListNotes(BitcoinTestFramework):
|
|||
assert_equal(201, self.nodes[0].getblockcount())
|
||||
|
||||
# Shield coinbase funds (must be a multiple of 10, no change allowed)
|
||||
receive_amount_10 = Decimal('10.0') - Decimal('0.0001')
|
||||
receive_amount_10 = Decimal('10.0') - DEFAULT_FEE
|
||||
recipients = [{"address":sproutzaddr, "amount":receive_amount_10}]
|
||||
myopid = self.nodes[0].z_sendmany(get_coinbase_address(self.nodes[0]), recipients)
|
||||
txid_1 = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
@ -63,9 +64,9 @@ class WalletListNotes(BitcoinTestFramework):
|
|||
# Current height = 202
|
||||
assert_equal(202, self.nodes[0].getblockcount())
|
||||
|
||||
# Send 1.0 (actually 0.9999) from sproutzaddr to a new zaddr
|
||||
# Send 1.0 minus default fee from sproutzaddr to a new zaddr
|
||||
sproutzaddr2 = self.nodes[0].z_getnewaddress('sprout')
|
||||
receive_amount_1 = Decimal('1.0') - Decimal('0.0001')
|
||||
receive_amount_1 = Decimal('1.0') - DEFAULT_FEE
|
||||
change_amount_9 = receive_amount_10 - Decimal('1.0')
|
||||
assert_equal('sprout', self.nodes[0].z_validateaddress(sproutzaddr2)['type'])
|
||||
recipients = [{"address": sproutzaddr2, "amount":receive_amount_1}]
|
||||
|
@ -101,10 +102,10 @@ class WalletListNotes(BitcoinTestFramework):
|
|||
# No funds in saplingzaddr yet
|
||||
assert_equal(0, len(self.nodes[0].z_listunspent(0, 9999, False, [saplingzaddr])))
|
||||
|
||||
# Send 0.9999 to our sapling zaddr
|
||||
# Send 2.0 minus default fee to our sapling zaddr
|
||||
# (sending from a sprout zaddr to a sapling zaddr is disallowed,
|
||||
# so send from coin base)
|
||||
receive_amount_2 = Decimal('2.0') - Decimal('0.0001')
|
||||
receive_amount_2 = Decimal('2.0') - DEFAULT_FEE
|
||||
recipients = [{"address": saplingzaddr, "amount":receive_amount_2}]
|
||||
myopid = self.nodes[0].z_sendmany(get_coinbase_address(self.nodes[0]), recipients)
|
||||
txid_3 = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
@ -133,12 +134,12 @@ class WalletListNotes(BitcoinTestFramework):
|
|||
assert_equal(sproutzaddr, unspent_tx[2]['address'])
|
||||
assert_equal(change_amount_9, unspent_tx[2]['amount'])
|
||||
|
||||
unspent_tx_filter = self.nodes[0].z_listunspent(0, 9999, False, [saplingzaddr])
|
||||
unspent_tx_filter = self.nodes[0].z_listunspent(0, 999, False, [saplingzaddr])
|
||||
assert_equal(1, len(unspent_tx_filter))
|
||||
assert_equal(unspent_tx[1], unspent_tx_filter[0])
|
||||
|
||||
# test that pre- and post-sapling can be filtered in a single call
|
||||
unspent_tx_filter = self.nodes[0].z_listunspent(0, 9999, False,
|
||||
unspent_tx_filter = self.nodes[0].z_listunspent(0, 999, False,
|
||||
[sproutzaddr, saplingzaddr])
|
||||
assert_equal(2, len(unspent_tx_filter))
|
||||
unspent_tx_filter = sorted(unspent_tx_filter, key=lambda k: k['amount'])
|
||||
|
@ -146,7 +147,7 @@ class WalletListNotes(BitcoinTestFramework):
|
|||
assert_equal(unspent_tx[2], unspent_tx_filter[1])
|
||||
|
||||
# so far, this node has no watchonly addresses, so results are the same
|
||||
unspent_tx_watchonly = self.nodes[0].z_listunspent(0, 9999, True)
|
||||
unspent_tx_watchonly = self.nodes[0].z_listunspent(0, 999, True)
|
||||
unspent_tx_watchonly = sorted(unspent_tx_watchonly, key=lambda k: k['amount'])
|
||||
assert_equal(unspent_tx, unspent_tx_watchonly)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, assert_false
|
||||
from test_framework.util import assert_equal, assert_true, assert_false, DEFAULT_FEE, DEFAULT_FEE_ZATS
|
||||
from test_framework.util import wait_and_assert_operationid_status
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -14,9 +14,6 @@ my_memo = my_memo + '0'*(1024-len(my_memo))
|
|||
|
||||
no_memo = 'f6' + ('0'*1022) # see section 5.5 of the protocol spec
|
||||
|
||||
fee = Decimal('0.0001')
|
||||
feeZat = 10000
|
||||
|
||||
class ListReceivedTest (BitcoinTestFramework):
|
||||
|
||||
def generate_and_sync(self, new_height):
|
||||
|
@ -193,8 +190,8 @@ class ListReceivedTest (BitcoinTestFramework):
|
|||
} in outputs)
|
||||
assert({
|
||||
'address': zaddr1,
|
||||
'value': Decimal('0.3999'),
|
||||
'valueZat': 39990000,
|
||||
'value': Decimal('0.4') - DEFAULT_FEE,
|
||||
'valueZat': 40000000 - DEFAULT_FEE_ZATS,
|
||||
'memo': no_memo,
|
||||
} in outputs)
|
||||
|
||||
|
@ -204,9 +201,9 @@ class ListReceivedTest (BitcoinTestFramework):
|
|||
assert_equal(2, len(r), "zaddr1 Should have received 2 notes")
|
||||
|
||||
assert_equal(txid, r[0]['txid'])
|
||||
assert_equal(Decimal('0.4')-fee, r[0]['amount'])
|
||||
assert_equal(40000000-feeZat, r[0]['amountZat'])
|
||||
assert_true(r[0]['change'], "Note valued at (0.4-fee) should be change")
|
||||
assert_equal(Decimal('0.4')-DEFAULT_FEE, r[0]['amount'])
|
||||
assert_equal(40000000-DEFAULT_FEE_ZATS, r[0]['amountZat'])
|
||||
assert_true(r[0]['change'], "Note valued at (0.4-"+str(DEFAULT_FEE)+") should be change")
|
||||
assert_equal(no_memo, r[0]['memo'])
|
||||
|
||||
# The old note still exists (it's immutable), even though it is spent
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, bitcoind_processes, \
|
||||
connect_nodes_bi, start_node, start_nodes, wait_and_assert_operationid_status, \
|
||||
get_coinbase_address
|
||||
get_coinbase_address, DEFAULT_FEE
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -24,7 +24,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
|||
# Tests using the default cached chain have one address per coinbase output
|
||||
mytaddr = get_coinbase_address(self.nodes[0])
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr0, "amount":Decimal('10.0')-Decimal('0.0001')}) # utxo amount less fee
|
||||
recipients.append({"address": myzaddr0, "amount": Decimal('10.0') - DEFAULT_FEE}) # utxo amount less fee
|
||||
|
||||
wait_and_assert_operationid_status(self.nodes[0], self.nodes[0].z_sendmany(mytaddr, recipients), timeout=120)
|
||||
|
||||
|
@ -79,7 +79,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
|||
|
||||
# check zaddr balance
|
||||
zsendmany2notevalue = Decimal('2.0')
|
||||
zsendmanyfee = Decimal('0.0001')
|
||||
zsendmanyfee = DEFAULT_FEE
|
||||
zaddrremaining = zsendmanynotevalue - zsendmany2notevalue - zsendmanyfee
|
||||
assert_equal(self.nodes[3].z_getbalance(myzaddr3), zsendmany2notevalue)
|
||||
assert_equal(self.nodes[2].z_getbalance(myzaddr), zaddrremaining)
|
||||
|
|
|
@ -11,6 +11,7 @@ from test_framework.util import (
|
|||
get_coinbase_address,
|
||||
start_nodes,
|
||||
wait_and_assert_operationid_status,
|
||||
DEFAULT_FEE
|
||||
)
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
|
||||
|
@ -69,8 +70,8 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
myopid = self.nodes[2].z_sendmany(taddr2, recipients, 0)
|
||||
txid_zsendmany = wait_and_assert_operationid_status(self.nodes[2], myopid)
|
||||
|
||||
# Node 0 shields to Node 2, a coinbase utxo of value 10.0 less fee 0.00010000
|
||||
zsendamount = Decimal('10.0') - Decimal('0.0001')
|
||||
# Node 0 shields to Node 2, a coinbase utxo of value 10.0 less default fee
|
||||
zsendamount = Decimal('10.0') - DEFAULT_FEE
|
||||
recipients = []
|
||||
recipients.append({"address":zaddr2, "amount": zsendamount})
|
||||
myopid = self.nodes[0].z_sendmany(taddr0, recipients)
|
||||
|
@ -84,7 +85,7 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
|
||||
# Verify balance
|
||||
assert_equal(self.nodes[1].z_getbalance(taddr1), Decimal('0.5'))
|
||||
assert_equal(self.nodes[2].getbalance(), Decimal('0.4999'))
|
||||
assert_equal(self.nodes[2].getbalance(), Decimal('0.5') - DEFAULT_FEE)
|
||||
assert_equal(self.nodes[2].z_getbalance(zaddr2), zsendamount)
|
||||
|
||||
# Verify transaction version is 4 (intended for Sapling+)
|
||||
|
@ -140,8 +141,8 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
myopid = self.nodes[3].z_sendmany(taddr3, recipients, 0)
|
||||
txid_zsendmany = wait_and_assert_operationid_status(self.nodes[3], myopid)
|
||||
|
||||
# Node 0 shields to Node 3, a coinbase utxo of value 10.0 less fee 0.00010000
|
||||
zsendamount = Decimal('10.0') - Decimal('0.0001')
|
||||
# Node 0 shields to Node 3, a coinbase utxo of value 10.0 less default fee
|
||||
zsendamount = Decimal('10.0') - DEFAULT_FEE
|
||||
recipients = []
|
||||
recipients.append({"address":zaddr3, "amount": zsendamount})
|
||||
myopid = self.nodes[0].z_sendmany(taddr0, recipients)
|
||||
|
@ -162,7 +163,7 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
|
||||
# Verify balance
|
||||
assert_equal(self.nodes[1].z_getbalance(taddr1), Decimal('1.0'))
|
||||
assert_equal(self.nodes[3].getbalance(), Decimal('0.4999'))
|
||||
assert_equal(self.nodes[3].getbalance(), Decimal('0.5') - DEFAULT_FEE)
|
||||
assert_equal(self.nodes[3].z_getbalance(zaddr3), zsendamount)
|
||||
|
||||
# Verify transaction version is 4 (intended for Sapling+)
|
||||
|
|
|
@ -9,6 +9,7 @@ from test_framework.util import (
|
|||
assert_equal,
|
||||
get_coinbase_address,
|
||||
wait_and_assert_operationid_status,
|
||||
DEFAULT_FEE
|
||||
)
|
||||
|
||||
from decimal import Decimal
|
||||
|
@ -162,8 +163,9 @@ class WalletSaplingTest(BitcoinTestFramework):
|
|||
try:
|
||||
self.nodes[1].z_sendmany(
|
||||
taddr1,
|
||||
[{'address': node4_sproutaddr, 'amount': 2.5}, {'address': node4_saplingaddr, 'amount': 2.4999}],
|
||||
1, 0.0001
|
||||
[{'address': node4_sproutaddr, 'amount': Decimal('2.5')},
|
||||
{'address': node4_saplingaddr, 'amount': Decimal('2.5') - DEFAULT_FEE}],
|
||||
1, DEFAULT_FEE
|
||||
)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
|
|
|
@ -7,7 +7,7 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_node, connect_nodes_bi, sync_blocks, sync_mempools, \
|
||||
wait_and_assert_operationid_status, get_coinbase_address
|
||||
wait_and_assert_operationid_status, get_coinbase_address, DEFAULT_FEE
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -101,7 +101,7 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
errorString = e.error['message']
|
||||
assert_equal("JSON integer out of range" in errorString, True)
|
||||
|
||||
# Shield coinbase utxos from node 0 of value 40, standard fee of 0.00010000
|
||||
# Shield coinbase utxos from node 0 of value 40, standard fee
|
||||
result = self.nodes[0].z_shieldcoinbase(mytaddr, myzaddr)
|
||||
wait_and_assert_operationid_status(self.nodes[0], result['opid'])
|
||||
self.sync_all()
|
||||
|
@ -111,7 +111,7 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
# Confirm balances and that do_not_shield_taddr containing funds of 10 was left alone
|
||||
assert_equal(self.nodes[0].getbalance(), 10)
|
||||
assert_equal(self.nodes[0].z_getbalance(do_not_shield_taddr), Decimal('10.0'))
|
||||
assert_equal(self.nodes[0].z_getbalance(myzaddr), Decimal('39.99990000'))
|
||||
assert_equal(self.nodes[0].z_getbalance(myzaddr), Decimal('40.0') - DEFAULT_FEE)
|
||||
assert_equal(self.nodes[1].getbalance(), 20)
|
||||
assert_equal(self.nodes[2].getbalance(), 30)
|
||||
|
||||
|
@ -123,7 +123,7 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 10)
|
||||
assert_equal(self.nodes[0].z_getbalance(myzaddr), Decimal('69.99990000'))
|
||||
assert_equal(self.nodes[0].z_getbalance(myzaddr), Decimal('70.0') - DEFAULT_FEE)
|
||||
assert_equal(self.nodes[1].getbalance(), 30)
|
||||
assert_equal(self.nodes[2].getbalance(), 0)
|
||||
|
||||
|
@ -170,13 +170,13 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
self.nodes[0].generate(200)
|
||||
self.sync_all()
|
||||
mytaddr = get_coinbase_address(self.nodes[0], 100)
|
||||
result = self.nodes[0].z_shieldcoinbase(mytaddr, myzaddr, Decimal('0.0001'))
|
||||
result = self.nodes[0].z_shieldcoinbase(mytaddr, myzaddr, DEFAULT_FEE)
|
||||
assert_equal(result["shieldingUTXOs"], Decimal('50'))
|
||||
assert_equal(result["remainingUTXOs"], Decimal('50'))
|
||||
wait_and_assert_operationid_status(self.nodes[0], result['opid'])
|
||||
|
||||
# Verify maximum number of utxos which node 0 can shield can be set by the limit parameter
|
||||
result = self.nodes[0].z_shieldcoinbase(mytaddr, myzaddr, Decimal('0.0001'), 33)
|
||||
result = self.nodes[0].z_shieldcoinbase(mytaddr, myzaddr, DEFAULT_FEE, 33)
|
||||
assert_equal(result["shieldingUTXOs"], Decimal('33'))
|
||||
assert_equal(result["remainingUTXOs"], Decimal('17'))
|
||||
wait_and_assert_operationid_status(self.nodes[0], result['opid'])
|
||||
|
|
|
@ -9,7 +9,7 @@ from test_framework.mininode import COIN
|
|||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes, connect_nodes_bi, wait_and_assert_operationid_status, \
|
||||
wait_and_assert_operationid_status_result, get_coinbase_address, \
|
||||
check_node_log
|
||||
check_node_log, DEFAULT_FEE
|
||||
|
||||
import sys
|
||||
import timeit
|
||||
|
@ -92,14 +92,14 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
recipients.append({"address":myzaddr, "amount":Decimal('1.23456789')})
|
||||
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
error_result = wait_and_assert_operationid_status_result(self.nodes[0], myopid, "failed", ("Change 8.76533211 not allowed. "
|
||||
error_result = wait_and_assert_operationid_status_result(self.nodes[0], myopid, "failed", ("Change 8.76542211 not allowed. "
|
||||
"When shielding coinbase funds, the wallet does not allow any change "
|
||||
"as there is currently no way to specify a change address in z_sendmany."), 10)
|
||||
|
||||
# Test that the returned status object contains a params field with the operation's input parameters
|
||||
assert_equal(error_result["method"], "z_sendmany")
|
||||
params = error_result["params"]
|
||||
assert_equal(params["fee"], Decimal('0.0001')) # default
|
||||
assert_equal(params["fee"], DEFAULT_FEE) # default
|
||||
assert_equal(params["minconf"], Decimal('1')) # default
|
||||
assert_equal(params["fromaddress"], mytaddr)
|
||||
assert_equal(params["amounts"][0]["address"], myzaddr)
|
||||
|
@ -109,8 +109,8 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
myviewingkey = self.nodes[0].z_exportviewingkey(myzaddr)
|
||||
self.nodes[3].z_importviewingkey(myviewingkey, "no")
|
||||
|
||||
# This send will succeed. We send two coinbase utxos totalling 20.0 less a fee of 0.00010000, with no change.
|
||||
shieldvalue = Decimal('20.0') - Decimal('0.0001')
|
||||
# This send will succeed. We send two coinbase utxos totalling 20.0 less a default fee, with no change.
|
||||
shieldvalue = Decimal('20.0') - DEFAULT_FEE
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr, "amount": shieldvalue})
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
|
@ -161,8 +161,8 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
# check balances (the z_sendmany consumes 3 coinbase utxos)
|
||||
resp = self.nodes[0].z_gettotalbalance()
|
||||
assert_equal(Decimal(resp["transparent"]), Decimal('20.0'))
|
||||
assert_equal(Decimal(resp["private"]), Decimal('19.9999'))
|
||||
assert_equal(Decimal(resp["total"]), Decimal('39.9999'))
|
||||
assert_equal(Decimal(resp["private"]), Decimal('20.0') - DEFAULT_FEE)
|
||||
assert_equal(Decimal(resp["total"]), Decimal('40.0') - DEFAULT_FEE)
|
||||
|
||||
# The Sprout value pool should reflect the send
|
||||
sproutvalue = shieldvalue
|
||||
|
@ -170,7 +170,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
|
||||
# A custom fee of 0 is okay. Here the node will send the note value back to itself.
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr, "amount": Decimal('19.9999')})
|
||||
recipients.append({"address":myzaddr, "amount": Decimal('20.0') - DEFAULT_FEE})
|
||||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, 1, Decimal('0.0'))
|
||||
mytxid = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
self.sync_all()
|
||||
|
@ -178,8 +178,8 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
resp = self.nodes[0].z_gettotalbalance()
|
||||
assert_equal(Decimal(resp["transparent"]), Decimal('20.0'))
|
||||
assert_equal(Decimal(resp["private"]), Decimal('19.9999'))
|
||||
assert_equal(Decimal(resp["total"]), Decimal('39.9999'))
|
||||
assert_equal(Decimal(resp["private"]), Decimal('20.0') - DEFAULT_FEE)
|
||||
assert_equal(Decimal(resp["total"]), Decimal('40.0') - DEFAULT_FEE)
|
||||
|
||||
# The Sprout value pool should be unchanged
|
||||
check_value_pool(self.nodes[0], 'sprout', sproutvalue)
|
||||
|
@ -201,18 +201,18 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
# check balances
|
||||
sproutvalue -= unshieldvalue + Decimal('0.0001')
|
||||
sproutvalue -= unshieldvalue + DEFAULT_FEE
|
||||
resp = self.nodes[0].z_gettotalbalance()
|
||||
assert_equal(Decimal(resp["transparent"]), Decimal('30.0'))
|
||||
assert_equal(Decimal(resp["private"]), Decimal('9.9998'))
|
||||
assert_equal(Decimal(resp["total"]), Decimal('39.9998'))
|
||||
assert_equal(Decimal(resp["private"]), Decimal('10.0') - 2*DEFAULT_FEE)
|
||||
assert_equal(Decimal(resp["total"]), Decimal('40.0') - 2*DEFAULT_FEE)
|
||||
check_value_pool(self.nodes[0], 'sprout', sproutvalue)
|
||||
|
||||
# z_sendmany will return an error if there is transparent change output considered dust.
|
||||
# UTXO selection in z_sendmany sorts in ascending order, so smallest utxos are consumed first.
|
||||
# At this point in time, unspent notes all have a value of 10.0 and standard z_sendmany fee is 0.0001.
|
||||
# At this point in time, unspent notes all have a value of 10.0.
|
||||
recipients = []
|
||||
amount = Decimal('10.0') - Decimal('0.00010000') - Decimal('0.00000001') # this leaves change at 1 zatoshi less than dust threshold
|
||||
amount = Decimal('10.0') - DEFAULT_FEE - Decimal('0.00000001') # this leaves change at 1 zatoshi less than dust threshold
|
||||
recipients.append({"address":self.nodes[0].getnewaddress(), "amount":amount })
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Insufficient transparent funds, have 10.00, need 0.00000053 more to avoid creating invalid change output 0.00000001 (dust threshold is 0.00000054)")
|
||||
|
@ -229,9 +229,9 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
recipients = []
|
||||
recipients.append({"address":self.nodes[1].getnewaddress(), "amount":Decimal('10000.0')})
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Insufficient transparent funds, have 10.00, need 10000.0001")
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Insufficient transparent funds, have 10.00, need 10000.00001")
|
||||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Insufficient shielded funds, have 9.9998, need 10000.0001")
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Insufficient shielded funds, have 9.99998, need 10000.00001")
|
||||
|
||||
# Send will fail because of insufficient funds unless sender uses coinbase utxos
|
||||
try:
|
||||
|
@ -282,7 +282,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
|
||||
# check balance
|
||||
node2balance = amount_per_recipient * num_t_recipients
|
||||
sproutvalue -= node2balance + Decimal('0.0001')
|
||||
sproutvalue -= node2balance + DEFAULT_FEE
|
||||
assert_equal(self.nodes[2].getbalance(), node2balance)
|
||||
check_value_pool(self.nodes[0], 'sprout', sproutvalue)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes, connect_nodes_bi, wait_and_assert_operationid_status, \
|
||||
get_coinbase_address
|
||||
get_coinbase_address, DEFAULT_FEE
|
||||
|
||||
import time
|
||||
from decimal import Decimal
|
||||
|
@ -37,9 +37,9 @@ class WalletTreeStateTest (BitcoinTestFramework):
|
|||
mytaddr = get_coinbase_address(self.nodes[0])
|
||||
myzaddr = self.nodes[0].z_getnewaddress()
|
||||
|
||||
# Spend coinbase utxos to create three notes of 9.99990000 each
|
||||
# Spend coinbase utxos to create three notes of 10 ZEC minus default fee each
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr, "amount":Decimal('10.0') - Decimal('0.0001')})
|
||||
recipients.append({"address": myzaddr, "amount": Decimal('10.0') - DEFAULT_FEE})
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
self.sync_all()
|
||||
|
@ -58,7 +58,7 @@ class WalletTreeStateTest (BitcoinTestFramework):
|
|||
|
||||
# Check balance
|
||||
resp = self.nodes[0].z_getbalance(myzaddr)
|
||||
assert_equal(Decimal(resp), Decimal('9.9999') * 3 )
|
||||
assert_equal(Decimal(resp), (Decimal('10.0') - DEFAULT_FEE) * 3)
|
||||
|
||||
# We want to test a real-world situation where during the time spent creating a transaction
|
||||
# with joinsplits, other transactions containing joinsplits have been mined into new blocks,
|
||||
|
@ -66,15 +66,15 @@ class WalletTreeStateTest (BitcoinTestFramework):
|
|||
|
||||
# Tx 1 will change the treestate while Tx 2 containing chained joinsplits is still being generated
|
||||
recipients = []
|
||||
recipients.append({"address":self.nodes[2].z_getnewaddress(), "amount":Decimal('10.0') - Decimal('0.0001')})
|
||||
recipients.append({"address": self.nodes[2].z_getnewaddress(), "amount": Decimal('10.0') - DEFAULT_FEE})
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
||||
# Tx 2 will consume all three notes, which must take at least two joinsplits. This is regardless of
|
||||
# the z_sendmany implementation because there are only two inputs per joinsplit.
|
||||
recipients = []
|
||||
recipients.append({"address":self.nodes[2].z_getnewaddress(), "amount":Decimal('18')})
|
||||
recipients.append({"address":self.nodes[2].z_getnewaddress(), "amount":Decimal('11.9997') - Decimal('0.0001')})
|
||||
recipients.append({"address": self.nodes[2].z_getnewaddress(), "amount": Decimal('18.0')})
|
||||
recipients.append({"address": self.nodes[2].z_getnewaddress(), "amount": Decimal('12.0') - 4*DEFAULT_FEE})
|
||||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients)
|
||||
|
||||
# Wait for Tx 2 to begin executing...
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
from decimal import Decimal
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_greater_than, start_nodes,\
|
||||
initialize_chain_clean, connect_nodes_bi, wait_and_assert_operationid_status
|
||||
initialize_chain_clean, connect_nodes_bi, wait_and_assert_operationid_status, \
|
||||
DEFAULT_FEE
|
||||
from functools import reduce
|
||||
import logging
|
||||
import sys
|
||||
|
||||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO, stream=sys.stdout)
|
||||
|
||||
fee = Decimal('0.0001') # constant (but can be changed within reason)
|
||||
fee = DEFAULT_FEE # constant (but can be changed within reason)
|
||||
|
||||
class ZkeyImportExportTest (BitcoinTestFramework):
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ from decimal import Decimal
|
|||
from slickrpc import Proxy
|
||||
from slickrpc.exc import RpcException
|
||||
|
||||
DEFAULT_FEE = Decimal('0.0001')
|
||||
DEFAULT_FEE = Decimal('0.00001')
|
||||
URL_FAUCET_DONATION = 'https://faucet.testnet.z.cash/donations'
|
||||
URL_FAUCET_TAP = 'https://faucet.testnet.z.cash/'
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
#include "amount.h"
|
||||
#include "policy/fees.h"
|
||||
|
||||
#include "tinyformat.h"
|
||||
|
||||
|
@ -18,6 +19,11 @@ CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize)
|
|||
nSatoshisPerK = 0;
|
||||
}
|
||||
|
||||
CAmount CFeeRate::GetFeeForRelay(size_t nSize) const
|
||||
{
|
||||
return std::min(GetFee(nSize), DEFAULT_FEE);
|
||||
}
|
||||
|
||||
CAmount CFeeRate::GetFee(size_t nSize) const
|
||||
{
|
||||
CAmount nFee = nSatoshisPerK*nSize / 1000;
|
||||
|
|
|
@ -19,7 +19,7 @@ static const CAmount CENT = 1000000;
|
|||
extern const std::string CURRENCY_UNIT;
|
||||
extern const std::string MINOR_CURRENCY_UNIT;
|
||||
|
||||
/** No amount larger than this (in satoshi) is valid.
|
||||
/** No amount larger than this (in zatoshi) is valid.
|
||||
*
|
||||
* Note that this constant is *not* the total money supply, which in Bitcoin
|
||||
* currently happens to be less than 21,000,000 BTC for various reasons, but
|
||||
|
@ -37,15 +37,16 @@ inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <=
|
|||
class CFeeRate
|
||||
{
|
||||
private:
|
||||
CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes
|
||||
CAmount nSatoshisPerK; // unit is zatoshis-per-1,000-bytes
|
||||
public:
|
||||
CFeeRate() : nSatoshisPerK(0) { }
|
||||
explicit CFeeRate(const CAmount& _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { }
|
||||
CFeeRate(const CAmount& nFeePaid, size_t nSize);
|
||||
CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; }
|
||||
|
||||
CAmount GetFee(size_t size) const; // unit returned is satoshis
|
||||
CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes
|
||||
CAmount GetFeeForRelay(size_t size) const; // unit returned is zatoshis
|
||||
CAmount GetFee(size_t size) const; // unit returned is zatoshis
|
||||
CAmount GetFeePerK() const { return GetFee(1000); } // zatoshis-per-1000-bytes
|
||||
|
||||
friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
|
||||
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) 2019 The Zcash developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php
|
||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
|
@ -135,7 +135,8 @@ TEST(MempoolLimitTests, WeightedTxInfoFromTx)
|
|||
builder.AddSaplingOutput(sk.full_viewing_key().ovk, sk.default_address(), 25000, {});
|
||||
builder.SetFee(9999);
|
||||
|
||||
WeightedTxInfo info = WeightedTxInfo::from(builder.Build().GetTxOrThrow(), 9999);
|
||||
static_assert(DEFAULT_FEE == 1000);
|
||||
WeightedTxInfo info = WeightedTxInfo::from(builder.Build().GetTxOrThrow(), DEFAULT_FEE-1);
|
||||
EXPECT_EQ(MIN_TX_COST, info.txWeight.cost);
|
||||
EXPECT_EQ(MIN_TX_COST + LOW_FEE_PENALTY, info.txWeight.evictionWeight);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ TEST(TransactionBuilder, TransparentToSapling)
|
|||
auto pk = *ivk.address(d);
|
||||
|
||||
// Create a shielding transaction from transparent to Sapling
|
||||
// 0.0005 t-ZEC in, 0.0004 z-ZEC out, 0.0001 t-ZEC fee
|
||||
// 0.0005 t-ZEC in, 0.0004 z-ZEC out, default fee
|
||||
auto builder = TransactionBuilder(consensusParams, 1, &keystore);
|
||||
builder.AddTransparentInput(COutPoint(uint256S("1234"), 0), scriptPubKey, 50000);
|
||||
builder.AddSaplingOutput(fvk_from.ovk, pk, 40000, {});
|
||||
|
@ -123,7 +123,7 @@ TEST(TransactionBuilder, SaplingToSapling) {
|
|||
auto testNote = GetTestSaplingNote(pa, 40000);
|
||||
|
||||
// Create a Sapling-only transaction
|
||||
// 0.0004 z-ZEC in, 0.00025 z-ZEC out, 0.0001 t-ZEC fee, 0.00005 z-ZEC change
|
||||
// 0.0004 z-ZEC in, 0.00025 z-ZEC out, default fee, 0.00005 z-ZEC change
|
||||
auto builder = TransactionBuilder(consensusParams, 2);
|
||||
builder.AddSaplingSpend(expsk, testNote.note, testNote.tree.root(), testNote.tree.witness());
|
||||
|
||||
|
@ -164,7 +164,7 @@ TEST(TransactionBuilder, SaplingToSprout) {
|
|||
// Create a Sapling-to-Sprout transaction (reusing the note from above)
|
||||
// - 0.0004 Sapling-ZEC in - 0.00025 Sprout-ZEC out
|
||||
// - 0.00005 Sapling-ZEC change
|
||||
// - 0.0001 t-ZEC fee
|
||||
// - default t-ZEC fee
|
||||
auto builder = TransactionBuilder(consensusParams, 2, nullptr);
|
||||
builder.AddSaplingSpend(expsk, testNote.note, testNote.tree.root(), testNote.tree.witness());
|
||||
builder.AddSproutOutput(sproutAddr, 25000);
|
||||
|
@ -299,19 +299,19 @@ TEST(TransactionBuilder, FailsWithNegativeChange)
|
|||
auto testNote = GetTestSaplingNote(pa, 59999);
|
||||
|
||||
// Fail if there is only a Sapling output
|
||||
// 0.0005 z-ZEC out, 0.0001 t-ZEC fee
|
||||
// 0.0005 z-ZEC out, default fee
|
||||
auto builder = TransactionBuilder(consensusParams, 1);
|
||||
builder.AddSaplingOutput(fvk.ovk, pa, 50000, {});
|
||||
EXPECT_EQ("Change cannot be negative", builder.Build().GetError());
|
||||
|
||||
// Fail if there is only a transparent output
|
||||
// 0.0005 t-ZEC out, 0.0001 t-ZEC fee
|
||||
// 0.0005 t-ZEC out, default fee
|
||||
builder = TransactionBuilder(consensusParams, 1, &keystore);
|
||||
builder.AddTransparentOutput(taddr, 50000);
|
||||
EXPECT_EQ("Change cannot be negative", builder.Build().GetError());
|
||||
|
||||
// Fails if there is insufficient input
|
||||
// 0.0005 t-ZEC out, 0.0001 t-ZEC fee, 0.00059999 z-ZEC in
|
||||
// 0.0005 t-ZEC out, default fee, 0.00059999 z-ZEC in
|
||||
builder.AddSaplingSpend(expsk, testNote.note, testNote.tree.root(), testNote.tree.witness());
|
||||
EXPECT_EQ("Change cannot be negative", builder.Build().GetError());
|
||||
|
||||
|
|
18
src/main.cpp
18
src/main.cpp
|
@ -1411,7 +1411,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
|
|||
return 0;
|
||||
}
|
||||
|
||||
CAmount nMinFee = ::minRelayTxFee.GetFee(nBytes);
|
||||
CAmount nMinFee = ::minRelayTxFee.GetFeeForRelay(nBytes);
|
||||
|
||||
if (fAllowFree)
|
||||
{
|
||||
|
@ -1603,27 +1603,27 @@ bool AcceptToMemoryPool(
|
|||
CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), mempool.HasNoInputsOf(tx), fSpendsCoinbase, consensusBranchId);
|
||||
unsigned int nSize = entry.GetTxSize();
|
||||
|
||||
// Accept a tx if it contains joinsplits and has at least the default fee specified by z_sendmany.
|
||||
if (tx.vJoinSplit.size() > 0 && nFees >= ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE) {
|
||||
// In future we will we have more accurate and dynamic computation of fees for tx with joinsplits.
|
||||
} else {
|
||||
// Don't accept it if it can't get into a block
|
||||
// Before zcashd 4.2.0, we had a condition here to always accept a tx if it contained
|
||||
// JoinSplits and had at least the default fee. It is no longer necessary to treat
|
||||
// that as a special case, because the fee returned by GetMinRelayFee is always at
|
||||
// most DEFAULT_FEE.
|
||||
|
||||
CAmount txMinFee = GetMinRelayFee(tx, nSize, true);
|
||||
if (fLimitFree && nFees < txMinFee)
|
||||
if (fLimitFree && nFees < txMinFee) {
|
||||
return state.DoS(0, error("AcceptToMemoryPool: not enough fees %s, %d < %d",
|
||||
hash.ToString(), nFees, txMinFee),
|
||||
REJECT_INSUFFICIENTFEE, "insufficient fee");
|
||||
}
|
||||
|
||||
// Require that free transactions have sufficient priority to be mined in the next block.
|
||||
if (GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) {
|
||||
if (GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nFees < ::minRelayTxFee.GetFeeForRelay(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) {
|
||||
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority");
|
||||
}
|
||||
|
||||
// Continuously rate-limit free (really, very-low-fee) transactions
|
||||
// This mitigates 'penny-flooding' -- sending thousands of free transactions just to
|
||||
// be annoying or make others' transactions take longer to confirm.
|
||||
if (fLimitFree && nFees < ::minRelayTxFee.GetFee(nSize))
|
||||
if (fLimitFree && nFees < ::minRelayTxFee.GetFeeForRelay(nSize))
|
||||
{
|
||||
static CCriticalSection csFreeLimiter;
|
||||
static double dFreeCount;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) 2019 The Zcash developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php
|
||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
#include "core_memusage.h"
|
||||
#include "mempool_limit.h"
|
||||
|
@ -9,7 +9,6 @@
|
|||
#include "timedata.h"
|
||||
#include "version.h"
|
||||
|
||||
const CAmount DEFAULT_FEE = 10000;
|
||||
const TxWeight ZERO_WEIGHT = TxWeight(0, 0);
|
||||
|
||||
void RecentlyEvictedList::pruneList()
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "primitives/transaction.h"
|
||||
#include "policy/fees.h"
|
||||
#include "uint256.h"
|
||||
|
||||
const size_t DEFAULT_MEMPOOL_TOTAL_COST_LIMIT = 80000000;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
static const CAmount DEFAULT_FEE = 1000;
|
||||
|
||||
class CAutoFile;
|
||||
class CFeeRate;
|
||||
class CTxMemPoolEntry;
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
|
||||
#include <rust/ed25519/types.h>
|
||||
|
||||
// Default transaction fee if caller does not specify one.
|
||||
#define MERGE_TO_ADDRESS_OPERATION_DEFAULT_MINERS_FEE 10000
|
||||
|
||||
using namespace libzcash;
|
||||
|
||||
// Input UTXO is a tuple of txid, vout, amount, script
|
||||
|
@ -65,7 +62,7 @@ public:
|
|||
std::vector<MergeToAddressInputSproutNote> sproutNoteInputs,
|
||||
std::vector<MergeToAddressInputSaplingNote> saplingNoteInputs,
|
||||
MergeToAddressRecipient recipient,
|
||||
CAmount fee = MERGE_TO_ADDRESS_OPERATION_DEFAULT_MINERS_FEE,
|
||||
CAmount fee = DEFAULT_FEE,
|
||||
UniValue contextInfo = NullUniValue);
|
||||
virtual ~AsyncRPCOperation_mergetoaddress();
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
const CAmount FEE = 10000;
|
||||
const int MIGRATION_EXPIRY_DELTA = 450;
|
||||
|
||||
AsyncRPCOperation_saplingmigration::AsyncRPCOperation_saplingmigration(int targetHeight) : targetHeight_(targetHeight) {}
|
||||
|
@ -114,7 +113,7 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
|
|||
CAmount amountToSend = chooseAmount(availableFunds);
|
||||
auto builder = TransactionBuilder(consensusParams, targetHeight_, pwalletMain, &coinsView, &cs_main);
|
||||
builder.SetExpiryHeight(targetHeight_ + MIGRATION_EXPIRY_DELTA);
|
||||
LogPrint("zrpcunsafe", "%s: Beginning creating transaction with Sapling output amount=%s\n", getId(), FormatMoney(amountToSend - FEE));
|
||||
LogPrint("zrpcunsafe", "%s: Beginning creating transaction with Sapling output amount=%s\n", getId(), FormatMoney(amountToSend - DEFAULT_FEE));
|
||||
std::vector<SproutNoteEntry> fromNotes;
|
||||
CAmount fromNoteAmount = 0;
|
||||
while (fromNoteAmount < amountToSend) {
|
||||
|
@ -144,10 +143,10 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
|
|||
pwalletMain->GetSproutNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
|
||||
builder.AddSproutInput(sproutSk, sproutEntry.note, vInputWitnesses[0].value());
|
||||
}
|
||||
// The amount chosen *includes* the 0.0001 ZEC fee for this transaction, i.e.
|
||||
// the value of the Sapling output will be 0.0001 ZEC less.
|
||||
builder.SetFee(FEE);
|
||||
builder.AddSaplingOutput(ovkForShieldingFromTaddr(seed), migrationDestAddress, amountToSend - FEE);
|
||||
// The amount chosen *includes* the default fee for this transaction, i.e.
|
||||
// the value of the Sapling output will be 0.00001 ZEC less.
|
||||
builder.SetFee(DEFAULT_FEE);
|
||||
builder.AddSaplingOutput(ovkForShieldingFromTaddr(seed), migrationDestAddress, amountToSend - DEFAULT_FEE);
|
||||
CTransaction tx = builder.Build().GetTxOrThrow();
|
||||
if (isCancelled()) {
|
||||
LogPrint("zrpcunsafe", "%s: Canceled. Stopping.\n", getId());
|
||||
|
@ -156,7 +155,7 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
|
|||
pwalletMain->AddPendingSaplingMigrationTx(tx);
|
||||
LogPrint("zrpcunsafe", "%s: Added pending migration transaction with txid=%s\n", getId(), tx.GetHash().ToString());
|
||||
++numTxCreated;
|
||||
amountMigrated += amountToSend - FEE;
|
||||
amountMigrated += amountToSend - DEFAULT_FEE;
|
||||
migrationTxIds.push_back(tx.GetHash().ToString());
|
||||
} while (numTxCreated < 5 && availableFunds > CENT);
|
||||
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
|
||||
#include <rust/ed25519/types.h>
|
||||
|
||||
// Default transaction fee if caller does not specify one.
|
||||
#define ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE 10000
|
||||
|
||||
using namespace libzcash;
|
||||
class TxValues;
|
||||
|
||||
|
@ -74,7 +71,7 @@ public:
|
|||
std::vector<SendManyRecipient> tOutputs,
|
||||
std::vector<SendManyRecipient> zOutputs,
|
||||
int minDepth,
|
||||
CAmount fee = ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE,
|
||||
CAmount fee = DEFAULT_FEE,
|
||||
UniValue contextInfo = NullUniValue);
|
||||
virtual ~AsyncRPCOperation_sendmany();
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
|
||||
#include <rust/ed25519/types.h>
|
||||
|
||||
// Default transaction fee if caller does not specify one.
|
||||
#define SHIELD_COINBASE_DEFAULT_MINERS_FEE 10000
|
||||
|
||||
using namespace libzcash;
|
||||
|
||||
struct ShieldCoinbaseUTXO {
|
||||
|
@ -49,7 +46,7 @@ public:
|
|||
CMutableTransaction contextualTx,
|
||||
std::vector<ShieldCoinbaseUTXO> inputs,
|
||||
std::string toAddress,
|
||||
CAmount fee = SHIELD_COINBASE_DEFAULT_MINERS_FEE,
|
||||
CAmount fee = DEFAULT_FEE,
|
||||
UniValue contextInfo = NullUniValue);
|
||||
virtual ~AsyncRPCOperation_shieldcoinbase();
|
||||
|
||||
|
|
|
@ -1952,7 +1952,7 @@ TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) {
|
|||
auto scriptPubKey = GetScriptForDestination(tsk.GetPubKey().GetID());
|
||||
|
||||
// Generate shielding tx from transparent to Sapling
|
||||
// 0.0005 t-ZEC in, 0.0004 z-ZEC out, 0.0001 t-ZEC fee
|
||||
// 0.0005 t-ZEC in, 0.0004 z-ZEC out, default fee
|
||||
auto builder = TransactionBuilder(consensusParams, 1, &keystore);
|
||||
builder.AddTransparentInput(COutPoint(), scriptPubKey, 50000);
|
||||
builder.AddSaplingOutput(extfvk.fvk.ovk, pk, 40000, {});
|
||||
|
@ -2006,7 +2006,7 @@ TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) {
|
|||
auto witness = saplingTree.witness();
|
||||
|
||||
// Create a Sapling-only transaction
|
||||
// 0.0004 z-ZEC in, 0.00025 z-ZEC out, 0.0001 t-ZEC fee, 0.00005 z-ZEC change
|
||||
// 0.0004 z-ZEC in, 0.00025 z-ZEC out, default fee, 0.00005 z-ZEC change
|
||||
auto builder2 = TransactionBuilder(consensusParams, 2);
|
||||
builder2.AddSaplingSpend(expsk, note, anchor, witness);
|
||||
builder2.AddSaplingOutput(extfvk.fvk.ovk, pk, 25000, {});
|
||||
|
|
|
@ -4043,7 +4043,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
|||
" }, ... ]\n"
|
||||
"3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n"
|
||||
"4. fee (numeric, optional, default="
|
||||
+ strprintf("%s", FormatMoney(ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE)) + ") The fee amount to attach to this transaction.\n"
|
||||
+ strprintf("%s", FormatMoney(DEFAULT_FEE)) + ") The fee amount to attach to this transaction.\n"
|
||||
"\nResult:\n"
|
||||
"\"operationid\" (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n"
|
||||
"\nExamples:\n"
|
||||
|
@ -4254,7 +4254,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Fee in Zatoshis, not currency format)
|
||||
CAmount nFee = ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE;
|
||||
CAmount nFee = DEFAULT_FEE;
|
||||
CAmount nDefaultFee = nFee;
|
||||
|
||||
if (params.size() > 3) {
|
||||
|
@ -4479,7 +4479,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
|||
"1. \"fromaddress\" (string, required) The address is a taddr or \"*\" for all taddrs belonging to the wallet.\n"
|
||||
"2. \"toaddress\" (string, required) The address is a zaddr.\n"
|
||||
"3. fee (numeric, optional, default="
|
||||
+ strprintf("%s", FormatMoney(SHIELD_COINBASE_DEFAULT_MINERS_FEE)) + ") The fee amount to attach to this transaction.\n"
|
||||
+ strprintf("%s", FormatMoney(DEFAULT_FEE)) + ") The fee amount to attach to this transaction.\n"
|
||||
"4. limit (numeric, optional, default="
|
||||
+ strprintf("%d", SHIELD_COINBASE_DEFAULT_LIMIT) + ") Limit on the maximum number of utxos to shield. Set to 0 to use as many as will fit in the transaction.\n"
|
||||
"\nResult:\n"
|
||||
|
@ -4530,7 +4530,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Convert fee from currency format to zatoshis
|
||||
CAmount nFee = SHIELD_COINBASE_DEFAULT_MINERS_FEE;
|
||||
CAmount nFee = DEFAULT_FEE;
|
||||
if (params.size() > 2) {
|
||||
if (params[2].get_real() == 0.0) {
|
||||
nFee = 0;
|
||||
|
@ -4710,7 +4710,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
|||
" ]\n"
|
||||
"2. \"toaddress\" (string, required) The taddr or zaddr to send the funds to.\n"
|
||||
"3. fee (numeric, optional, default="
|
||||
+ strprintf("%s", FormatMoney(MERGE_TO_ADDRESS_OPERATION_DEFAULT_MINERS_FEE)) + ") The fee amount to attach to this transaction.\n"
|
||||
+ strprintf("%s", FormatMoney(DEFAULT_FEE)) + ") The fee amount to attach to this transaction.\n"
|
||||
"4. transparent_limit (numeric, optional, default="
|
||||
+ strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use as many as will fit in the transaction.\n"
|
||||
"5. shielded_limit (numeric, optional, default="
|
||||
|
@ -4831,7 +4831,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Convert fee from currency format to zatoshis
|
||||
CAmount nFee = SHIELD_COINBASE_DEFAULT_MINERS_FEE;
|
||||
CAmount nFee = DEFAULT_FEE;
|
||||
if (params.size() > 2) {
|
||||
if (params[2].get_real() == 0.0) {
|
||||
nFee = 0;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef BITCOIN_WALLET_RPCWALLET_H
|
||||
#define BITCOIN_WALLET_RPCWALLET_H
|
||||
|
||||
#include "policy/fees.h" // for DEFAULT_FEE
|
||||
|
||||
class CRPCTable;
|
||||
|
||||
void RegisterWalletRPCCommands(CRPCTable &tableRPC);
|
||||
|
|
|
@ -1086,7 +1086,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters)
|
|||
BOOST_CHECK_THROW(CallRPC("z_sendmany "
|
||||
"tmRr6yJonqGK23UVhrKuyvTpF8qxQQjKigJ "
|
||||
"[{\"address\":\"tmQP9L3s31cLsghVYf2Jb5MhKj1jRBPoeQn\", \"amount\":50.0}] "
|
||||
"1 -0.0001"
|
||||
"1 -0.00001"
|
||||
), runtime_error);
|
||||
|
||||
// invalid fee amount, bigger than MAX_MONEY
|
||||
|
@ -1683,7 +1683,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_shieldcoinbase_parameters)
|
|||
BOOST_CHECK_THROW(CallRPC("z_shieldcoinbase "
|
||||
"tmRr6yJonqGK23UVhrKuyvTpF8qxQQjKigJ "
|
||||
"tnpoQJVnYBZZqkFadj2bJJLThNCxbADGB5gSGeYTAGGrT5tejsxY9Zc1BtY8nnHmZkB "
|
||||
"-0.0001"
|
||||
"-0.00001"
|
||||
), runtime_error);
|
||||
|
||||
// invalid fee amount, bigger than MAX_MONEY
|
||||
|
@ -1839,7 +1839,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
|
|||
"Invalid parameter, duplicated address: " + taddr1);
|
||||
|
||||
// invalid fee amount, cannot be negative
|
||||
CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] " + taddr2 + " -0.0001",
|
||||
CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] " + taddr2 + " -0.00001",
|
||||
"Amount out of range");
|
||||
|
||||
// invalid fee amount, bigger than MAX_MONEY
|
||||
|
@ -1847,11 +1847,11 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
|
|||
"Amount out of range");
|
||||
|
||||
// invalid transparent limit, must be at least 0
|
||||
CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] " + taddr2 + " 0.0001 -1",
|
||||
CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] " + taddr2 + " 0.00001 -1",
|
||||
"Limit on maximum number of UTXOs cannot be negative");
|
||||
|
||||
// invalid shielded limit, must be at least 0
|
||||
CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] " + taddr2 + " 0.0001 100 -1",
|
||||
CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] " + taddr2 + " 0.00001 100 -1",
|
||||
"Limit on maximum number of notes cannot be negative");
|
||||
|
||||
CheckRPCThrows("z_mergetoaddress [\"ANY_TADDR\",\"" + taddr1 + "\"] " + taddr2,
|
||||
|
@ -1867,7 +1867,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
|
|||
std::vector<char> v (2 * (ZC_MEMO_SIZE+1)); // x2 for hexadecimal string format
|
||||
std::fill(v.begin(),v.end(), 'A');
|
||||
std::string badmemo(v.begin(), v.end());
|
||||
CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] " + aSproutAddr + " 0.0001 100 100 " + badmemo,
|
||||
CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] " + aSproutAddr + " 0.00001 100 100 " + badmemo,
|
||||
"Invalid parameter, size of memo is larger than maximum allowed 512");
|
||||
|
||||
// Mutable tx containing contextual information we need to build tx
|
||||
|
@ -1968,7 +1968,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals)
|
|||
operation->main();
|
||||
BOOST_CHECK(operation->isFailed());
|
||||
std::string msg = operation->getErrorMessage();
|
||||
BOOST_CHECK( msg.find("Insufficient funds, have 0.00 and miners fee is 0.0001") != string::npos);
|
||||
BOOST_CHECK( msg.find("Insufficient funds, have 0.00 and miners fee is 0.00001") != string::npos);
|
||||
}
|
||||
|
||||
// get_memo_from_hex_string())
|
||||
|
|
|
@ -3849,7 +3849,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||
|
||||
// If we made it here and we aren't even able to meet the relay fee on the next pass, give up
|
||||
// because we must be at the maximum allowed fee.
|
||||
if (nFeeNeeded < ::minRelayTxFee.GetFee(nBytes))
|
||||
if (nFeeNeeded < ::minRelayTxFee.GetFeeForRelay(nBytes))
|
||||
{
|
||||
strFailReason = _("Transaction too large for fee policy");
|
||||
return false;
|
||||
|
@ -3924,7 +3924,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, std::optional<std::reference_
|
|||
|
||||
CAmount CWallet::GetRequiredFee(unsigned int nTxBytes)
|
||||
{
|
||||
return std::max(minTxFee.GetFee(nTxBytes), ::minRelayTxFee.GetFee(nTxBytes));
|
||||
return std::max(minTxFee.GetFee(nTxBytes), ::minRelayTxFee.GetFeeForRelay(nTxBytes));
|
||||
}
|
||||
|
||||
CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
|
||||
|
@ -3942,8 +3942,8 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
|
|||
if (nFeeNeeded == 0)
|
||||
nFeeNeeded = GetRequiredFee(nTxBytes);
|
||||
// prevent user from paying a non-sense fee (like 1 satoshi): 0 < fee < minRelayFee
|
||||
if (nFeeNeeded < ::minRelayTxFee.GetFee(nTxBytes))
|
||||
nFeeNeeded = ::minRelayTxFee.GetFee(nTxBytes);
|
||||
if (nFeeNeeded < ::minRelayTxFee.GetFeeForRelay(nTxBytes))
|
||||
nFeeNeeded = ::minRelayTxFee.GetFeeForRelay(nTxBytes);
|
||||
// But always obey the maximum
|
||||
if (nFeeNeeded > maxTxFee)
|
||||
nFeeNeeded = maxTxFee;
|
||||
|
|
Loading…
Reference in New Issue