Litecoin: litecoinify

This commit is contained in:
ultragtx 2017-12-08 16:03:46 +08:00
parent d489238711
commit 4e7675cc7a
33 changed files with 546 additions and 1534 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ docker_data/
browser/bcoin* browser/bcoin*
package-lock.json package-lock.json
npm-debug.log npm-debug.log
.DS_Store

View File

@ -1,4 +1,4 @@
# Bcoin # Lcoin (Bcoin ported to Litecoin)
__NOTE__: The latest release of bcoin contains a non-backward compatible change __NOTE__: The latest release of bcoin contains a non-backward compatible change
to the rest API. Please read the [changelog]'s "migrating" section for more to the rest API. Please read the [changelog]'s "migrating" section for more
@ -6,13 +6,9 @@ details.
--- ---
**Bcoin** is an alternative implementation of the bitcoin protocol, written in **Lcoin** is an alternative implementation of the bitcoin protocol, written in
node.js. node.js.
Although still in a beta state, bcoin is well tested and aware of all known
consensus rules. It is currently used in production as the consensus backend
and wallet system for [purse.io][purse].
## Uses ## Uses
- Full Node - Full Node
@ -27,10 +23,10 @@ Try it in the browser: http://bcoin.io/browser.html
## Install ## Install
``` ```
$ git clone git://github.com/bcoin-org/bcoin.git $ git clone git://github.com/bcoin-org/lcoin.git
$ cd bcoin $ cd lcoin
$ npm install $ npm install
$ ./bin/bcoin $ ./bin/lcoin
``` ```
See the [Beginner's Guide][guide] for more in-depth installation instructions. See the [Beginner's Guide][guide] for more in-depth installation instructions.
@ -47,7 +43,7 @@ Join us on [freenode][freenode] in the [#bcoin][irc] channel.
## Disclaimer ## Disclaimer
Bcoin does not guarantee you against theft or lost funds due to bugs, mishaps, Lcoin does not guarantee you against theft or lost funds due to bugs, mishaps,
or your own incompetence. You and you alone are responsible for securing your or your own incompetence. You and you alone are responsible for securing your
money. money.

View File

@ -12,14 +12,14 @@ const ANTIREPLAY = ''
+ '220456c656374726f6e696320436173682053797374656d'; + '220456c656374726f6e696320436173682053797374656d';
function CLI() { function CLI() {
this.config = new Config('bcoin'); this.config = new Config('lcoin');
this.config.load({ this.config.load({
argv: true, argv: true,
env: true env: true
}); });
this.config.open('bcoin.conf'); this.config.open('lcoin.conf');
this.argv = this.config.argv; this.argv = this.config.argv;
this.client = null; this.client = null;

View File

@ -2,7 +2,7 @@
'use strict'; 'use strict';
process.title = 'bcoin'; process.title = 'lcoin';
if (process.argv.indexOf('--help') !== -1 if (process.argv.indexOf('--help') !== -1
|| process.argv.indexOf('-h') !== -1) { || process.argv.indexOf('-h') !== -1) {

View File

@ -2,7 +2,7 @@
'use strict'; 'use strict';
process.title = 'bcoin'; process.title = 'lcoin';
const assert = require('assert'); const assert = require('assert');
const SPVNode = require('../lib/node/spvnode'); const SPVNode = require('../lib/node/spvnode');

View File

@ -12,7 +12,7 @@ const worker = fs.readFileSync(`${__dirname}/bcoin-worker.js`);
const proxy = new WSProxy({ const proxy = new WSProxy({
pow: process.argv.indexOf('--pow') !== -1, pow: process.argv.indexOf('--pow') !== -1,
ports: [8333, 18333, 18444, 28333, 28901] ports: [9333, 19335, 19444, 28333, 28901]
}); });
const server = new HTTPBase({ const server = new HTTPBase({

View File

@ -2302,7 +2302,12 @@ Chain.prototype.getTarget = async function getTarget(time, prev) {
} }
// Back 2 weeks // Back 2 weeks
const height = prev.height - (pow.retargetInterval - 1); var back = pow.retargetInterval - 1;
if (prev.height + 1 !== pow.retargetInterval)
back = pow.retargetInterval;
const height = prev.height - back;
assert(height >= 0); assert(height >= 0);
const first = await this.getAncestor(prev, height); const first = await this.getAncestor(prev, height);

View File

@ -98,7 +98,7 @@ URI.prototype.fromString = function fromString(str, network) {
const prefix = str.substring(0, 8); const prefix = str.substring(0, 8);
assert(prefix === 'bitcoin:', 'Not a bitcoin URI.'); assert(prefix === 'litecoin:', 'Not a bitcoin URI.');
str = str.substring(8); str = str.substring(8);
@ -154,7 +154,7 @@ URI.fromString = function fromString(str, network) {
*/ */
URI.prototype.toString = function toString() { URI.prototype.toString = function toString() {
let str = 'bitcoin:'; let str = 'litecoin:';
str += this.address.toString(); str += this.address.toString();

View File

@ -7,7 +7,7 @@
'use strict'; 'use strict';
const assert = require('assert'); const assert = require('assert');
const digest = require('../crypto/digest'); const scrypt = require('../crypto/scrypt').derive;
/** /**
* Hash until the nonce overflows. * Hash until the nonce overflows.
@ -27,7 +27,7 @@ function mine(data, target, min, max) {
// The heart and soul of the miner: match the target. // The heart and soul of the miner: match the target.
while (nonce <= max) { while (nonce <= max) {
// Hash and test against the next target. // Hash and test against the next target.
if (rcmp(digest.hash256(data), target) <= 0) if (rcmp(powHash(data), target) <= 0)
return nonce; return nonce;
// Increment the nonce to get a different hash. // Increment the nonce to get a different hash.
@ -40,6 +40,16 @@ function mine(data, target, min, max) {
return -1; return -1;
} }
/**
* Proof of work function.
* @param {Buffer} data
* @returns {Buffer}
*/
function powHash(data) {
return scrypt(data, data, 1024, 1, 1, 32);
}
/** /**
* "Reverse" comparison so we don't have * "Reverse" comparison so we don't have
* to waste time reversing the block hash. * to waste time reversing the block hash.

View File

@ -23,6 +23,7 @@ const encoding = require('../utils/encoding');
const CoinView = require('../coins/coinview'); const CoinView = require('../coins/coinview');
const Script = require('../script/script'); const Script = require('../script/script');
const common = require('./common'); const common = require('./common');
const scrypt = require('../crypto/scrypt').derive;
const DUMMY = Buffer.alloc(0); const DUMMY = Buffer.alloc(0);
/** /**
@ -418,7 +419,7 @@ BlockTemplate.prototype.getHeader = function getHeader(root, time, nonce) {
BlockTemplate.prototype.getProof = function getProof(nonce1, nonce2, time, nonce) { BlockTemplate.prototype.getProof = function getProof(nonce1, nonce2, time, nonce) {
const root = this.getRoot(nonce1, nonce2); const root = this.getRoot(nonce1, nonce2);
const data = this.getHeader(root, time, nonce); const data = this.getHeader(root, time, nonce);
const hash = digest.hash256(data); const hash = scrypt(data, data, 1024, 1, 1, 32);
return new BlockProof(hash, root, nonce1, nonce2, time, nonce); return new BlockProof(hash, root, nonce1, nonce2, time, nonce);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,17 @@
'use strict'; 'use strict';
module.exports = [ module.exports = [
'thfsmmn2jbitcoin.onion', '45.33.107.92',
'it2pj4f7657g3rhi.onion', '45.76.92.84',
'nkf5e6b7pl4jfd4a.onion', '47.93.81.84',
'4zhkir2ofl7orfom.onion', '66.178.182.35',
't6xj6wilh4ytvcs7.onion', '78.47.34.228',
'i6y6ivorwakd7nw3.onion', '94.176.237.167',
'ubqj4rsu3nqtxmtp.onion' '98.234.65.112',
'104.131.161.171',
'104.236.211.206',
'104.243.38.34',
'108.61.195.151',
'138.197.220.217',
'173.209.44.34',
]; ];

View File

@ -32,12 +32,12 @@ function Node(options) {
AsyncObject.call(this); AsyncObject.call(this);
this.config = new Config('bcoin'); this.config = new Config('lcoin');
this.config.inject(options); this.config.inject(options);
this.config.load(options); this.config.load(options);
if (options.config) if (options.config)
this.config.open('bcoin.conf'); this.config.open('lcoin.conf');
this.network = Network.get(this.config.network); this.network = Network.get(this.config.network);
this.startTime = -1; this.startTime = -1;

View File

@ -15,6 +15,7 @@ const StaticWriter = require('../utils/staticwriter');
const InvItem = require('./invitem'); const InvItem = require('./invitem');
const encoding = require('../utils/encoding'); const encoding = require('../utils/encoding');
const consensus = require('../protocol/consensus'); const consensus = require('../protocol/consensus');
const scrypt = require('../crypto/scrypt').derive;
/** /**
* The class which all block-like objects inherit from. * The class which all block-like objects inherit from.
@ -156,6 +157,17 @@ AbstractBlock.prototype.hash = function hash(enc) {
return h; return h;
}; };
/**
* Hash the block headers with scrypt.
* @param {String?} enc - Can be `'hex'` or `null`.
* @returns {Hash|Buffer} hash
*/
AbstractBlock.prototype.powHash = function powHash() {
var data = this.toHead();
return scrypt(data, data, 1024, 1, 1, 32);
};
/** /**
* Serialize the block headers. * Serialize the block headers.
* @returns {Buffer} * @returns {Buffer}
@ -226,7 +238,7 @@ AbstractBlock.prototype.verify = function verify() {
*/ */
AbstractBlock.prototype.verifyPOW = function verifyPOW() { AbstractBlock.prototype.verifyPOW = function verifyPOW() {
return consensus.verifyPOW(this.hash(), this.bits); return consensus.verifyPOW(this.powHash(), this.bits);
}; };
/** /**

View File

@ -49,7 +49,8 @@ function Address(options) {
Address.types = { Address.types = {
PUBKEYHASH: 2, PUBKEYHASH: 2,
SCRIPTHASH: 3, SCRIPTHASH: 3,
WITNESS: 4 SCRIPTHASH2: 4,
WITNESS: 5
}; };
/** /**
@ -162,6 +163,8 @@ Address.prototype.getPrefix = function getPrefix(network) {
return prefixes.pubkeyhash; return prefixes.pubkeyhash;
case Address.types.SCRIPTHASH: case Address.types.SCRIPTHASH:
return prefixes.scripthash; return prefixes.scripthash;
case Address.types.SCRIPTHASH2:
return prefixes.scripthash2;
case Address.types.WITNESS: case Address.types.WITNESS:
if (this.hash.length === 20) if (this.hash.length === 20)
return prefixes.witnesspubkeyhash; return prefixes.witnesspubkeyhash;
@ -784,7 +787,7 @@ Address.prototype.isPubkeyhash = function isPubkeyhash() {
*/ */
Address.prototype.isScripthash = function isScripthash() { Address.prototype.isScripthash = function isScripthash() {
return this.type === Address.types.SCRIPTHASH; return this.type === Address.types.SCRIPTHASH || this.type === Address.types.SCRIPTHASH2;
}; };
/** /**
@ -891,6 +894,8 @@ Address.getType = function getType(prefix, network) {
return Address.types.PUBKEYHASH; return Address.types.PUBKEYHASH;
case prefixes.scripthash: case prefixes.scripthash:
return Address.types.SCRIPTHASH; return Address.types.SCRIPTHASH;
case prefixes.scripthash2:
return Address.types.SCRIPTHASH2;
case prefixes.witnesspubkeyhash: case prefixes.witnesspubkeyhash:
case prefixes.witnessscripthash: case prefixes.witnessscripthash:
return Address.types.WITNESS; return Address.types.WITNESS;

View File

@ -1440,6 +1440,10 @@ TX.prototype.checkSanity = function checkSanity() {
if (output.value > consensus.MAX_MONEY) if (output.value > consensus.MAX_MONEY)
return [false, 'bad-txns-vout-toolarge', 100]; return [false, 'bad-txns-vout-toolarge', 100];
if (!util.isSafeAddition(total, output.value)) {
return [false, 'bad-txns-txouttotal-toolarge', 100];
}
total += output.value; total += output.value;
if (total < 0 || total > consensus.MAX_MONEY) if (total < 0 || total > consensus.MAX_MONEY)
@ -1745,6 +1749,10 @@ TX.prototype.checkInputs = function checkInputs(view, height) {
if (coin.value < 0 || coin.value > consensus.MAX_MONEY) if (coin.value < 0 || coin.value > consensus.MAX_MONEY)
return [-1, 'bad-txns-inputvalues-outofrange', 100]; return [-1, 'bad-txns-inputvalues-outofrange', 100];
if (!util.isSafeAddition(total, coin.value)) {
return [-1, 'bad-txns-inputvalues-outofrange', 100];
}
total += coin.value; total += coin.value;
if (total < 0 || total > consensus.MAX_MONEY) if (total < 0 || total > consensus.MAX_MONEY)

View File

@ -29,7 +29,7 @@ exports.COIN = 100000000;
* @default * @default
*/ */
exports.MAX_MONEY = 21000000 * exports.COIN; exports.MAX_MONEY = 84000000 * exports.COIN;
/** /**
* Base block subsidy (consensus). * Base block subsidy (consensus).
@ -216,7 +216,7 @@ exports.MAX_MULTISIG_PUBKEYS = 20;
* @default * @default
*/ */
exports.BIP16_TIME = 1333238400; exports.BIP16_TIME = 1349049600;
/** /**
* Convert a compact number to a big number. * Convert a compact number to a big number.

View File

@ -79,7 +79,6 @@ Network.type = null;
Network.main = null; Network.main = null;
Network.testnet = null; Network.testnet = null;
Network.regtest = null; Network.regtest = null;
Network.segnet4 = null;
Network.simnet = null; Network.simnet = null;
/** /**
@ -418,6 +417,7 @@ function cmpAddress(network, prefix) {
switch (prefix) { switch (prefix) {
case prefixes.pubkeyhash: case prefixes.pubkeyhash:
case prefixes.scripthash: case prefixes.scripthash:
case prefixes.scripthash2:
case prefixes.witnesspubkeyhash: case prefixes.witnesspubkeyhash:
case prefixes.witnessscripthash: case prefixes.witnessscripthash:
return true; return true;

View File

@ -48,12 +48,11 @@ main.type = 'main';
*/ */
main.seeds = [ main.seeds = [
'seed.bitcoin.sipa.be', // Pieter Wuille 'seed-a.litecoin.loshan.co.uk',
'dnsseed.bluematt.me', // Matt Corallo 'dnsseed.thrasher.io',
'dnsseed.bitcoin.dashjr.org', // Luke Dashjr 'dnsseed.litecointools.com',
'seed.bitcoinstats.com', // Christian Decker 'dnsseed.litecoinpool.org',
'seed.bitcoin.jonasschnelli.ch', // Jonas Schnelli 'dnsseed.koin-project.com'
'seed.btc.petertodd.org' // Peter Todd
]; ];
/** /**
@ -62,7 +61,7 @@ main.seeds = [
* @default * @default
*/ */
main.magic = 0xd9b4bef9; main.magic = 0xdbb6c0fb;
/** /**
* Default network port. * Default network port.
@ -70,7 +69,7 @@ main.magic = 0xd9b4bef9;
* @default * @default
*/ */
main.port = 8333; main.port = 9333;
/** /**
* Checkpoint block list. * Checkpoint block list.
@ -78,30 +77,22 @@ main.port = 8333;
*/ */
main.checkpointMap = { main.checkpointMap = {
11111: '1d7c6eb2fd42f55925e92efad68b61edd22fba29fde8783df744e26900000000', 1500: '67299ab5a20244afc95e8376d48b5fe4545ad055a707a7cf88d25d9565291a84',
33333: 'a6d0b5df7d0df069ceb1e736a216ad187a50b07aaa4e78748a58d52d00000000', 4032: '4608cfd9e3d75f9687a935fd6ae2805b720335ce05595ef00efc9871420ee99c',
74000: '201a66b853f9e7814a820e2af5f5dc79c07144e31ce4c9a39339570000000000', 8064: '700d4394a67d98b3fc29b7f0efeeb9baa4b8400c151f6510f29051fc534398eb',
105000: '97dc6b1d15fbeef373a744fee0b254b0d2c820a3ae7f0228ce91020000000000', 16128: '3d15cd1c2ae103ec4b7acd9d4d1ddc6fb66c0e9b1d9f80afa6f9b75918df2e60',
134444: 'feb0d2420d4a18914c81ac30f494a5d4ff34cd15d34cfd2fb105000000000000', 23420: '07b501510bce8f974e87ec30258fa57d54fea9c30aa9b2d20bfd1aa89cdf0fd8',
168000: '63b703835cb735cb9a89d733cbe66f212f63795e0172ea619e09000000000000', 50000: 'a6207ad0713e2b2b88323a4fdb2a6727c11904cc2d01a575f0689b02eb37dc69',
193000: '17138bca83bdc3e6f60f01177c3877a98266de40735f2a459f05000000000000', 80000: '0ae9b2cd2e186748cbbe8c6ab420f9a85599a864c7493f5000a376f6027ccb4f',
210000: '2e3471a19b8e22b7f939c63663076603cf692f19837e34958b04000000000000', 120000: '3161ac52357a6a021b12e7e9ce298e9ec88e82325f15f0a7daf6054f92269dbd',
216116: '4edf231bf170234e6a811460f95c94af9464e41ee833b4f4b401000000000000', 161500: '43ff718479f7bb8d41b8283b12914902dc1cba777c225cf7b44b4f478098e8db',
225430: '32595730b165f097e7b806a679cf7f3e439040f750433808c101000000000000', 179620: '09f7b9782b0ba55883b2dca7e969fa2fbed70f6e448ed12604c00a995cc6d92a',
250000: '14d2f24d29bed75354f3f88a5fb50022fc064b02291fdf873800000000000000', 240000: 'aa885055a13e2eab6e4e0c59c439db739c4cf23676ee17a27c15c2b4c4d14071',
279000: '407ebde958e44190fa9e810ea1fc3a7ef601c3b0a0728cae0100000000000000', 383640: '64f3c626f1c396a090057d4be94ba32751a310f1b35ec6af5b21a994f009682b',
295000: '83a93246c67003105af33ae0b29dd66f689d0f0ff54e9b4d0000000000000000', 409004: 'a3085935f1b439cfe9770edcfb67b682d974ad95931d6108faf1d963d6187548',
300255: 'b2f3a0f0de4120c1089d5f5280a263059f9b6e7c520428160000000000000000', 456000: '0420375624e31b407dac0105a4a64ce397f822be060d9387d46c36c61cf734bf',
319400: '3bf115fd057391587ca39a531c5d4989e1adec9b2e05c6210000000000000000', 638902: '384fc7ae3bc5ec5cc49ccd3d95fc9a81a5f3fc758c9ae28dd263ece856862315',
343185: '548536d48e7678fcfa034202dd45d4a76b1ad061f38b2b070000000000000000', 721000: 'e540989a758adc4116743ee6a235b2ea14b7759dd93b46e27894dfe14d7b8a19'
352940: 'ffc9520143e41c94b6e03c2fa3e62bb76b55ba2df45d75100000000000000000',
382320: 'b28afdde92b0899715e40362f56afdb20e3d135bedc68d0a0000000000000000',
401465: 'eed16cb3e893ed9366f27c39a9ecd95465d02e3ef40e45010000000000000000',
420000: 'a1ff746b2d42b834cb7d6b8981b09c265c2cabc016e8cc020000000000000000',
440000: '9bf296b8de5f834f7635d5e258a434ad51b4dbbcf7c08c030000000000000000',
450000: '0ba2070c62cd9da1f8cef88a0648c661a411d33e728340010000000000000000',
460000: '8c25fc7e414d3e868d6ce0ec473c30ad44e7e8bc1b75ef000000000000000000',
470000: '89756d1ed75901437300af10d5ab69070a282e729c536c000000000000000000'
}; };
/** /**
@ -110,14 +101,14 @@ main.checkpointMap = {
* @default * @default
*/ */
main.lastCheckpoint = 470000; main.lastCheckpoint = 721000;
/** /**
* @const {Number} * @const {Number}
* @default * @default
*/ */
main.halvingInterval = 210000; main.halvingInterval = 840000;
/** /**
* Genesis block header. * Genesis block header.
@ -126,13 +117,12 @@ main.halvingInterval = 210000;
main.genesis = { main.genesis = {
version: 1, version: 1,
hash: '6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000', hash: 'e2bf047e7e5a191aa4ef34d314979dc9986e0f19251edaba5940fd1fe365a712',
prevBlock: '0000000000000000000000000000000000000000000000000000000000000000', prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
merkleRoot: merkleRoot: 'd9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97',
'3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', time: 1317972665,
time: 1231006505, bits: 504365040, // 0x1e0ffff0
bits: 486604799, nonce: 2084524493,
nonce: 2083236893,
height: 0 height: 0
}; };
@ -143,14 +133,13 @@ main.genesis = {
main.genesisBlock = main.genesisBlock =
'0100000000000000000000000000000000000000000000000000000000000000000000' '0100000000000000000000000000000000000000000000000000000000000000000000'
+ '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab' + '00d9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97b9aa'
+ '5f49ffff001d1dac2b7c01010000000100000000000000000000000000000000000000' + '8e4ef0ff0f1ecd513f7c01010000000100000000000000000000000000000000000000'
+ '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573' + '00000000000000000000000000ffffffff4804ffff001d0104404e592054696d657320'
+ '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66' + '30352f4f63742f32303131205374657665204a6f62732c204170706c65e28099732056'
+ '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01' + '6973696f6e6172792c2044696573206174203536ffffffff0100f2052a010000004341'
+ '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f' + '040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4'
+ '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f' + 'd4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9ac00000000';
+ 'ac00000000';
/** /**
* POW-related constants. * POW-related constants.
@ -165,7 +154,7 @@ main.pow = {
*/ */
limit: new BN( limit: new BN(
'00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff', '00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
'hex' 'hex'
), ),
@ -175,7 +164,7 @@ main.pow = {
* @default * @default
*/ */
bits: 486604799, bits: 504365055,
/** /**
* Minimum chainwork for best chain. * Minimum chainwork for best chain.
@ -183,7 +172,7 @@ main.pow = {
*/ */
chainwork: new BN( chainwork: new BN(
'00000000000000000000000000000000000000000074093f7ecede98cadd3a32', '00000000000000000000000000000000000000000000000ba50a60f8b56c7fe0',
'hex' 'hex'
), ),
@ -193,7 +182,7 @@ main.pow = {
* @default * @default
*/ */
targetTimespan: 14 * 24 * 60 * 60, targetTimespan: 3.5 * 24 * 60 * 60,
/** /**
* Average block time. * Average block time.
@ -201,7 +190,7 @@ main.pow = {
* @default * @default
*/ */
targetSpacing: 10 * 60, targetSpacing: 2.5 * 60,
/** /**
* Retarget interval in blocks. * Retarget interval in blocks.
@ -241,37 +230,37 @@ main.block = {
* Used for avoiding bip30 checks. * Used for avoiding bip30 checks.
*/ */
bip34height: 227931, bip34height: 710000,
/** /**
* Hash of the block that activated bip34. * Hash of the block that activated bip34.
*/ */
bip34hash: 'b808089c756add1591b1d17bab44bba3fed9e02f942ab4894b02000000000000', bip34hash: 'cf519deb9a32b4c72612ff0c42bf3a04f262fa41d4c8a7d58e763aa804d209fa',
/** /**
* Height at which bip65 was activated. * Height at which bip65 was activated.
*/ */
bip65height: 388381, bip65height: 918684,
/** /**
* Hash of the block that activated bip65. * Hash of the block that activated bip65.
*/ */
bip65hash: 'f035476cfaeb9f677c2cdad00fd908c556775ded24b6c2040000000000000000', bip65hash: '1a31cc64827cc248b2afefd849d41dde2bb907e73ff6ef3edce077891e04b3ba',
/** /**
* Height at which bip66 was activated. * Height at which bip66 was activated.
*/ */
bip66height: 363725, bip66height: 811879,
/** /**
* Hash of the block that activated bip66. * Hash of the block that activated bip66.
*/ */
bip66hash: '3109b588941188a9f1c2576aae462d729b8cce9da1ea79030000000000000000', bip66hash: '941849dc7bbdd271a727db8fb06acd33e23a1b8b5d83f85289fa332801eece7a',
/** /**
* Safe height to start pruning. * Safe height to start pruning.
@ -298,7 +287,7 @@ main.block = {
* logs without spamming. * logs without spamming.
*/ */
slowHeight: 325000 slowHeight: 900000
}; };
/** /**
@ -308,10 +297,7 @@ main.block = {
* @default * @default
*/ */
main.bip30 = { main.bip30 = {};
91842: 'eccae000e3c8e4e093936360431f3b7603c563c1ff6181390a4d0a0000000000',
91880: '21d77ccb4c08386a04ac0196ae10f6a1d2c2a377558ca190f143070000000000'
};
/** /**
* For versionbits. * For versionbits.
@ -319,7 +305,7 @@ main.bip30 = {
* @default * @default
*/ */
main.activationThreshold = 1916; // 95% of 2016 main.activationThreshold = 6048; // 75% of 8064
/** /**
* Confirmation window for versionbits. * Confirmation window for versionbits.
@ -327,7 +313,7 @@ main.activationThreshold = 1916; // 95% of 2016
* @default * @default
*/ */
main.minerWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing main.minerWindow = 8064; // nPowTargetTimespan / nPowTargetSpacing * 4
/** /**
* Deployments for versionbits. * Deployments for versionbits.
@ -339,8 +325,8 @@ main.deployments = {
csv: { csv: {
name: 'csv', name: 'csv',
bit: 0, bit: 0,
startTime: 1462060800, // May 1st, 2016 startTime: 1485561600, // January 28, 2017
timeout: 1493596800, // May 1st, 2017 timeout: 1517356801, // January 31st, 2018
threshold: -1, threshold: -1,
window: -1, window: -1,
required: false, required: false,
@ -349,23 +335,13 @@ main.deployments = {
segwit: { segwit: {
name: 'segwit', name: 'segwit',
bit: 1, bit: 1,
startTime: 1479168000, // November 15th, 2016. startTime: 1485561600, // January 28, 2017
timeout: 1510704000, // November 15th, 2017. timeout: 1517356801, // January 31st, 2018
threshold: -1, threshold: -1,
window: -1, window: -1,
required: true, required: true,
force: false force: false
}, },
segsignal: {
name: 'segsignal',
bit: 4,
startTime: 1496275200, // June 1st, 2017.
timeout: 1510704000, // November 15th, 2017.
threshold: 269, // 80%
window: 336, // ~2.33 days
required: false,
force: false
},
testdummy: { testdummy: {
name: 'testdummy', name: 'testdummy',
bit: 28, bit: 28,
@ -387,7 +363,6 @@ main.deployments = {
main.deploys = [ main.deploys = [
main.deployments.csv, main.deployments.csv,
main.deployments.segwit, main.deployments.segwit,
main.deployments.segsignal,
main.deployments.testdummy main.deployments.testdummy
]; ];
@ -398,7 +373,7 @@ main.deploys = [
*/ */
main.keyPrefix = { main.keyPrefix = {
privkey: 0x80, privkey: 0xb0,
xpubkey: 0x0488b21e, xpubkey: 0x0488b21e,
xprivkey: 0x0488ade4, xprivkey: 0x0488ade4,
xpubkey58: 'xpub', xpubkey58: 'xpub',
@ -412,11 +387,12 @@ main.keyPrefix = {
*/ */
main.addressPrefix = { main.addressPrefix = {
pubkeyhash: 0x00, pubkeyhash: 0x30,
scripthash: 0x05, scripthash: 0x05,
scripthash2: 0x32,
witnesspubkeyhash: 0x06, witnesspubkeyhash: 0x06,
witnessscripthash: 0x0a, witnessscripthash: 0x0a,
bech32: 'bc' bech32: 'ltc'
}; };
/** /**
@ -434,7 +410,7 @@ main.requireStandard = true;
* @default * @default
*/ */
main.rpcPort = 8332; main.rpcPort = 9332;
/** /**
* Default min relay rate. * Default min relay rate.
@ -442,7 +418,7 @@ main.rpcPort = 8332;
* @default * @default
*/ */
main.minRelay = 1000; main.minRelay = 10000;
/** /**
* Default normal relay rate. * Default normal relay rate.
@ -450,7 +426,7 @@ main.minRelay = 1000;
* @default * @default
*/ */
main.feeRate = 100000; main.feeRate = 1000000;
/** /**
* Maximum normal relay rate. * Maximum normal relay rate.
@ -458,7 +434,7 @@ main.feeRate = 100000;
* @default * @default
*/ */
main.maxFeeRate = 400000; main.maxFeeRate = 4000000;
/** /**
* Whether to allow self-connection. * Whether to allow self-connection.
@ -484,85 +460,69 @@ const testnet = {};
testnet.type = 'testnet'; testnet.type = 'testnet';
testnet.seeds = [ testnet.seeds = [
'testnet-seed.bitcoin.jonasschnelli.ch', // Jonas Schnelli 'testnet-seed.litecointools.com',
'seed.tbtc.petertodd.org', // Peter Todd 'seed-b.litecoin.loshan.co.uk',
'testnet-seed.bluematt.me', // Matt Corallo 'dnsseed-testnet.thrasher.io'
'testnet-seed.bitcoin.schildbach.de' // Andreas Schildbach
]; ];
testnet.magic = 0x0709110b; testnet.magic = 0xf1c8d2fd;
testnet.port = 18333; testnet.port = 19335;
testnet.checkpointMap = { testnet.checkpointMap = {
546: '70cb6af7ebbcb1315d3414029c556c55f3e2fc353c4c9063a76c932a00000000', 2056: '8932a8789c96c516d8a1080a29c7e7e387d2397a83864f9adcaf97ba318a7417',
10000: '02a1b43f52591e53b660069173ac83b675798e12599dbb0442b7580000000000',
100000: '1e0a16bbadccde1d80c66597b1939e45f91b570d29f95fc158299e0000000000',
170000: '508125560d202b89757889bb0e49c712477be20440058f05db4f0e0000000000',
210000: '32365454b5f29a826bff8ad9b0448cad0072fc73d50e482d91a3dece00000000',
300000: 'a141bf3972424853f04367b47995e220e0b5a2706e5618766f22000000000000',
390000: 'f217e183484fb6d695609cc71fa2ae24c3020943407e0150b298030000000000',
420000: 'de9e73a3b91fbb014e036e8583a17d6b638a699aeb2de8573d12580800000000',
500000: '06f60922a2aab2757317820fc6ffaf6a470e2cbb0f63a2aac0a7010000000000',
630000: 'bbbe117035432a6a4effcb297207a02b031735b43e0d19a9217c000000000000',
700000: 'c14d3f6a1e7c7d66fd940951e44f3c3be1273bea4d2ab1786140000000000000',
780000: '0381582e34c3755964dc2813e2b33e521e5596367144e1670851050000000000',
840000: 'dac1648107bd4394e57e4083c86d42b548b1cfb119665f179ea80a0000000000',
900000: '9bd8ac418beeb1a2cf5d68c8b5c6ebaa947a5b766e5524898d6f350000000000',
1050000: 'd8190cf0af7f08e179cab51d67db0b44b87951a78f7fdc31b4a01a0000000000'
}; };
testnet.lastCheckpoint = 1050000; testnet.lastCheckpoint = 2056;
testnet.halvingInterval = 210000; testnet.halvingInterval = 840000;
testnet.genesis = { testnet.genesis = {
version: 1, version: 1,
hash: '43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000', hash: 'a0293e4eeb3da6e6f56f81ed595f57880d1a21569e13eefdd951284b5a626649',
prevBlock: '0000000000000000000000000000000000000000000000000000000000000000', prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
merkleRoot: merkleRoot: 'd9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97',
'3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', time: 1486949366,
time: 1296688602, bits: 504365040,
bits: 486604799, nonce: 293345,
nonce: 414098458,
height: 0 height: 0
}; };
testnet.genesisBlock = testnet.genesisBlock =
'0100000000000000000000000000000000000000000000000000000000000000000000' '010000000000000000000000000000000000000000000000000000000000000000000'
+ '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5' + '000d9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97f6'
+ '494dffff001d1aa4ae1801010000000100000000000000000000000000000000000000' + '0ba158f0ff0f1ee179040001010000000100000000000000000000000000000000000'
+ '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573' + '00000000000000000000000000000ffffffff4804ffff001d0104404e592054696d65'
+ '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66' + '732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997'
+ '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01' + '320566973696f6e6172792c2044696573206174203536ffffffff0100f2052a010000'
+ '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f' + '004341040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3e'
+ '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f' + 'b4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9ac'
+ 'ac00000000'; + '00000000';
testnet.pow = { testnet.pow = {
limit: new BN( limit: new BN(
'00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff', '00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
'hex' 'hex'
), ),
bits: 486604799, bits: 504365055,
chainwork: new BN( chainwork: new BN(
'0000000000000000000000000000000000000000000000286d17360c5492b2c4', '0000000000000000000000000000000000000000000000000000364b0cbc3568',
'hex' 'hex'
), ),
targetTimespan: 14 * 24 * 60 * 60, targetTimespan: 3.5 * 24 * 60 * 60,
targetSpacing: 10 * 60, targetSpacing: 2.5 * 60,
retargetInterval: 2016, retargetInterval: 2016,
targetReset: true, targetReset: true,
noRetargeting: false noRetargeting: false
}; };
testnet.block = { testnet.block = {
bip34height: 21111, bip34height: 76,
bip34hash: 'f88ecd9912d00d3f5c2a8e0f50417d3e415c75b3abe584346da9b32300000000', bip34hash: '73058ccc33da8b5479e3548c3cce4fb32a705fa9803994fd5f498bed71c77580',
bip65height: 581885, bip65height: 76,
bip65hash: 'b61e864fbec41dfaf09da05d1d76dc068b0dd82ee7982ff255667f0000000000', bip65hash: '73058ccc33da8b5479e3548c3cce4fb32a705fa9803994fd5f498bed71c77580',
bip66height: 330776, bip66height: 76,
bip66hash: '82a14b9e5ea81d4832b8e2cd3c2a6092b5a3853285a8995ec4c8042100000000', bip66hash: '73058ccc33da8b5479e3548c3cce4fb32a705fa9803994fd5f498bed71c77580',
pruneAfterHeight: 1000, pruneAfterHeight: 1000,
keepBlocks: 10000, keepBlocks: 10000,
maxTipAge: 24 * 60 * 60, maxTipAge: 24 * 60 * 60,
@ -579,8 +539,8 @@ testnet.deployments = {
csv: { csv: {
name: 'csv', name: 'csv',
bit: 0, bit: 0,
startTime: 1456790400, // March 1st, 2016 startTime: 1483228800, // March 1st, 2016
timeout: 1493596800, // May 1st, 2017 timeout: 1517356801, // May 1st, 2017
threshold: -1, threshold: -1,
window: -1, window: -1,
required: false, required: false,
@ -589,23 +549,13 @@ testnet.deployments = {
segwit: { segwit: {
name: 'segwit', name: 'segwit',
bit: 1, bit: 1,
startTime: 1462060800, // May 1st 2016 startTime: 1483228800, // May 1st 2016
timeout: 1493596800, // May 1st 2017 timeout: 1517356801, // May 1st 2017
threshold: -1, threshold: -1,
window: -1, window: -1,
required: true, required: true,
force: false force: false
}, },
segsignal: {
name: 'segsignal',
bit: 4,
startTime: 0xffffffff,
timeout: 0xffffffff,
threshold: 269,
window: 336,
required: false,
force: false
},
testdummy: { testdummy: {
name: 'testdummy', name: 'testdummy',
bit: 28, bit: 28,
@ -621,7 +571,6 @@ testnet.deployments = {
testnet.deploys = [ testnet.deploys = [
testnet.deployments.csv, testnet.deployments.csv,
testnet.deployments.segwit, testnet.deployments.segwit,
testnet.deployments.segsignal,
testnet.deployments.testdummy testnet.deployments.testdummy
]; ];
@ -629,22 +578,23 @@ testnet.keyPrefix = {
privkey: 0xef, privkey: 0xef,
xpubkey: 0x043587cf, xpubkey: 0x043587cf,
xprivkey: 0x04358394, xprivkey: 0x04358394,
xpubkey58: 'tpub', xpubkey58: 'xpub',
xprivkey58: 'tprv', xprivkey58: 'xprv',
coinType: 1 coinType: 1
}; };
testnet.addressPrefix = { testnet.addressPrefix = {
pubkeyhash: 0x6f, pubkeyhash: 0x6f,
scripthash: 0xc4, scripthash: 0xc4,
scripthash2: 0x3a,
witnesspubkeyhash: 0x03, witnesspubkeyhash: 0x03,
witnessscripthash: 0x28, witnessscripthash: 0x28,
bech32: 'tb' bech32: 'tltc'
}; };
testnet.requireStandard = false; testnet.requireStandard = false;
testnet.rpcPort = 18332; testnet.rpcPort = 19332;
testnet.minRelay = 1000; testnet.minRelay = 1000;
@ -670,7 +620,7 @@ regtest.seeds = [
regtest.magic = 0xdab5bffa; regtest.magic = 0xdab5bffa;
regtest.port = 48444; regtest.port = 19444;
regtest.checkpointMap = {}; regtest.checkpointMap = {};
regtest.lastCheckpoint = 0; regtest.lastCheckpoint = 0;
@ -679,26 +629,25 @@ regtest.halvingInterval = 150;
regtest.genesis = { regtest.genesis = {
version: 1, version: 1,
hash: '06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f', hash: 'f916c456fc51df627885d7d674ed02dc88a225adb3f02ad13eb4938ff3270853',
prevBlock: '0000000000000000000000000000000000000000000000000000000000000000', prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
merkleRoot: merkleRoot: 'd9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97',
'3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a',
time: 1296688602, time: 1296688602,
bits: 545259519, bits: 545259519,
nonce: 2, nonce: 0,
height: 0 height: 0
}; };
regtest.genesisBlock = regtest.genesisBlock =
'0100000000000000000000000000000000000000000000000000000000000000000000' '010000000000000000000000000000000000000000000000000000000000000000000'
+ '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5' + '000d9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97da'
+ '494dffff7f200200000001010000000100000000000000000000000000000000000000' + 'e5494dffff7f200000000001010000000100000000000000000000000000000000000'
+ '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573' + '00000000000000000000000000000ffffffff4804ffff001d0104404e592054696d65'
+ '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66' + '732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997'
+ '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01' + '320566973696f6e6172792c2044696573206174203536ffffffff0100f2052a010000'
+ '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f' + '004341040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3e'
+ '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f' + 'b4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9ac'
+ 'ac00000000'; + '00000000';
regtest.pow = { regtest.pow = {
limit: new BN( limit: new BN(
@ -707,18 +656,18 @@ regtest.pow = {
), ),
bits: 545259519, bits: 545259519,
chainwork: new BN( chainwork: new BN(
'0000000000000000000000000000000000000000000000000000000000000002', '0000000000000000000000000000000000000000000000000000000000000000',
'hex' 'hex'
), ),
targetTimespan: 14 * 24 * 60 * 60, targetTimespan: 3.5 * 24 * 60 * 60,
targetSpacing: 10 * 60, targetSpacing: 2.5 * 60,
retargetInterval: 2016, retargetInterval: 2016,
targetReset: true, targetReset: true,
noRetargeting: true noRetargeting: true
}; };
regtest.block = { regtest.block = {
bip34height: 100000000, bip34height: 0xffffffff,
bip34hash: null, bip34hash: null,
bip65height: 1351, bip65height: 1351,
bip65hash: null, bip65hash: null,
@ -757,16 +706,6 @@ regtest.deployments = {
required: true, required: true,
force: false force: false
}, },
segsignal: {
name: 'segsignal',
bit: 4,
startTime: 0xffffffff,
timeout: 0xffffffff,
threshold: 269,
window: 336,
required: false,
force: false
},
testdummy: { testdummy: {
name: 'testdummy', name: 'testdummy',
bit: 28, bit: 28,
@ -782,30 +721,30 @@ regtest.deployments = {
regtest.deploys = [ regtest.deploys = [
regtest.deployments.csv, regtest.deployments.csv,
regtest.deployments.segwit, regtest.deployments.segwit,
regtest.deployments.segsignal,
regtest.deployments.testdummy regtest.deployments.testdummy
]; ];
regtest.keyPrefix = { regtest.keyPrefix = {
privkey: 0x5a, privkey: 0xef,
xpubkey: 0xeab4fa05, xpubkey: 0x043587cf,
xprivkey: 0xeab404c7, xprivkey: 0x04358394,
xpubkey58: 'rpub', xpubkey58: 'xpub',
xprivkey58: 'rprv', xprivkey58: 'xprv',
coinType: 1 coinType: 1
}; };
regtest.addressPrefix = { regtest.addressPrefix = {
pubkeyhash: 0x3c, pubkeyhash: 0x6f,
scripthash: 0x26, scripthash: 0xc4,
witnesspubkeyhash: 0x7a, scripthash2: 0x3a,
witnessscripthash: 0x14, witnesspubkeyhash: 0x03,
bech32: 'rb' witnessscripthash: 0x28,
bech32: 'rltc'
}; };
regtest.requireStandard = false; regtest.requireStandard = false;
regtest.rpcPort = 48332; regtest.rpcPort = 19445;
regtest.minRelay = 1000; regtest.minRelay = 1000;
@ -873,8 +812,8 @@ simnet.pow = {
'0000000000000000000000000000000000000000000000000000000000000002', '0000000000000000000000000000000000000000000000000000000000000002',
'hex' 'hex'
), ),
targetTimespan: 14 * 24 * 60 * 60, targetTimespan: 3.5 * 24 * 60 * 60,
targetSpacing: 10 * 60, targetSpacing: 2.5 * 60,
retargetInterval: 2016, retargetInterval: 2016,
targetReset: true, targetReset: true,
noRetargeting: false noRetargeting: false

View File

@ -13,7 +13,7 @@ const random = require('../crypto/random');
const cleanse = require('../crypto/cleanse'); const cleanse = require('../crypto/cleanse');
const aes = require('../crypto/aes'); const aes = require('../crypto/aes');
const pbkdf2 = require('../crypto/pbkdf2'); const pbkdf2 = require('../crypto/pbkdf2');
const scrypt = require('../crypto/scrypt'); const scrypt = require('../crypto/scrypt').derive;
const BufferReader = require('../utils/reader'); const BufferReader = require('../utils/reader');
const StaticWriter = require('../utils/staticwriter'); const StaticWriter = require('../utils/staticwriter');
const encoding = require('../utils/encoding'); const encoding = require('../utils/encoding');

View File

@ -25,7 +25,7 @@ const server = exports;
*/ */
server.create = function create(options) { server.create = function create(options) {
const config = new Config('bcoin'); const config = new Config('lcoin');
let logger = new Logger('debug'); let logger = new Logger('debug');
config.inject(options); config.inject(options);

View File

@ -1,12 +1,12 @@
{ {
"name": "bcoin", "name": "lcoin",
"version": "1.0.0-beta.15", "version": "1.0.0-beta.15",
"description": "Bitcoin bike-shed", "description": "Litecoin bike-shed",
"license": "MIT", "license": "MIT",
"repository": "git://github.com/bcoin-org/bcoin.git", "repository": "git://github.com/bcoin-org/lcoin.git",
"homepage": "https://github.com/bcoin-org/bcoin", "homepage": "https://github.com/bcoin-org/lcoin",
"bugs": { "bugs": {
"url": "https://github.com/bcoin-org/bcoin/issues" "url": "https://github.com/bcoin-org/lcoin/issues"
}, },
"author": "Fedor Indutny <fedor@indutny.com>", "author": "Fedor Indutny <fedor@indutny.com>",
"contributors": [ "contributors": [
@ -53,10 +53,10 @@
}, },
"main": "./lib/bcoin.js", "main": "./lib/bcoin.js",
"bin": { "bin": {
"bcoin": "./bin/bcoin", "lcoin": "./bin/lcoin",
"bcoin-cli": "./bin/cli", "lcoin-cli": "./bin/cli",
"bcoin-node": "./bin/node", "lcoin-node": "./bin/node",
"bcoin-spvnode": "./bin/spvnode" "lcoin-spvnode": "./bin/spvnode"
}, },
"scripts": { "scripts": {
"clean": "rm -f {browser/,}{bcoin.js,bcoin-worker.js}", "clean": "rm -f {browser/,}{bcoin.js,bcoin-worker.js}",

View File

@ -66,44 +66,35 @@ function createGenesisBlock(options) {
const main = createGenesisBlock({ const main = createGenesisBlock({
version: 1, version: 1,
time: 1231006505, time: 1317972665,
bits: 486604799, bits: 504365040,
nonce: 2083236893 nonce: 2084524493,
flags: Buffer.from(
'NY Times 05/Oct/2011 Steve Jobs, Apples Visionary, Dies at 56',
'ascii'),
key: Buffer.from('040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9', 'hex')
}); });
const testnet = createGenesisBlock({ const testnet = createGenesisBlock({
version: 1, version: 1,
time: 1296688602, time: 1486949366,
bits: 486604799, bits: 0x1e0ffff0,
nonce: 414098458 nonce: 293345,
flags: Buffer.from(
'NY Times 05/Oct/2011 Steve Jobs, Apples Visionary, Dies at 56',
'ascii'),
key: Buffer.from('040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9', 'hex')
}); });
const regtest = createGenesisBlock({ const regtest = createGenesisBlock({
version: 1, version: 1,
time: 1296688602, time: 1296688602,
bits: 545259519, bits: 0x207fffff,
nonce: 2 nonce: 0,
}); flags: Buffer.from(
'NY Times 05/Oct/2011 Steve Jobs, Apples Visionary, Dies at 56',
const segnet3 = createGenesisBlock({ 'ascii'),
version: 1, key: Buffer.from('040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9', 'hex')
time: 1452831101,
bits: 486604799,
nonce: 0
});
const segnet4 = createGenesisBlock({
version: 1,
time: 1452831101,
bits: 503447551,
nonce: 0
});
const btcd = createGenesisBlock({
version: 1,
time: 1401292357,
bits: 545259519,
nonce: 2
}); });
util.log(main); util.log(main);
@ -112,11 +103,6 @@ util.log(testnet);
util.log(''); util.log('');
util.log(regtest); util.log(regtest);
util.log(''); util.log('');
util.log(segnet3);
util.log('');
util.log(segnet4);
util.log('');
util.log('');
util.log('main hash: %s', main.rhash()); util.log('main hash: %s', main.rhash());
util.log('main raw: %s', main.toRaw().toString('hex')); util.log('main raw: %s', main.toRaw().toString('hex'));
util.log(''); util.log('');
@ -126,11 +112,3 @@ util.log('');
util.log('regtest hash: %s', regtest.rhash()); util.log('regtest hash: %s', regtest.rhash());
util.log('regtest raw: %s', regtest.toRaw().toString('hex')); util.log('regtest raw: %s', regtest.toRaw().toString('hex'));
util.log(''); util.log('');
util.log('segnet3 hash: %s', segnet3.rhash());
util.log('segnet3 raw: %s', segnet3.toRaw().toString('hex'));
util.log('');
util.log('segnet4 hash: %s', segnet4.rhash());
util.log('segnet4 raw: %s', segnet4.toRaw().toString('hex'));
util.log('');
util.log('btcd simnet hash: %s', btcd.rhash());
util.log('btcd simnet raw: %s', btcd.toRaw().toString('hex'));

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
dir=$(dirname "$(which "$0")") dir=$(dirname "$(which "$0")")
url_main='https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/seeds/nodes_main.txt' url_main='https://raw.githubusercontent.com/litecoin-project/litecoin/master/contrib/seeds/nodes_main.txt'
url_testnet='https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/seeds/nodes_test.txt' url_testnet='https://raw.githubusercontent.com/litecoin-project/litecoin/master/contrib/seeds/nodes_test.txt'
getseeds() { getseeds() {
echo "$(curl -s "$1")" echo "$(curl -s "$1")"

View File

@ -12,7 +12,7 @@ describe('Address', function() {
const raw = 'e34cce70c86373273efcc54ce7d2a491bb4a0e84'; const raw = 'e34cce70c86373273efcc54ce7d2a491bb4a0e84';
const p2pkh = Buffer.from(raw, 'hex'); const p2pkh = Buffer.from(raw, 'hex');
const addr = Address.fromPubkeyhash(p2pkh); const addr = Address.fromPubkeyhash(p2pkh);
const expectedAddr = '1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX'; const expectedAddr = 'LfwofMun44rKk766Vcft6v9a7XPWBSppiq';
assert.strictEqual(addr.toString(), expectedAddr); assert.strictEqual(addr.toString(), expectedAddr);
}); });
@ -20,7 +20,7 @@ describe('Address', function() {
const raw = '0ef030107fd26e0b6bf40512bca2ceb1dd80adaa'; const raw = '0ef030107fd26e0b6bf40512bca2ceb1dd80adaa';
const p2pkh = Buffer.from(raw, 'hex'); const p2pkh = Buffer.from(raw, 'hex');
const addr = Address.fromPubkeyhash(p2pkh); const addr = Address.fromPubkeyhash(p2pkh);
const expectedAddr = '12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG'; const expectedAddr = 'LLawTSFdhuPKGSotr5KpwS4rGdkB7J9vLq';
assert.strictEqual(addr.toString(), expectedAddr); assert.strictEqual(addr.toString(), expectedAddr);
}); });
@ -90,7 +90,7 @@ describe('Address', function() {
const raw = '751e76e8199196d454941c45d1b3a323f1433bd6'; const raw = '751e76e8199196d454941c45d1b3a323f1433bd6';
const p2wpkh = Buffer.from(raw, 'hex'); const p2wpkh = Buffer.from(raw, 'hex');
const addr = Address.fromWitnessPubkeyhash(p2wpkh); const addr = Address.fromWitnessPubkeyhash(p2wpkh);
const expectedAddr = 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4'; const expectedAddr = 'ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9';
assert.strictEqual(addr.toString(), expectedAddr); assert.strictEqual(addr.toString(), expectedAddr);
}); });
@ -102,14 +102,14 @@ describe('Address', function() {
+ 'b8c6329604903262', 'hex'); + 'b8c6329604903262', 'hex');
const addr = Address.fromWitnessScripthash(p2wpkh); const addr = Address.fromWitnessScripthash(p2wpkh);
assert.strictEqual(addr.toString(), assert.strictEqual(addr.toString(),
'bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3'); 'ltc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qmu8tk5');
}); });
it('should match testnet segwit p2wpkh v0 address', () => { it('should match testnet segwit p2wpkh v0 address', () => {
const raw = '751e76e8199196d454941c45d1b3a323f1433bd6'; const raw = '751e76e8199196d454941c45d1b3a323f1433bd6';
const p2wpkh = Buffer.from(raw, 'hex'); const p2wpkh = Buffer.from(raw, 'hex');
const addr = Address.fromWitnessPubkeyhash(p2wpkh, 'testnet'); const addr = Address.fromWitnessPubkeyhash(p2wpkh, 'testnet');
const expectedAddr = 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx'; const expectedAddr = 'tltc1qw508d6qejxtdg4y5r3zarvary0c5xw7klfsuq0';
assert.strictEqual(addr.toString(), expectedAddr); assert.strictEqual(addr.toString(), expectedAddr);
}); });
@ -121,7 +121,7 @@ describe('Address', function() {
+ 'b8c6329604903262', 'hex'); + 'b8c6329604903262', 'hex');
const addr = Address.fromWitnessScripthash(p2wpkh, 'testnet'); const addr = Address.fromWitnessScripthash(p2wpkh, 'testnet');
assert.strictEqual(addr.toString(), assert.strictEqual(addr.toString(),
'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7'); 'tltc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qsnr4fp');
}); });
it('should match testnet segwit p2pwsh v0 address 2', () => { it('should match testnet segwit p2pwsh v0 address 2', () => {
@ -132,7 +132,7 @@ describe('Address', function() {
+ '4d165dab93e86433', 'hex'); + '4d165dab93e86433', 'hex');
const addr = Address.fromWitnessScripthash(p2wpkh, 'testnet'); const addr = Address.fromWitnessScripthash(p2wpkh, 'testnet');
assert.strictEqual(addr.toString(), assert.strictEqual(addr.toString(),
'tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy'); 'tltc1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesu9tmgm');
}); });
it('should handle invalid segwit hrp', () => { it('should handle invalid segwit hrp', () => {

View File

@ -42,14 +42,14 @@ const validChecksums = [
const validAddresses = [ const validAddresses = [
[ [
'BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'LTC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KGMN4N9',
Buffer.from([ Buffer.from([
0x00, 0x14, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x00, 0x14, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54,
0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6
]) ])
], ],
[ [
'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'tltc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qsnr4fp',
Buffer.from([ Buffer.from([
0x00, 0x20, 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04, 0x00, 0x20, 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04,
0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x6c, 0x98, 0x56, 0x78, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x6c, 0x98, 0x56, 0x78,
@ -58,8 +58,7 @@ const validAddresses = [
]) ])
], ],
[ [
'bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw50' 'ltc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k0tul4w',
+ '8d6qejxtdg4y5r3zarvary0c5xw7k7grplx',
Buffer.from([ Buffer.from([
0x81, 0x28, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x81, 0x28, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54,
0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6,
@ -68,20 +67,20 @@ const validAddresses = [
]) ])
], ],
[ [
'BC1SW50QA3JX3S', 'LTC1SW50QZGYDF5',
Buffer.from([ Buffer.from([
0x90, 0x02, 0x75, 0x1e 0x90, 0x02, 0x75, 0x1e
]) ])
], ],
[ [
'bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj', 'ltc1zw508d6qejxtdg4y5r3zarvaryvdzur3w',
Buffer.from([ Buffer.from([
0x82, 0x10, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x82, 0x10, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54,
0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23
]) ])
], ],
[ [
'tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy', 'tltc1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesu9tmgm',
Buffer.from([ Buffer.from([
0x00, 0x20, 0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62, 0x21, 0x00, 0x20, 0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62, 0x21,
0xb2, 0xa1, 0x87, 0x90, 0x5e, 0x52, 0x66, 0x36, 0x2b, 0x99, 0xd5, 0xb2, 0xa1, 0x87, 0x90, 0x5e, 0x52, 0x66, 0x36, 0x2b, 0x99, 0xd5,
@ -144,7 +143,7 @@ describe('Bech32', function() {
for (const [addr, script] of validAddresses) { for (const [addr, script] of validAddresses) {
it(`should have valid address for ${addr}`, () => { it(`should have valid address for ${addr}`, () => {
let hrp = 'bc'; let hrp = 'ltc';
let ret = null; let ret = null;
try { try {
@ -154,7 +153,7 @@ describe('Bech32', function() {
} }
if (ret === null) { if (ret === null) {
hrp = 'tb'; hrp = 'tltc';
try { try {
ret = fromAddress(hrp, addr); ret = fromAddress(hrp, addr);
} catch (e) { } catch (e) {
@ -174,8 +173,8 @@ describe('Bech32', function() {
for (const addr of invalidAddresses) { for (const addr of invalidAddresses) {
it(`should have invalid address for ${addr}`, () => { it(`should have invalid address for ${addr}`, () => {
assert.throws(() => fromAddress('bc', addr)); assert.throws(() => fromAddress('ltc', addr));
assert.throws(() => fromAddress('tb', addr)); assert.throws(() => fromAddress('tltc', addr));
}); });
} }

View File

@ -72,8 +72,8 @@ const op4 = new Outpoint(
'b7c3c4bce1a23baef2da05f9b7e4bff813449ec7e80f980ec7e4cacfadcd3314', 'b7c3c4bce1a23baef2da05f9b7e4bff813449ec7e80f980ec7e4cacfadcd3314',
300); 300);
const addr1 = new Address('bc1qmyrddmxglk49ye2wd29wefaavw7es8k5d555lx'); const addr1 = new Address('ltc1qmyrddmxglk49ye2wd29wefaavw7es8k5fgws8k');
const addr2 = new Address('bc1q4645ycu0l9pnvxaxnhemushv0w4cd9flkqh95j'); const addr2 = new Address('ltc1q4645ycu0l9pnvxaxnhemushv0w4cd9fljudpvz');
let filter1 = null; let filter1 = null;
let filter2 = null; let filter2 = null;

View File

@ -198,7 +198,7 @@ describe('HTTP', function() {
vbrequired: 0, vbrequired: 0,
height: 1, height: 1,
previousblockhash: previousblockhash:
'0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', '530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9',
target: target:
'7fffff0000000000000000000000000000000000000000000000000000000000', '7fffff0000000000000000000000000000000000000000000000000000000000',
bits: '207fffff', bits: '207fffff',
@ -210,7 +210,7 @@ describe('HTTP', function() {
sigoplimit: 20000, sigoplimit: 20000,
sizelimit: 1000000, sizelimit: 1000000,
longpollid: longpollid:
'0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206' '530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9'
+ '0000000000', + '0000000000',
submitold: false, submitold: false,
coinbaseaux: { flags: '6d696e65642062792062636f696e' }, coinbaseaux: { flags: '6d696e65642062792062636f696e' },

View File

@ -55,7 +55,7 @@ describe('Input', function() {
const prevout = input.prevout.toRaw(); const prevout = input.prevout.toRaw();
assert.strictEqual(type, 'pubkeyhash'); assert.strictEqual(type, 'pubkeyhash');
assert.strictEqual(addr, '1PM9ZgAV8Z4df1md2zRTF98tPjzTAfk2a6'); assert.strictEqual(addr, 'Lha6ptUKDDJgupTnD8QkXACebxMjFtmfTg');
assert.strictEqual(input.isCoinbase(), false); assert.strictEqual(input.isCoinbase(), false);
assert.strictEqual(input.isFinal(), true); assert.strictEqual(input.isFinal(), true);

View File

@ -7,10 +7,10 @@ const assert = require('./util/assert');
const KeyRing = require('../lib/primitives/keyring'); const KeyRing = require('../lib/primitives/keyring');
const uncompressed = KeyRing.fromSecret( const uncompressed = KeyRing.fromSecret(
'5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss'); '6vrJ6bnKwaSuimkkRLpNNziSjqwZCG59kfFC9P2kjbUUs5Y6Cw9');
const compressed = KeyRing.fromSecret( const compressed = KeyRing.fromSecret(
'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1'); 'TAgaTiX4btdMhNY6eSU5N5jvc71o6hXKdhoeBzEk31AHykGDou8i');
describe('KeyRing', function() { describe('KeyRing', function() {
it('should get uncompressed public key', () => { it('should get uncompressed public key', () => {
@ -22,13 +22,13 @@ describe('KeyRing', function() {
it('should get uncompressed public key address', () => { it('should get uncompressed public key address', () => {
assert.strictEqual( assert.strictEqual(
'1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN', 'Lbnu1x4UfToiiFGU8MvPrLpj2GSrtUrxFH',
uncompressed.getKeyAddress('base58')); uncompressed.getKeyAddress('base58'));
}); });
it('should get uncompressed WIF', () => { it('should get uncompressed WIF', () => {
assert.strictEqual( assert.strictEqual(
'5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss', '6vrJ6bnKwaSuimkkRLpNNziSjqwZCG59kfFC9P2kjbUUs5Y6Cw9',
uncompressed.toSecret()); uncompressed.toSecret());
}); });
@ -40,13 +40,13 @@ describe('KeyRing', function() {
it('should get compressed public key address', () => { it('should get compressed public key address', () => {
assert.strictEqual( assert.strictEqual(
'1F3sAm6ZtwLAUnj7d38pGFxtP3RVEvtsbV', 'LZGpRyQPybaDjbRGoB87YH2ebFnmKYmRui',
compressed.getKeyAddress('base58')); compressed.getKeyAddress('base58'));
}); });
it('should get compressed WIF', () => { it('should get compressed WIF', () => {
assert.strictEqual( assert.strictEqual(
'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1', 'TAgaTiX4btdMhNY6eSU5N5jvc71o6hXKdhoeBzEk31AHykGDou8i',
compressed.toSecret()); compressed.toSecret());
}); });
}); });

View File

@ -49,7 +49,7 @@ function dummyInput(script, hash) {
const fund = new MTX(); const fund = new MTX();
fund.addCoin(coin); fund.addCoin(coin);
fund.addOutput(script, 70000); fund.addOutput(script, 700000);
const [tx, view] = fund.commit(); const [tx, view] = fund.commit();
@ -72,55 +72,55 @@ describe('Mempool', function() {
const key = KeyRing.generate(); const key = KeyRing.generate();
const t1 = new MTX(); const t1 = new MTX();
t1.addOutput(wallet.getAddress(), 50000); t1.addOutput(wallet.getAddress(), 500000);
t1.addOutput(wallet.getAddress(), 10000); t1.addOutput(wallet.getAddress(), 100000);
const script = Script.fromPubkey(key.publicKey); const script = Script.fromPubkey(key.publicKey);
t1.addCoin(dummyInput(script, encoding.ONE_HASH.toString('hex'))); t1.addCoin(dummyInput(script, encoding.ONE_HASH.toString('hex')));
const sig = t1.signature(0, script, 70000, key.privateKey, ALL, 0); const sig = t1.signature(0, script, 700000, key.privateKey, ALL, 0);
t1.inputs[0].script = Script.fromItems([sig]); t1.inputs[0].script = Script.fromItems([sig]);
// balance: 51000 // balance: 510000
wallet.sign(t1); wallet.sign(t1);
const t2 = new MTX(); const t2 = new MTX();
t2.addTX(t1, 0); // 50000 t2.addTX(t1, 0); // 500000
t2.addOutput(wallet.getAddress(), 20000); t2.addOutput(wallet.getAddress(), 200000);
t2.addOutput(wallet.getAddress(), 20000); t2.addOutput(wallet.getAddress(), 200000);
// balance: 49000 // balance: 4900000
wallet.sign(t2); wallet.sign(t2);
const t3 = new MTX(); const t3 = new MTX();
t3.addTX(t1, 1); // 10000 t3.addTX(t1, 1); // 100000
t3.addTX(t2, 0); // 20000 t3.addTX(t2, 0); // 200000
t3.addOutput(wallet.getAddress(), 23000); t3.addOutput(wallet.getAddress(), 230000);
// balance: 47000 // balance: 470000
wallet.sign(t3); wallet.sign(t3);
const t4 = new MTX(); const t4 = new MTX();
t4.addTX(t2, 1); // 24000 t4.addTX(t2, 1); // 240000
t4.addTX(t3, 0); // 23000 t4.addTX(t3, 0); // 230000
t4.addOutput(wallet.getAddress(), 11000); t4.addOutput(wallet.getAddress(), 110000);
t4.addOutput(wallet.getAddress(), 11000); t4.addOutput(wallet.getAddress(), 110000);
// balance: 22000 // balance: 220000
wallet.sign(t4); wallet.sign(t4);
const f1 = new MTX(); const f1 = new MTX();
f1.addTX(t4, 1); // 11000 f1.addTX(t4, 1); // 110000
f1.addOutput(new Address(), 9000); f1.addOutput(new Address(), 90000);
// balance: 11000 // balance: 110000
wallet.sign(f1); wallet.sign(f1);
const fake = new MTX(); const fake = new MTX();
fake.addTX(t1, 1); // 1000 (already redeemed) fake.addTX(t1, 1); // 10000 (already redeemed)
fake.addOutput(wallet.getAddress(), 6000); // 6000 instead of 500 fake.addOutput(wallet.getAddress(), 60000); // 60000 instead of 5000
// Script inputs but do not sign // Script inputs but do not sign
wallet.template(fake); wallet.template(fake);
@ -129,42 +129,42 @@ describe('Mempool', function() {
const input = fake.inputs[0]; const input = fake.inputs[0];
input.script.setData(0, encoding.ZERO_SIG); input.script.setData(0, encoding.ZERO_SIG);
input.script.compile(); input.script.compile();
// balance: 11000 // balance: 110000
{ {
await mempool.addTX(fake.toTX()); await mempool.addTX(fake.toTX());
await mempool.addTX(t4.toTX()); await mempool.addTX(t4.toTX());
const balance = mempool.getBalance(); const balance = mempool.getBalance();
assert.strictEqual(balance, 70000); assert.strictEqual(balance, 700000);
} }
{ {
await mempool.addTX(t1.toTX()); await mempool.addTX(t1.toTX());
const balance = mempool.getBalance(); const balance = mempool.getBalance();
assert.strictEqual(balance, 60000); assert.strictEqual(balance, 600000);
} }
{ {
await mempool.addTX(t2.toTX()); await mempool.addTX(t2.toTX());
const balance = mempool.getBalance(); const balance = mempool.getBalance();
assert.strictEqual(balance, 50000); assert.strictEqual(balance, 500000);
} }
{ {
await mempool.addTX(t3.toTX()); await mempool.addTX(t3.toTX());
const balance = mempool.getBalance(); const balance = mempool.getBalance();
assert.strictEqual(balance, 22000); assert.strictEqual(balance, 220000);
} }
{ {
await mempool.addTX(f1.toTX()); await mempool.addTX(f1.toTX());
const balance = mempool.getBalance(); const balance = mempool.getBalance();
assert.strictEqual(balance, 20000); assert.strictEqual(balance, 200000);
} }
const txs = mempool.getHistory(); const txs = mempool.getHistory();
@ -177,8 +177,8 @@ describe('Mempool', function() {
const key = KeyRing.generate(); const key = KeyRing.generate();
const tx = new MTX(); const tx = new MTX();
tx.addOutput(wallet.getAddress(), 50000); tx.addOutput(wallet.getAddress(), 500000);
tx.addOutput(wallet.getAddress(), 10000); tx.addOutput(wallet.getAddress(), 100000);
const prev = Script.fromPubkey(key.publicKey); const prev = Script.fromPubkey(key.publicKey);
const prevHash = random.randomBytes(32).toString('hex'); const prevHash = random.randomBytes(32).toString('hex');
@ -188,7 +188,7 @@ describe('Mempool', function() {
chain.tip.height = 200; chain.tip.height = 200;
const sig = tx.signature(0, prev, 70000, key.privateKey, ALL, 0); const sig = tx.signature(0, prev, 700000, key.privateKey, ALL, 0);
tx.inputs[0].script = Script.fromItems([sig]); tx.inputs[0].script = Script.fromItems([sig]);
await mempool.addTX(tx.toTX()); await mempool.addTX(tx.toTX());
@ -199,8 +199,8 @@ describe('Mempool', function() {
const key = KeyRing.generate(); const key = KeyRing.generate();
const tx = new MTX(); const tx = new MTX();
tx.addOutput(wallet.getAddress(), 50000); tx.addOutput(wallet.getAddress(), 500000);
tx.addOutput(wallet.getAddress(), 10000); tx.addOutput(wallet.getAddress(), 100000);
const prev = Script.fromPubkey(key.publicKey); const prev = Script.fromPubkey(key.publicKey);
const prevHash = random.randomBytes(32).toString('hex'); const prevHash = random.randomBytes(32).toString('hex');
@ -209,7 +209,7 @@ describe('Mempool', function() {
tx.setLocktime(200); tx.setLocktime(200);
chain.tip.height = 200 - 1; chain.tip.height = 200 - 1;
const sig = tx.signature(0, prev, 70000, key.privateKey, ALL, 0); const sig = tx.signature(0, prev, 700000, key.privateKey, ALL, 0);
tx.inputs[0].script = Script.fromItems([sig]); tx.inputs[0].script = Script.fromItems([sig]);
let err; let err;
@ -230,8 +230,8 @@ describe('Mempool', function() {
key.witness = true; key.witness = true;
const tx = new MTX(); const tx = new MTX();
tx.addOutput(wallet.getAddress(), 50000); tx.addOutput(wallet.getAddress(), 500000);
tx.addOutput(wallet.getAddress(), 10000); tx.addOutput(wallet.getAddress(), 100000);
const prev = Script.fromProgram(0, key.getKeyHash()); const prev = Script.fromProgram(0, key.getKeyHash());
const prevHash = random.randomBytes(32).toString('hex'); const prevHash = random.randomBytes(32).toString('hex');
@ -240,7 +240,7 @@ describe('Mempool', function() {
const prevs = Script.fromPubkeyhash(key.getKeyHash()); const prevs = Script.fromPubkeyhash(key.getKeyHash());
const sig = tx.signature(0, prevs, 70000, key.privateKey, ALL, 1); const sig = tx.signature(0, prevs, 700000, key.privateKey, ALL, 1);
sig[sig.length - 1] = 0; sig[sig.length - 1] = 0;
tx.inputs[0].witness = new Witness([sig, key.publicKey]); tx.inputs[0].witness = new Witness([sig, key.publicKey]);
@ -260,15 +260,15 @@ describe('Mempool', function() {
const key = KeyRing.generate(); const key = KeyRing.generate();
const tx = new MTX(); const tx = new MTX();
tx.addOutput(wallet.getAddress(), 50000); tx.addOutput(wallet.getAddress(), 500000);
tx.addOutput(wallet.getAddress(), 10000); tx.addOutput(wallet.getAddress(), 100000);
const prev = Script.fromPubkey(key.publicKey); const prev = Script.fromPubkey(key.publicKey);
const prevHash = random.randomBytes(32).toString('hex'); const prevHash = random.randomBytes(32).toString('hex');
tx.addCoin(dummyInput(prev, prevHash)); tx.addCoin(dummyInput(prev, prevHash));
const sig = tx.signature(0, prev, 70000, key.privateKey, ALL, 0); const sig = tx.signature(0, prev, 700000, key.privateKey, ALL, 0);
tx.inputs[0].script = Script.fromItems([sig]); tx.inputs[0].script = Script.fromItems([sig]);
tx.inputs[0].witness.push(Buffer.alloc(0)); tx.inputs[0].witness.push(Buffer.alloc(0));
@ -289,8 +289,8 @@ describe('Mempool', function() {
key.witness = true; key.witness = true;
const tx = new MTX(); const tx = new MTX();
tx.addOutput(wallet.getAddress(), 50000); tx.addOutput(wallet.getAddress(), 500000);
tx.addOutput(wallet.getAddress(), 10000); tx.addOutput(wallet.getAddress(), 100000);
const prev = Script.fromProgram(0, key.getKeyHash()); const prev = Script.fromProgram(0, key.getKeyHash());
const prevHash = random.randomBytes(32).toString('hex'); const prevHash = random.randomBytes(32).toString('hex');
@ -313,8 +313,8 @@ describe('Mempool', function() {
const key = KeyRing.generate(); const key = KeyRing.generate();
const tx = new MTX(); const tx = new MTX();
tx.addOutput(wallet.getAddress(), 50000); tx.addOutput(wallet.getAddress(), 500000);
tx.addOutput(wallet.getAddress(), 10000); tx.addOutput(wallet.getAddress(), 100000);
const prev = Script.fromPubkey(key.publicKey); const prev = Script.fromPubkey(key.publicKey);
const prevHash = random.randomBytes(32).toString('hex'); const prevHash = random.randomBytes(32).toString('hex');
@ -338,7 +338,7 @@ describe('Mempool', function() {
it('should clear reject cache', async () => { it('should clear reject cache', async () => {
const tx = new MTX(); const tx = new MTX();
tx.addOutpoint(new Outpoint()); tx.addOutpoint(new Outpoint());
tx.addOutput(wallet.getAddress(), 50000); tx.addOutput(wallet.getAddress(), 500000);
assert(mempool.hasReject(cachedTX.hash())); assert(mempool.hasReject(cachedTX.hash()));

View File

@ -251,12 +251,12 @@ describe('Wallet', function() {
}); });
it('should validate existing address', () => { it('should validate existing address', () => {
assert(Address.fromString('1KQ1wMNwXHUYj1nV2xzsRcKUH8gVFpTFUc')); assert(Address.fromString('LdcyCZgmbwibypUeD6zAhdPEVM3mPj4zxH'));
}); });
it('should fail to validate invalid address', () => { it('should fail to validate invalid address', () => {
assert.throws(() => { assert.throws(() => {
Address.fromString('1KQ1wMNwXHUYj1nv2xzsRcKUH8gVFpTFUc'); Address.fromString('LdcyCZgmbwibypueD6zAhdPEVM3mPj4zxH');
}); });
}); });