Socket
Socket
Sign inDemoInstall

bitcoin-util-fee

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bitcoin-util-fee

utility of bitcoin transaction size calculate


Version published
Weekly downloads
6
increased by200%
Maintainers
1
Install size
10.8 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 25 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc