mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge pull request #1356 from delta1/discountct-blockmintxfee
fix: use discountvsize in miner if discount enabled
This commit is contained in:
commit
639715df61
2 changed files with 40 additions and 2 deletions
|
|
@ -441,15 +441,23 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
|||
uint64_t packageSize = iter->GetSizeWithAncestors();
|
||||
CAmount packageFees = iter->GetModFeesWithAncestors();
|
||||
int64_t packageSigOpsCost = iter->GetSigOpCostWithAncestors();
|
||||
uint64_t discountSize = iter->GetDiscountSizeWithAncestors();
|
||||
if (fUsingModified) {
|
||||
packageSize = modit->nSizeWithAncestors;
|
||||
packageFees = modit->nModFeesWithAncestors;
|
||||
packageSigOpsCost = modit->nSigOpCostWithAncestors;
|
||||
discountSize = modit->discountSizeWithAncestors;
|
||||
}
|
||||
|
||||
if (packageFees < blockMinFeeRate.GetFee(packageSize)) {
|
||||
// Everything else we might consider has a lower fee rate
|
||||
return;
|
||||
if (Params().GetAcceptDiscountCT()) {
|
||||
if (packageFees < blockMinFeeRate.GetFee(discountSize)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Everything else we might consider has a lower fee rate
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!TestPackage(packageSize, packageSigOpsCost)) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ class CTTest(BitcoinTestFramework):
|
|||
"-con_connect_genesis_outputs=1",
|
||||
"-initialfreecoins=2100000000000000",
|
||||
"-txindex=1",
|
||||
"-minrelaytxfee=0.00000100",
|
||||
"-blockmintxfee=0.00000100",
|
||||
"-fallbackfee=0.00000100",
|
||||
]
|
||||
self.extra_args = [
|
||||
# node 0 does not accept nor create discounted CTs
|
||||
|
|
@ -154,6 +157,33 @@ class CTTest(BitcoinTestFramework):
|
|||
tx = node0.getrawtransaction(txid, True)
|
||||
assert_equal(tx['vsize'], 2575)
|
||||
|
||||
# check liquidv1 min feerate
|
||||
feerate = 0.1
|
||||
self.log.info(f"Send confidential (discounted) tx to node 1 at {feerate} sats/vb")
|
||||
addr = node1.getnewaddress()
|
||||
info = node1.getaddressinfo(addr)
|
||||
txid = node2.sendtoaddress(info['confidential'], 1.0, "", "", False, None, None, None, None, None, None, feerate)
|
||||
self.sync_mempools([node1, node2])
|
||||
assert_equal(node0.getrawmempool(), [])
|
||||
self.generate(node2, 1, sync_fun=self.sync_blocks)
|
||||
for node in [node2, node1]:
|
||||
tx = node.gettransaction(txid, True, True)
|
||||
assert_equal(tx["confirmations"], 1)
|
||||
decoded = tx['decoded']
|
||||
vin = decoded['vin']
|
||||
vout = decoded['vout']
|
||||
assert_equal(len(vin), 2)
|
||||
assert_equal(len(vout), 3)
|
||||
if 'bitcoin' in decoded['fee']:
|
||||
assert_equal(decoded['fee']['bitcoin'], Decimal('-0.00000041'))
|
||||
else:
|
||||
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000041'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['discountvsize'], 410)
|
||||
# node0 only has vsize
|
||||
tx = node0.getrawtransaction(txid, True)
|
||||
assert_equal(tx['vsize'], 2575)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
CTTest().main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue