undercoin
Bitcoin utility belt
usage
npm install undercoin
In node or browser
const undercoin = require('undercoin')
api
For functions that accept a testnet parameter, said parameter needs be just true (otherwise the function will default to mainnet).
newAddress
undercoin.newAddress(testnet)
Creates a new Bitcoin address.
undercoin.newAddress()
Note that no private key is provided (you can never spend funds sent to this address).
newKeypair
undercoin.newKeypair(testnet)
Creates a new Bitcoin keypair; an object containing a private and public key
undercoin.newKeypair()
newWIF
undercoin.newWIF(testnet)
Creates a new WIF
undercoin.newWIF()
addressFromWIF
undercoin.addressFromWIF(wif, testnet)
Output a public Bitcoin address from a WIF
undercoin.addressFromWIF(wif)
getAddress
undercoin.getAddress(testnet, callback)
Get a (recent) address on the blockchain
undercoin.getAddress((err, address) => console.log(address))
isSegwit
undercoin.isSegwit(address)
Determines if address is Segwit (Bech32) or not.
undercoin.isSegwit('bc1qx9lplhcemust5q7vjejmfaglg8h6knu7a92r5p')
feeEstimate
Get an estimate on the fee required to complete a transaction within x hours
Conversion functions
The following conversion functions are directly from fmtbtc, see also that repo for more conversions beyond this selection below:
btc2sat
undercoin.btc2sat(btcAmount)
Converts BTC to satoshis
undercoin.btc2sat(1)
sat2btc
undercoin.sat2btc(satoshis)
Converts satoshis to BTC
undercoin.sat2btc(15000000)
btc2msat
undercoin.btc2msat(btcAmount)
Converts BTC to 1/1000th of a satoshi
undercoin.btc2msat(1)
msat2btc
undercoin.msat2btc(mSatoshis)
Converts mSatoshis to BTC.
undercoin.msat2btc(1)
msat2sat
undercoin.msat2sat(mSatoshis)
Converts mSatoshis to regular satoshis.
undercoin.msat2sat(1000)
sat2msat
undercoin.msat2sat(satoshis)
Converts satoshis to mSatoshis.
undercoin.sat2msat(1)
MIT