Merge pull request #1095 from bitcoinjs/nolitecoin

rm Litecoin
This commit is contained in:
Daniel Cousens 2018-06-20 14:57:24 +10:00 committed by GitHub
commit 71311d023d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 21 deletions

View file

@ -23,15 +23,5 @@ module.exports = {
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef
},
litecoin: {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x019da462,
private: 0x019d9cfe
},
pubKeyHash: 0x30,
scriptHash: 0x32,
wif: 0xb0
}
}

View file

@ -1,10 +1,21 @@
/* global describe, it */
var assert = require('assert')
var baddress = require('../src/address')
var networks = require('../src/networks')
var bscript = require('../src/script')
var fixtures = require('./fixtures/address.json')
let assert = require('assert')
let baddress = require('../src/address')
let bscript = require('../src/script')
let fixtures = require('./fixtures/address.json')
let NETWORKS = Object.assign({
litecoin: {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x019da462,
private: 0x019d9cfe
},
pubKeyHash: 0x30,
scriptHash: 0x32,
wif: 0xb0
}
}, require('../src/networks'))
describe('address', function () {
describe('fromBase58Check', function () {
@ -36,7 +47,7 @@ describe('address', function () {
var actual = baddress.fromBech32(f.bech32)
assert.strictEqual(actual.version, f.version)
assert.strictEqual(actual.prefix, networks[f.network].bech32)
assert.strictEqual(actual.prefix, NETWORKS[f.network].bech32)
assert.strictEqual(actual.data.toString('hex'), f.data)
})
})
@ -54,7 +65,7 @@ describe('address', function () {
fixtures.standard.forEach(function (f) {
it('encodes ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () {
var script = bscript.fromASM(f.script)
var address = baddress.fromOutputScript(script, networks[f.network])
var address = baddress.fromOutputScript(script, NETWORKS[f.network])
assert.strictEqual(address, f.base58check || f.bech32.toLowerCase())
})
@ -107,7 +118,7 @@ describe('address', function () {
describe('toOutputScript', function () {
fixtures.standard.forEach(function (f) {
it('decodes ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () {
var script = baddress.toOutputScript(f.base58check || f.bech32, networks[f.network])
var script = baddress.toOutputScript(f.base58check || f.bech32, NETWORKS[f.network])
assert.strictEqual(bscript.toASM(script), f.script)
})

View file

@ -4,6 +4,17 @@ let assert = require('assert')
let bitcoin = require('../../')
let dhttp = require('dhttp/200')
let LITECOIN = {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x019da462,
private: 0x019d9cfe
},
pubKeyHash: 0x30,
scriptHash: 0x32,
wif: 0xb0
}
// deterministic RNG for testing only
function rng () { return Buffer.from('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz') }
@ -135,10 +146,9 @@ describe('bitcoinjs-lib (addresses)', function () {
})
it('can generate a Litecoin address', function () {
let litecoin = bitcoin.networks.litecoin
let keyPair = bitcoin.ECPair.makeRandom({ network: litecoin, rng: rng })
let keyPair = bitcoin.ECPair.makeRandom({ network: LITECOIN, rng: rng })
let wif = keyPair.toWIF()
let address = getAddress(keyPair, litecoin)
let address = getAddress(keyPair, LITECOIN)
assert.strictEqual(address, 'LZJSxZbjqJ2XVEquqfqHg1RQTDdfST5PTn')
assert.strictEqual(wif, 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS')