Fix liquid fees & remove minimum fee rate
This commit is contained in:
parent
61e28a33e0
commit
709783280a
@ -171,7 +171,9 @@ class Blocks {
|
|||||||
|
|
||||||
private convertLiquidFees(block: IBitcoinApi.VerboseBlock): IBitcoinApi.VerboseBlock {
|
private convertLiquidFees(block: IBitcoinApi.VerboseBlock): IBitcoinApi.VerboseBlock {
|
||||||
block.tx.forEach(tx => {
|
block.tx.forEach(tx => {
|
||||||
|
if (!isFinite(Number(tx.fee))) {
|
||||||
tx.fee = Object.values(tx.fee || {}).reduce((total, output) => total + output, 0);
|
tx.fee = Object.values(tx.fee || {}).reduce((total, output) => total + output, 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
@ -877,7 +879,7 @@ class Blocks {
|
|||||||
|
|
||||||
let height = blockHeight;
|
let height = blockHeight;
|
||||||
let summary: BlockSummary;
|
let summary: BlockSummary;
|
||||||
if (cpfpSummary) {
|
if (cpfpSummary && !Common.isLiquid()) {
|
||||||
summary = {
|
summary = {
|
||||||
id: hash,
|
id: hash,
|
||||||
transactions: cpfpSummary.transactions.map(tx => {
|
transactions: cpfpSummary.transactions.map(tx => {
|
||||||
|
@ -35,6 +35,13 @@ class TransactionUtils {
|
|||||||
} else {
|
} else {
|
||||||
transaction = await bitcoinApi.$getRawTransaction(txId, false, addPrevouts, lazyPrevouts);
|
transaction = await bitcoinApi.$getRawTransaction(txId, false, addPrevouts, lazyPrevouts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Common.isLiquid()) {
|
||||||
|
if (!isFinite(Number(transaction.fee))) {
|
||||||
|
transaction.fee = Object.values(transaction.fee || {}).reduce((total, output) => total + output, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (addMempoolData || !transaction?.status?.confirmed) {
|
if (addMempoolData || !transaction?.status?.confirmed) {
|
||||||
return this.extendMempoolTransaction(transaction);
|
return this.extendMempoolTransaction(transaction);
|
||||||
} else {
|
} else {
|
||||||
@ -52,8 +59,7 @@ class TransactionUtils {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
const feePerVbytes = Math.max(Common.isLiquid() ? 0.1 : 1,
|
const feePerVbytes = (transaction.fee || 0) / (transaction.weight / 4);
|
||||||
(transaction.fee || 0) / (transaction.weight / 4));
|
|
||||||
const transactionExtended: TransactionExtended = Object.assign({
|
const transactionExtended: TransactionExtended = Object.assign({
|
||||||
vsize: Math.round(transaction.weight / 4),
|
vsize: Math.round(transaction.weight / 4),
|
||||||
feePerVsize: feePerVbytes,
|
feePerVsize: feePerVbytes,
|
||||||
@ -68,13 +74,11 @@ class TransactionUtils {
|
|||||||
public extendMempoolTransaction(transaction: IEsploraApi.Transaction): MempoolTransactionExtended {
|
public extendMempoolTransaction(transaction: IEsploraApi.Transaction): MempoolTransactionExtended {
|
||||||
const vsize = Math.ceil(transaction.weight / 4);
|
const vsize = Math.ceil(transaction.weight / 4);
|
||||||
const fractionalVsize = (transaction.weight / 4);
|
const fractionalVsize = (transaction.weight / 4);
|
||||||
const sigops = this.countSigops(transaction);
|
const sigops = Common.isLiquid() ? this.countSigops(transaction) : 0;
|
||||||
// https://github.com/bitcoin/bitcoin/blob/e9262ea32a6e1d364fb7974844fadc36f931f8c6/src/policy/policy.cpp#L295-L298
|
// https://github.com/bitcoin/bitcoin/blob/e9262ea32a6e1d364fb7974844fadc36f931f8c6/src/policy/policy.cpp#L295-L298
|
||||||
const adjustedVsize = Math.max(fractionalVsize, sigops * 5); // adjusted vsize = Max(weight, sigops * bytes_per_sigop) / witness_scale_factor
|
const adjustedVsize = Math.max(fractionalVsize, sigops * 5); // adjusted vsize = Max(weight, sigops * bytes_per_sigop) / witness_scale_factor
|
||||||
const feePerVbytes = Math.max(Common.isLiquid() ? 0.1 : 1,
|
const feePerVbytes = (transaction.fee || 0) / fractionalVsize;
|
||||||
(transaction.fee || 0) / fractionalVsize);
|
const adjustedFeePerVsize = (transaction.fee || 0) / adjustedVsize;
|
||||||
const adjustedFeePerVsize = Math.max(Common.isLiquid() ? 0.1 : 1,
|
|
||||||
(transaction.fee || 0) / adjustedVsize);
|
|
||||||
const transactionExtended: MempoolTransactionExtended = Object.assign(transaction, {
|
const transactionExtended: MempoolTransactionExtended = Object.assign(transaction, {
|
||||||
order: this.txidToOrdering(transaction.txid),
|
order: this.txidToOrdering(transaction.txid),
|
||||||
vsize: Math.round(transaction.weight / 4),
|
vsize: Math.round(transaction.weight / 4),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user