cryptocoinjs / coininfo

JavaScript component for crypto currency specific information.
116 stars 112 forks source link

testnet does not work #99

Closed VolckaertAchiel closed 3 years ago

VolckaertAchiel commented 3 years ago

testnet coin generation does not work on the coins

const bitcoinjs = require('bitcoinjs-lib')
const bip32 = bitcoinjs.bip32

const coininfo = require('coininfo')
// const litecoin = coininfo.litecoin.main
const litecoin = coininfo.litecoin.test
const litecoinBitcoinJSLib = litecoin.toBitcoinJS()

const ltub = 'tpubD8pc36mM6KpYLpAqMTz6mqSxm79fpiJCgpoq4WxsARqZikr7xcH17T8dq3BuEy4xt63gcpwWFnFgRxqEuULBB4kDxNqB2kTZqtrg9UcEgxu'

const accountNode = bip32.fromBase58(ltub, litecoinBitcoinJSLib)

function getAddress (node, network) {
  return bitcoinjs.payments.p2pkh({ pubkey: node.publicKey, network }).address
}

const recvNode = accountNode.derive(0)

console.log((getAddress(recvNode.derive(2), litecoinBitcoinJSLib)))
junderw commented 3 years ago

litecoin testnet uses "ttub" not "tpub"

VolckaertAchiel commented 3 years ago

iancoleman's tool gives a tpub?

also same issue with doge, doge tpubD8SsRvv4Xbf82F7Hnyn3JXDCufcpdanDSDmhiaZWnH96NATLVxCYfgTUw8SbJ7JCcvaSvZp5uC9cZL7njoSSxBkCMWeT23TegBrnqQG4nn5

junderw commented 3 years ago

What does litecoind give? What does dogecoind give?

That is what we will follow.

If you find the line in litecoind or dogecoind that says tpub we'll switch to tpub.