@cobo/btc
v0.2.1
Published
## Example
Downloads
21
Readme
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
)