Bitcoinjs-lib: Altcoin and bitcoinjs

Created on 27 Mar 2015  路  4Comments  路  Source: bitcoinjs/bitcoinjs-lib

Hi there,
I see the bitcoinjs is works perfect with Bitcoin.
can any you show me what and where the parameters to change in the code to be work perfect wirth Litecoin.
I mean the address prefix , private key prefix and any other required parameters
and it is important if there any other parameters

regards,

how to / question / docs

Most helpful comment

Fortunately a lot of these altcoins just use a version number to differentiate how addresses work. bitcoinjs-lib can accommodate this. First, take a look here to see if the network (altcoin) info is already supported: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/networks.js If it is not, it's just a Google search away to find the information.

To generate a Litecoin address / private key (wallet import format):

// assuming bitcoinjs-lib 1.x
var bitcoin = require('bitcoinjs-lib')
var litecoin = bitcoin.networks.litecoin

var key = bitcoin.ECKey.makeRandom()
var wif = key.toWIF(litecoin)
var address = key.pub.getAddress(litecoin).toString()

console.log('wif: ' + wif)
console.log('address: ' + address)

Should do the trick.

All 4 comments

Fortunately a lot of these altcoins just use a version number to differentiate how addresses work. bitcoinjs-lib can accommodate this. First, take a look here to see if the network (altcoin) info is already supported: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/networks.js If it is not, it's just a Google search away to find the information.

To generate a Litecoin address / private key (wallet import format):

// assuming bitcoinjs-lib 1.x
var bitcoin = require('bitcoinjs-lib')
var litecoin = bitcoin.networks.litecoin

var key = bitcoin.ECKey.makeRandom()
var wif = key.toWIF(litecoin)
var address = key.pub.getAddress(litecoin).toString()

console.log('wif: ' + wif)
console.log('address: ' + address)

Should do the trick.

I did it,

but i got from the log this :

2015-04-01 09:43:52 trying connection 108.49.59.73:8334 lastseen=3215.0hrs
2015-04-01 09:43:53 ERROR: CScriptCheck() : 9bb8ffd9c2304e9633ff2bec90e677fbb4b27272f01dfc9423a50dd8976824d6 VerifySignature failed
2015-04-01 09:43:53 ERROR: CScriptCheck() : 9bb8ffd9c2304e9633ff2bec90e677fbb4b27272f01dfc9423a50dd8976824d6 VerifySignature failed
2015-04-01 09:43:53 ERROR: CTxMemPool::accept() : ConnectInputs failed 9bb8ffd9c2304e9633ff2bec90e677fbb4b27272f01dfc9423a50dd8976824d6

@coingeek that is not related to bitcoinjs-lib at all.

when i excute the tx (rawtansaction) that i got from the bitcoinjs, i got in the in the log above error (verifysignature)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itsMikeLowrey picture itsMikeLowrey  路  3Comments

dakk picture dakk  路  3Comments

yakitorifoodie picture yakitorifoodie  路  3Comments

LeonYanghaha picture LeonYanghaha  路  3Comments

stefanhuber picture stefanhuber  路  4Comments