Reduce the default fee for z_* operations, and the "low fee penalty" threshold for mempool limiting, to 1000 zatoshis.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2020-12-17 19:39:58 +00:00 committed by Kris Nuttycombe
parent 844ef48b45
commit 5e84362702
38 changed files with 212 additions and 197 deletions

View File

@ -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.

View File

@ -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()

View File

@ -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))

View File

@ -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()

View File

@ -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'))

View File

@ -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')

View File

@ -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):
@ -79,7 +80,7 @@ class RemoveSproutShieldingTest (BitcoinTestFramework):
except JSONRPCException as e:
errorString = e.error['message']
assert("Sprout shielding is not supported after Canopy" in errorString)
print("taddr -> Sprout z_shieldcoinbase tx rejected at Canopy activation on node 0")
print("taddr -> Sprout z_shieldcoinbase tx rejected at Canopy activation on node 0")
# Create taddr -> Sprout z_sendmany transaction on node 0. Should fail
errorString = ''
@ -94,7 +95,7 @@ class RemoveSproutShieldingTest (BitcoinTestFramework):
# Create z_mergetoaddress [taddr, Sprout] -> Sprout transaction on node 0. Should fail
errorString = ''
try:
self.nodes[0].z_mergetoaddress(["ANY_TADDR", "ANY_SPROUT"], self.nodes[1].z_getnewaddress('sprout'))
self.nodes[0].z_mergetoaddress(["ANY_TADDR", "ANY_SPROUT"], self.nodes[1].z_getnewaddress('sprout'))
except JSONRPCException as e:
errorString = e.error['message']
assert("Sprout shielding is not supported after Canopy" in errorString)

View File

@ -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.
@ -54,4 +57,4 @@ class SignOfflineTest (BitcoinTestFramework):
assert_true(len(online_tx_hash) > 0)
if __name__ == '__main__':
SignOfflineTest().main()
SignOfflineTest().main()

View File

@ -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'

View File

@ -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

View File

@ -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})

View File

@ -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__':

View File

@ -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)

View File

@ -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,19 +31,19 @@ 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)
self.sync_all()
# No funds (with (default) one or more confirmations) in sproutzaddr yet
assert_equal(0, len(self.nodes[0].z_listunspent()))
assert_equal(0, len(self.nodes[0].z_listunspent(1)))
# no private balance because no confirmations yet
assert_equal(0, Decimal(self.nodes[0].z_gettotalbalance()['private']))
# list private unspent, this time allowing 0 confirmations
unspent_cb = self.nodes[0].z_listunspent(0)
assert_equal(1, len(unspent_cb))
@ -55,7 +56,7 @@ class WalletListNotes(BitcoinTestFramework):
# list unspent, filtering by address, should produce same result
unspent_cb_filter = self.nodes[0].z_listunspent(0, 9999, False, [sproutzaddr])
assert_equal(unspent_cb, unspent_cb_filter)
# Generate a block to confirm shield coinbase tx
self.nodes[0].generate(1)
self.sync_all()
@ -63,16 +64,16 @@ 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}]
myopid = self.nodes[0].z_sendmany(sproutzaddr, recipients)
txid_2 = wait_and_assert_operationid_status(self.nodes[0], myopid)
self.sync_all()
# list unspent, allowing 0conf txs
unspent_tx = self.nodes[0].z_listunspent(0)
assert_equal(len(unspent_tx), 2)
@ -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)

View File

@ -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

View File

@ -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,8 +24,8 @@ 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)
self.sync_all()
@ -52,7 +52,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
# send node 0 zaddr to note 2 zaddr
recipients = []
recipients.append({"address":myzaddr, "amount":7.0})
wait_and_assert_operationid_status(self.nodes[0], self.nodes[0].z_sendmany(myzaddr0, recipients), timeout=120)
self.sync_all()
@ -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)
@ -92,7 +92,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
mytaddr1 = self.nodes[1].getnewaddress()
recipients = []
recipients.append({"address":mytaddr1, "amount":1.0})
wait_and_assert_operationid_status(self.nodes[1], self.nodes[1].z_sendmany(myzaddr, recipients), timeout=120)
self.sync_all()

View File

@ -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+)

View File

@ -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:

View File

@ -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'])

View File

@ -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
@ -90,16 +90,16 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
# as it's currently not possible to specify a change address in z_sendmany.
recipients = []
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)

View File

@ -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...

View File

@ -45,7 +45,7 @@ class JoinSplitTest(BitcoinTestFramework):
for i in range(4):
assert_equal(self.nodes[i].getbalance(), starting_balance)
self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress!
# Generate zcaddress keypairs
zckeypair = self.nodes[0].zcrawkeygen()
zcsecretkey = zckeypair["zcsecretkey"]

View File

@ -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):

View File

@ -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/'

View File

@ -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>
@ -122,12 +122,12 @@ TEST(MempoolLimitTests, WeightedTxInfoFromTx)
auto builder = TransactionBuilder(consensusParams, 1);
builder.AddSaplingSpend(sk.expanded_spending_key(), testNote.note, testNote.tree.root(), testNote.tree.witness());
builder.AddSaplingOutput(sk.full_viewing_key().ovk, sk.default_address(), 25000, {});
WeightedTxInfo info = WeightedTxInfo::from(builder.Build().GetTxOrThrow(), 10000);
EXPECT_EQ(MIN_TX_COST, info.txWeight.cost);
EXPECT_EQ(MIN_TX_COST, info.txWeight.evictionWeight);
}
// Lower than standard fee
{
auto builder = TransactionBuilder(consensusParams, 1);
@ -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);
}
@ -148,7 +149,7 @@ TEST(MempoolLimitTests, WeightedTxInfoFromTx)
builder.AddSaplingOutput(sk.full_viewing_key().ovk, sk.default_address(), 5000, {});
builder.AddSaplingOutput(sk.full_viewing_key().ovk, sk.default_address(), 5000, {});
builder.AddSaplingOutput(sk.full_viewing_key().ovk, sk.default_address(), 5000, {});
auto result = builder.Build();
if (result.IsError()) {
std::cerr << result.GetError() << std::endl;
@ -157,6 +158,6 @@ TEST(MempoolLimitTests, WeightedTxInfoFromTx)
EXPECT_EQ(5168, info.txWeight.cost);
EXPECT_EQ(5168, info.txWeight.evictionWeight);
}
RegtestDeactivateSapling();
}

View File

@ -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, {});
@ -121,9 +121,9 @@ TEST(TransactionBuilder, SaplingToSapling) {
auto pa = sk.default_address();
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);
@ -199,7 +199,7 @@ TEST(TransactionBuilder, SproutToSproutAndSapling) {
auto wtx = GetValidSproutReceive(sproutSk, 25000, true);
auto sproutNote = GetSproutNote(sproutSk, wtx, 0, 1);
SproutMerkleTree sproutTree;
for (int i = 0; i < ZC_NUM_JS_OUTPUTS; i++) {
sproutTree.append(wtx.vJoinSplit[0].commitments[i]);
@ -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());

View File

@ -1603,8 +1603,8 @@ 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) {
// Accept a tx if it contains joinsplits and has at least the default fee for z_* operations.
if (tx.vJoinSplit.size() > 0 && nFees >= DEFAULT_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

View File

@ -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()

View File

@ -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;
@ -22,7 +23,7 @@ const uint64_t LOW_FEE_PENALTY = 16000;
// This class keeps track of transactions which have been recently evicted from the mempool
// in order to prevent them from being re-accepted for a given amount of time.
// in order to prevent them from being re-accepted for a given amount of time.
class RecentlyEvictedList
{
const size_t capacity;
@ -37,7 +38,7 @@ class RecentlyEvictedList
void pruneList();
public:
RecentlyEvictedList(size_t capacity_, int64_t timeToKeep_) : capacity(capacity_), timeToKeep(timeToKeep_)
RecentlyEvictedList(size_t capacity_, int64_t timeToKeep_) : capacity(capacity_), timeToKeep(timeToKeep_)
{
assert(capacity <= EVICTION_MEMORY_ENTRIES);
}
@ -88,7 +89,7 @@ class WeightedTxTree
{
const int64_t capacity;
size_t size = 0;
// The following two vectors are the tree representation of this collection.
// We keep track of 3 data points for each node: A transaction's txid, its cost,
// and the sum of the weights of all children and descendant of that node.

View File

@ -12,6 +12,8 @@
#include <string>
#include <vector>
static const CAmount DEFAULT_FEE = 1000;
class CAutoFile;
class CFeeRate;
class CTxMemPoolEntry;

View File

@ -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();
@ -87,7 +84,7 @@ private:
friend class TEST_FRIEND_AsyncRPCOperation_mergetoaddress; // class for unit testing
UniValue contextinfo_; // optional data to include in return value from getStatus()
bool isUsingBuilder_; // Indicates that no Sprout addresses are involved
uint32_t consensusBranchId_;
CAmount fee_;

View File

@ -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);

View File

@ -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,16 +71,16 @@ 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();
// We don't want to be copied or moved around
AsyncRPCOperation_sendmany(AsyncRPCOperation_sendmany const&) = delete; // Copy construct
AsyncRPCOperation_sendmany(AsyncRPCOperation_sendmany&&) = delete; // Move construct
AsyncRPCOperation_sendmany& operator=(AsyncRPCOperation_sendmany const&) = delete; // Copy assign
AsyncRPCOperation_sendmany& operator=(AsyncRPCOperation_sendmany &&) = delete; // Move assign
virtual void main();
virtual UniValue getStatus() const;
@ -154,35 +151,35 @@ private:
class TEST_FRIEND_AsyncRPCOperation_sendmany {
public:
std::shared_ptr<AsyncRPCOperation_sendmany> delegate;
TEST_FRIEND_AsyncRPCOperation_sendmany(std::shared_ptr<AsyncRPCOperation_sendmany> ptr) : delegate(ptr) {}
CTransaction getTx() {
return delegate->tx_;
}
void setTx(CTransaction tx) {
delegate->tx_ = tx;
}
// Delegated methods
void add_taddr_change_output_to_tx(CReserveKey& keyChange, CAmount amount) {
delegate->add_taddr_change_output_to_tx(keyChange, amount);
}
void add_taddr_outputs_to_tx() {
delegate->add_taddr_outputs_to_tx();
}
bool find_unspent_notes() {
return delegate->find_unspent_notes();
}
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s) {
return delegate->get_memo_from_hex_string(s);
}
bool main_impl() {
return delegate->main_impl();
}

View File

@ -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();

View File

@ -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, {});

View File

@ -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;

View File

@ -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);

View File

@ -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())