Utility functions for handling transaction fees in Satoshi Showdown. Includes functionality for fetching current network fee rates and estimating transaction fees based on transaction details.
- Source:
Requires
- module:utils/apiUtil
- module:bitcoinjs-lib
Methods
(inner) adjustAmountForFee(amount, fee) → {number}
Adjusts the transaction amount to account for the transaction fee. This function ensures that the fee is deducted from the total amount, avoiding leaving dust in the wallet.
Parameters:
Name | Type | Description |
---|---|---|
amount |
number | Original transaction amount in satoshis. |
fee |
number | Transaction fee in satoshis. |
- Source:
Returns:
Adjusted amount after deducting the fee.
- Type
- number
(inner) estimateTransactionFee(numInputs, numOutputs, feeRate) → {number}
Estimates the transaction fee in satoshis based on the number of inputs, outputs, and the fee rate. Uses the formula for virtual size (vSize) to calculate the fee more accurately for SegWit transactions.
Parameters:
Name | Type | Description |
---|---|---|
numInputs |
number | Number of transaction inputs. |
numOutputs |
number | Number of transaction outputs. |
feeRate |
number | Fee rate in satoshis per byte. |
- Source:
Returns:
Estimated transaction fee in satoshis.
- Type
- number
(async, inner) getCurrentFeeRates() → {Promise.<{highFeePerByte: number, mediumFeePerByte: number, lowFeePerByte: number}>}
Fetches the current Bitcoin network fee rates (high, medium, low) from BlockCypher.
- Source:
Throws:
-
If the request to the BlockCypher API fails.
- Type
- Error
Returns:
An object containing high, medium, and low fee rates in satoshis per byte.
- Type
- Promise.<{highFeePerByte: number, mediumFeePerByte: number, lowFeePerByte: number}>