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, pubKeyHash: 0x6f,
scriptHash: 0xc4, scriptHash: 0xc4,
wif: 0xef 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 */ /* global describe, it */
var assert = require('assert') let assert = require('assert')
var baddress = require('../src/address') let baddress = require('../src/address')
var networks = require('../src/networks') let bscript = require('../src/script')
var bscript = require('../src/script') let fixtures = require('./fixtures/address.json')
var 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('address', function () {
describe('fromBase58Check', function () { describe('fromBase58Check', function () {
@ -36,7 +47,7 @@ describe('address', function () {
var actual = baddress.fromBech32(f.bech32) var actual = baddress.fromBech32(f.bech32)
assert.strictEqual(actual.version, f.version) 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) assert.strictEqual(actual.data.toString('hex'), f.data)
}) })
}) })
@ -54,7 +65,7 @@ describe('address', function () {
fixtures.standard.forEach(function (f) { fixtures.standard.forEach(function (f) {
it('encodes ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () { it('encodes ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () {
var script = bscript.fromASM(f.script) 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()) assert.strictEqual(address, f.base58check || f.bech32.toLowerCase())
}) })
@ -107,7 +118,7 @@ describe('address', function () {
describe('toOutputScript', function () { describe('toOutputScript', function () {
fixtures.standard.forEach(function (f) { fixtures.standard.forEach(function (f) {
it('decodes ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () { 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) assert.strictEqual(bscript.toASM(script), f.script)
}) })

View file

@ -4,6 +4,17 @@ let assert = require('assert')
let bitcoin = require('../../') let bitcoin = require('../../')
let dhttp = require('dhttp/200') 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 // deterministic RNG for testing only
function rng () { return Buffer.from('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz') } function rng () { return Buffer.from('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz') }
@ -135,10 +146,9 @@ describe('bitcoinjs-lib (addresses)', function () {
}) })
it('can generate a Litecoin address', 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 wif = keyPair.toWIF()
let address = getAddress(keyPair, litecoin) let address = getAddress(keyPair, LITECOIN)
assert.strictEqual(address, 'LZJSxZbjqJ2XVEquqfqHg1RQTDdfST5PTn') assert.strictEqual(address, 'LZJSxZbjqJ2XVEquqfqHg1RQTDdfST5PTn')
assert.strictEqual(wif, 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS') assert.strictEqual(wif, 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS')