@cobo/btc

0.2.1 • Public • Published

BTC Wallet with altcoins support

Example

const wallet = require('@cobo/btc')

const w = wallet
  .fromMnemonic(
    'maid series tooth gesture smile scrub awesome because letter aware wash nation',
    wallet.networks.testnet
  )
  .derivePath("m/49'/1'/0'/0/0")

const utxos = [
  {
    txId: '07e73301edaaaa713d3a671120824861314f24baf7c371232026a59a389b5ced',
    vout: 0,
    value: 1 * 1e8
  }
]

const { hex } = w.generateTransaction({
  address: 'tb1quyup6le6zt30cwmf2kdmj0y84gxze0q2f67euz',
  fee: 1e4,
  utxos,
  amount: 2e7
})

console.log(hex)

Also you can switch P2PKH / P2SH for BTC:

import wallet from 'btc-wallet'

// default to p2sh
const P2PKHWallet = wallet.fromMasterSeed(
    seed,
    wallet.networks.bitcoin
)

// legacy address
const P2SHWallet = wallet.fromMasterSeed(
    seed,
    wallet.networks.bitcoin,
    wallet.ADDRESS_TYPES.p2pkh
)

Readme

Keywords

none

Package Sidebar

Install

npm i @cobo/btc

Weekly Downloads

0

Version

0.2.1

License

none

Unpacked Size

1.14 MB

Total Files

6

Last publish

Collaborators

  • cobowallet