bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.62k stars 2.09k forks source link

If you use bitcoinjs.ECPair.fromWIF(publicKeys, mainnet) on the main network; how do you need to modify the mainnet later? #1223

Closed tangjielong closed 5 years ago

tangjielong commented 5 years ago

If you use bitcoinjs.ECPair.fromWIF(publicKeys, mainnet) on the main network; how do you need to modify the mainnet later? this my code const TestNet = bitcoinjs.networks.testnet; var key = new bitcoinjs.ECPair.fromWIF(publicKeys, TestNet); var tx = new bitcoinjs.TransactionBuilder(TestNet); how to use main network?

dcousens commented 5 years ago

Testnet

const bitcoin = require('bitcoinjs-lib')

// ...
const network = bitcoin.networks.testnet // spot the difference

// ...
const keyPair = new bitcoin.ECPair.fromWIF(..., network)
const txb = new bitcoin.TransactionBuilder(network)

Mainnet

const bitcoin = require('bitcoinjs-lib')

// ...
const network = bitcoin.networks.bitcoin // spot the difference

// ...
const keyPair = new bitcoin.ECPair.fromWIF(..., network)
const txb = new bitcoin.TransactionBuilder(network)

Reference https://github.com/bitcoinjs/bitcoinjs-lib/blob/625f5e01ce4241d52ab89993aa501d8b7e6cc999/src/networks.js#L4-L27

tangjielong commented 5 years ago

think your very mach!