bitcoin-util-fee
v0.0.6
Published
utility of bitcoin transaction size calculate
Downloads
40
Readme
node-bitcoin-fee-util
install
npm i bitcoin-util-fee
simple transaction-fee calculate usage
please install bitcoinfees-21co
npm i bitcoinfees-21co
P2PKH
'use strict'
const bitcoinfees = require('bitcoinfees-21co');
const feeutil = require('bitcoin-util-fee');
const getCurrentFees = () =>
bitcoinfees.FeesApi.recommended().then(res => res.fastestFee)
const process = () => {
const number_of_input = 1;
const number_of_output = 2;
const satoshi = feeutil.p2pkh_tx_calc_fee(number_of_input, number_of_output)
console.log("P2PKH fee %d satoshi", satoshi)
}
getCurrentFees().then(fee => {
feeutil.BASE_SATOSHI_PER_BYTE = fee; // initialize satoshi/byte rate
process()
})
P2SH n-of-m multisig
'use strict'
const bitcoinfees = require('bitcoinfees-21co');
const feeutil = require('bitcoin-fee-util');
const getCurrentFees = () =>
bitcoinfees.FeesApi.recommended().then(res => res.fastestFee)
const process = () => {
const number_of_input = 1;
const number_of_output = 2;
const p2sh_tx_calc_fee_2of3 = feeutil.p2sh_tx_calc_fee_create(2, 3);
const satoshi = p2sh_tx_calc_fee_2of3(number_of_input, number_of_output)
console.log("2of3 multisig fee %s satoshi", satoshi)
}
getCurrentFees().then(fee => {
feeutil.BASE_SATOSHI_PER_BYTE = fee; // initialize satoshi/byte rate
process()
})
LICENSE
MIT LICENSE