Skip to content

you21979/node-bitcoin-util-fee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-bitcoin-fee-util

NPM
Build Status Coverage Status

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published