Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/policy/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee)

CAmount GetShieldedDustThreshold(const CFeeRate& dustRelayFee)
{
unsigned int K = DEFAULT_SHIELDEDTXFEE_K; // Fixed (1000) for now
unsigned int K = DEFAULT_SHIELDEDTXFEE_K; // Fixed (100) for now
return 3 * K * dustRelayFee.GetFee(SPENDDESCRIPTION_SIZE +
CTXOUT_REGULAR_SIZE +
BINDINGSIG_SIZE);
Expand Down
8 changes: 4 additions & 4 deletions src/test/librust/sapling_wallet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ BOOST_AUTO_TEST_CASE(SpentSaplingNoteIsFromMe) {
BOOST_CHECK_EQUAL(tx2.vin.size(), 0);
BOOST_CHECK_EQUAL(tx2.vout.size(), 0);
BOOST_CHECK_EQUAL(tx2.sapData->vShieldedSpend.size(), 1);
BOOST_CHECK_EQUAL(tx2.sapData->vShieldedOutput.size(), 1); // 0.025 dust change added to the fee
BOOST_CHECK_EQUAL(tx2.sapData->valueBalance, 12500000); // 0.025 dust change added to the fee
BOOST_CHECK_EQUAL(tx2.sapData->vShieldedOutput.size(), 2);
BOOST_CHECK_EQUAL(tx2.sapData->valueBalance, 10000000);

CWalletTx wtx2 {&wallet, tx2};

Expand Down Expand Up @@ -1115,8 +1115,8 @@ BOOST_AUTO_TEST_CASE(MarkAffectedSaplingTransactionsDirty) {
BOOST_CHECK_EQUAL(tx2.vin.size(), 0);
BOOST_CHECK_EQUAL(tx2.vout.size(), 0);
BOOST_CHECK_EQUAL(tx2.sapData->vShieldedSpend.size(), 1);
BOOST_CHECK_EQUAL(tx2.sapData->vShieldedOutput.size(), 1); // 0.05 dust change added to the fee
BOOST_CHECK_EQUAL(tx2.sapData->valueBalance, 15000000); // 0.05 dust change added to the fee
BOOST_CHECK_EQUAL(tx2.sapData->vShieldedOutput.size(), 2);
BOOST_CHECK_EQUAL(tx2.sapData->valueBalance, 10000000);

CWalletTx wtx2 {&wallet, tx2};

Expand Down
7 changes: 3 additions & 4 deletions src/test/librust/transaction_builder_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(SaplingToSapling) {
auto pa = sk.default_address();

// Create a Sapling-only transaction
// --- 0.4 shielded-PIV in, 0.25 shielded-PIV out, 0.1 shielded-PIV fee, 0.05 shielded-PIV change (added to fee)
// --- 0.4 shielded-PIV in, 0.299 shielded-PIV out, 0.1 shielded-PIV fee, 0.001 shielded-PIV change (added to fee)
auto testNote = GetTestSaplingNote(pa, 40000000);
auto builder = TransactionBuilder(consensusParams, 2);
builder.AddSaplingSpend(expsk, testNote.note, testNote.tree.root(), testNote.tree.witness());
Expand All @@ -73,16 +73,15 @@ BOOST_AUTO_TEST_CASE(SaplingToSapling) {
// TODO: the following check can be split out in to another test
BOOST_CHECK_THROW(builder.AddSaplingSpend(expsk, testNote.note, uint256(), testNote.tree.witness()), std::runtime_error);

builder.AddSaplingOutput(fvk.ovk, pa, 25000000, {});
builder.AddSaplingOutput(fvk.ovk, pa, 29900000, {});
auto tx = builder.Build().GetTxOrThrow();

BOOST_CHECK_EQUAL(tx.vin.size(), 0);
BOOST_CHECK_EQUAL(tx.vout.size(), 0);
BOOST_CHECK_EQUAL(tx.sapData->vShieldedSpend.size(), 1);

// since the change is below the dust threshold, it is added to the fee
BOOST_CHECK_EQUAL(tx.sapData->vShieldedOutput.size(), 1);
BOOST_CHECK_EQUAL(tx.sapData->valueBalance, 15000000);
BOOST_CHECK_EQUAL(tx.sapData->valueBalance, 10100000);

CValidationState state;
BOOST_CHECK(SaplingValidation::ContextualCheckTransaction(tx, state, Params(), 3, true, false));
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ CAmount GetMinRelayFee(unsigned int nBytes, bool fAllowFree)
CAmount GetShieldedTxMinFee(const CTransaction& tx)
{
assert (tx.IsShieldedTx());
unsigned int K = DEFAULT_SHIELDEDTXFEE_K; // Fixed (1000) for now
unsigned int K = DEFAULT_SHIELDEDTXFEE_K; // Fixed (100) for now
CAmount nMinFee = ::minRelayTxFee.GetFee(tx.GetTotalSize()) * K;
if (!Params().GetConsensus().MoneyRange(nMinFee))
nMinFee = Params().GetConsensus().nMaxMoneyOut;
Expand Down
2 changes: 1 addition & 1 deletion src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL = 30;
* Blocks, whitelisted receivers, and a random 25% of transactions bypass this. */
static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
/** Default multiplier used in the computation for shielded txes min fee */
static const unsigned int DEFAULT_SHIELDEDTXFEE_K = 1000;
static const unsigned int DEFAULT_SHIELDEDTXFEE_K = 100;

/** Enable bloom filter */
static const bool DEFAULT_PEERBLOOMFILTERS = true;
Expand Down
4 changes: 2 additions & 2 deletions test/functional/sapling_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run_test(self):
alice = self.nodes[1]

# Fixed fee
fee = 1
fee = 0.05

self.log.info("Mining 120 blocks...")
miner.generate(120)
Expand All @@ -49,7 +49,7 @@ def run_test(self):
# Alice creates and sends tx_B, unshielding the same note to tadd_B
self.log.info("Alice creating and sending tx_B...")
tadd_B = alice.getnewaddress()
txid_B = alice.shieldsendmany(alice_zaddr, [{"address": tadd_B, "amount": Decimal('9.00')}], 1, fee)
txid_B = alice.shieldsendmany(alice_zaddr, [{"address": tadd_B, "amount": Decimal('9.95')}], 1, fee)

# Miner receives tx_B and accepts it in the mempool
assert (txid_B in alice.getrawmempool())
Expand Down
4 changes: 2 additions & 2 deletions test/functional/sapling_supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def generate_and_sync(self, count):

def check_shield_supply(self, z_supply):
self.log.info("Checking supply...")
assert_equal(self.nodes[0].getsupplyinfo()['shieldsupply'], z_supply)
assert_equal(self.nodes[0].getsupplyinfo()['shieldsupply'], Decimal("%.8f" % z_supply))
self.log.info("OK. Shield supply is %.8f" % z_supply)

def run_test(self):
fee = 1
fee = 0.05
# First mine 101 blocks to mature one utxo
self.log.info("Generating 101 blocks...")
self.generate_and_sync(101)
Expand Down
34 changes: 17 additions & 17 deletions test/functional/sapling_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def run_test(self):
self.log.info("Good. Not accepted in the mempool.")

# Fixed fee
fee = 1
fee = 0.05

# Node 0 shields some funds
# taddr -> Sapling
Expand Down Expand Up @@ -209,11 +209,11 @@ def run_test(self):
self.sync_all()

# Verify balance
assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('3')) # 30 received - (20 sent + 3 fee) - 4 sent
assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('20')) # 20 received
assert_equal(self.nodes[0].getshieldbalance(saplingAddr2), Decimal('2')) # 10 received - 10 sent + 2 change
assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('4.9')) # 30 received - (20 sent + 0.15 fee) - 4.95 sent
assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('20')) # 20 received
assert_equal(self.nodes[0].getshieldbalance(saplingAddr2), Decimal('3.9')) # 10 received - 10 sent + 3.9 change
assert_equal(self.nodes[1].getreceivedbyaddress(taddr1), Decimal('0'))
assert_equal(self.nodes[0].getshieldbalance(), Decimal('5'))
assert_equal(self.nodes[0].getshieldbalance(), Decimal('8.8'))
self.log.info("Balances check out")

# Node 1 sends some shield funds to node 0, as well as unshielding
Expand All @@ -230,14 +230,14 @@ def run_test(self):
self.sync_all()

# Verify balance
assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('11')) # 3 prev balance + 8 received
assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('1')) # 20 prev balance - (18 sent + 1 fee)
assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('12.9')) # 4.9 prev balance + 8 received
assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('1.95')) # 20 prev balance - (18 sent + 0.05 fee)
assert_equal(self.nodes[1].getreceivedbyaddress(taddr1), Decimal('10'))
self.log.info("Balances check out")

# Verify existence of Sapling related JSON fields
resp = self.nodes[0].getrawtransaction(mytxid7, 1)
assert_equal(Decimal(resp['valueBalance']), Decimal('11.00')) # 20 shield input - 8 shield spend - 1 change
assert_equal(Decimal(resp['valueBalance']), Decimal('10.05')) # 20 shield input - 8 shield spend - 1.95 change
assert_equal(len(resp['vShieldSpend']), 3)
assert_equal(len(resp['vShieldOutput']), 2)
assert('bindingSig' in resp)
Expand All @@ -262,26 +262,26 @@ def run_test(self):
sk0 = self.nodes[0].exportsaplingkey(saplingAddr0)
saplingAddrInfo0 = self.nodes[2].importsaplingkey(sk0, "yes")
assert_equal(saplingAddrInfo0["address"], saplingAddr0)
assert_equal(self.nodes[2].getshieldbalance(saplingAddrInfo0["address"]), Decimal('11'))
assert_equal(self.nodes[2].getshieldbalance(saplingAddrInfo0["address"]), Decimal('12.9'))
sk1 = self.nodes[1].exportsaplingkey(saplingAddr1)
saplingAddrInfo1 = self.nodes[2].importsaplingkey(sk1, "yes")
assert_equal(saplingAddrInfo1["address"], saplingAddr1)
assert_equal(self.nodes[2].getshieldbalance(saplingAddrInfo1["address"]), Decimal('1'))
assert_equal(self.nodes[2].getshieldbalance(saplingAddrInfo1["address"]), Decimal('1.95'))

# Verify importing a viewing key will update the nullifiers and witnesses correctly
self.log.info("Checking exporting/importing a viewing key...")
extfvk0 = self.nodes[0].exportsaplingviewingkey(saplingAddr0)
saplingAddrInfo0 = self.nodes[3].importsaplingviewingkey(extfvk0, "yes")
assert_equal(saplingAddrInfo0["address"], saplingAddr0)
assert_equal(Decimal(self.nodes[3].getshieldbalance(saplingAddrInfo0["address"], 1, True)), Decimal('11'))
assert_equal(Decimal(self.nodes[3].getshieldbalance(saplingAddrInfo0["address"], 1, True)), Decimal('12.9'))
extfvk1 = self.nodes[1].exportsaplingviewingkey(saplingAddr1)
saplingAddrInfo1 = self.nodes[3].importsaplingviewingkey(extfvk1, "yes")
assert_equal(saplingAddrInfo1["address"], saplingAddr1)
assert_equal(self.nodes[3].getshieldbalance(saplingAddrInfo1["address"], 1, True), Decimal('1'))
assert_equal(self.nodes[3].getshieldbalance(saplingAddrInfo1["address"], 1, True), Decimal('1.95'))
# no balance in the wallet
assert_equal(self.nodes[3].getshieldbalance(), Decimal('0'))
# watch only balance
assert_equal(self.nodes[3].getshieldbalance("*", 1, True), Decimal('12.00'))
assert_equal(self.nodes[3].getshieldbalance("*", 1, True), Decimal('14.85'))

# Now shield some funds using sendmany
self.log.info("TX11: Shielding coins to multiple destinations with sendmany RPC...")
Expand Down Expand Up @@ -318,9 +318,9 @@ def run_test(self):
# Verify balance
self.nodes[2].generate(1)
self.sync_all()
assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('19')) # 11 prev balance + 8 received
assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('2')) # 1 prev balance + 1 received
assert_equal(self.nodes[0].getshieldbalance(saplingAddr2), Decimal('2.5')) # 2 prev balance + 0.5 received
assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('20.9')) # 12.9 prev balance + 8 received
assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('2.95')) # 1.95 prev balance + 1 received
assert_equal(self.nodes[0].getshieldbalance(saplingAddr2), Decimal('4.4')) # 3.9 prev balance + 0.5 received
# Balance of node 0 is: prev_balance - 1 PIV (+fee) sent externally + 250 PIV matured coinbase
assert_equal(self.nodes[0].getbalance(), satoshi_round(prev_balance + Decimal('249') - Decimal(fee)))

Expand All @@ -345,7 +345,7 @@ def run_test(self):
# Verify balance
self.nodes[2].generate(1)
self.sync_all()
assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('29')) # 19 prev balance + 10 received
assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('30.9')) # 20.9 prev balance + 10 received

self.log.info("All good.")

Expand Down
12 changes: 6 additions & 6 deletions test/functional/sapling_wallet_listreceived.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def run_test(self):
self.nodes[1].shieldsendmany, taddr,
[{'address': shield_addr1, 'amount': 2, 'memo': too_big_memo_str}])
# Fixed fee
fee = 0.5
fee = 0.05

# Send 1 PIV to shield addr1
txid = self.nodes[1].shieldsendmany(taddr, [ # node_1 with 6 PIV sending them all (fee is 0.1 PIV)
Expand Down Expand Up @@ -128,9 +128,9 @@ def run_test(self):
# Generate some change by sending part of shield_addr1 to shield_addr2
txidPrev = txid
shield_addr2 = self.nodes[1].getnewshieldaddress()
txid = self.nodes[1].shieldsendmany(shield_addr1, # shield_addr1 has 2 PIV, send 0.6 PIV + 0.5 PIV fee
txid = self.nodes[1].shieldsendmany(shield_addr1, # shield_addr1 has 2 PIV, send 0.6 PIV + 0.05 PIV fee
[{'address': shield_addr2, 'amount': 0.6, "memo": non_ascii_memo_str}],
1, fee) # change 0.9
1, fee) # change 1.35
self.sync_all()
self.generate_and_sync(height+4)

Expand Down Expand Up @@ -165,8 +165,8 @@ def run_test(self):
assert_equal(out['address'], shield_addr1)
assert_equal(out['outgoing'], False)
assert_equal(out['memo'], no_memo)
assert_equal(out['value'], Decimal('0.9'))
assert_equal(out['valueSat'], 90000000)
assert_equal(out['value'], Decimal('1.35'))
assert_equal(out['valueSat'], 135000000)
found[1] = True
assert_equal(found, [True] * 2)

Expand All @@ -176,7 +176,7 @@ def run_test(self):
assert_true(2 == len(r), "shield_addr1 Should have received 2 notes")

assert_equal(txid, r[0]['txid'])
assert_equal(Decimal('0.9'), r[0]['amount'])
assert_equal(Decimal('1.35'), r[0]['amount'])
assert_true(r[0]['change'], "Note valued at (1.4-fee) should be change")
assert_equal(no_memo, r[0]['memo'])

Expand Down