Litecoin: litecoinify
This commit is contained in:
parent
d489238711
commit
4e7675cc7a
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ docker_data/
|
||||
browser/bcoin*
|
||||
package-lock.json
|
||||
npm-debug.log
|
||||
.DS_Store
|
||||
|
||||
16
README.md
16
README.md
@ -1,4 +1,4 @@
|
||||
# Bcoin
|
||||
# Lcoin (Bcoin ported to Litecoin)
|
||||
|
||||
__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
|
||||
@ -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.
|
||||
|
||||
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
|
||||
|
||||
- Full Node
|
||||
@ -27,10 +23,10 @@ Try it in the browser: http://bcoin.io/browser.html
|
||||
## Install
|
||||
|
||||
```
|
||||
$ git clone git://github.com/bcoin-org/bcoin.git
|
||||
$ cd bcoin
|
||||
$ git clone git://github.com/bcoin-org/lcoin.git
|
||||
$ cd lcoin
|
||||
$ npm install
|
||||
$ ./bin/bcoin
|
||||
$ ./bin/lcoin
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
money.
|
||||
|
||||
|
||||
4
bin/cli
4
bin/cli
@ -12,14 +12,14 @@ const ANTIREPLAY = ''
|
||||
+ '220456c656374726f6e696320436173682053797374656d';
|
||||
|
||||
function CLI() {
|
||||
this.config = new Config('bcoin');
|
||||
this.config = new Config('lcoin');
|
||||
|
||||
this.config.load({
|
||||
argv: true,
|
||||
env: true
|
||||
});
|
||||
|
||||
this.config.open('bcoin.conf');
|
||||
this.config.open('lcoin.conf');
|
||||
|
||||
this.argv = this.config.argv;
|
||||
this.client = null;
|
||||
|
||||
2
bin/node
2
bin/node
@ -2,7 +2,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
process.title = 'bcoin';
|
||||
process.title = 'lcoin';
|
||||
|
||||
if (process.argv.indexOf('--help') !== -1
|
||||
|| process.argv.indexOf('-h') !== -1) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
process.title = 'bcoin';
|
||||
process.title = 'lcoin';
|
||||
|
||||
const assert = require('assert');
|
||||
const SPVNode = require('../lib/node/spvnode');
|
||||
|
||||
@ -12,7 +12,7 @@ const worker = fs.readFileSync(`${__dirname}/bcoin-worker.js`);
|
||||
|
||||
const proxy = new WSProxy({
|
||||
pow: process.argv.indexOf('--pow') !== -1,
|
||||
ports: [8333, 18333, 18444, 28333, 28901]
|
||||
ports: [9333, 19335, 19444, 28333, 28901]
|
||||
});
|
||||
|
||||
const server = new HTTPBase({
|
||||
|
||||
@ -2302,7 +2302,12 @@ Chain.prototype.getTarget = async function getTarget(time, prev) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
const first = await this.getAncestor(prev, height);
|
||||
|
||||
@ -98,7 +98,7 @@ URI.prototype.fromString = function fromString(str, network) {
|
||||
|
||||
const prefix = str.substring(0, 8);
|
||||
|
||||
assert(prefix === 'bitcoin:', 'Not a bitcoin URI.');
|
||||
assert(prefix === 'litecoin:', 'Not a bitcoin URI.');
|
||||
|
||||
str = str.substring(8);
|
||||
|
||||
@ -154,7 +154,7 @@ URI.fromString = function fromString(str, network) {
|
||||
*/
|
||||
|
||||
URI.prototype.toString = function toString() {
|
||||
let str = 'bitcoin:';
|
||||
let str = 'litecoin:';
|
||||
|
||||
str += this.address.toString();
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const digest = require('../crypto/digest');
|
||||
const scrypt = require('../crypto/scrypt').derive;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
while (nonce <= max) {
|
||||
// Hash and test against the next target.
|
||||
if (rcmp(digest.hash256(data), target) <= 0)
|
||||
if (rcmp(powHash(data), target) <= 0)
|
||||
return nonce;
|
||||
|
||||
// Increment the nonce to get a different hash.
|
||||
@ -40,6 +40,16 @@ function mine(data, target, min, max) {
|
||||
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
|
||||
* to waste time reversing the block hash.
|
||||
|
||||
@ -23,6 +23,7 @@ const encoding = require('../utils/encoding');
|
||||
const CoinView = require('../coins/coinview');
|
||||
const Script = require('../script/script');
|
||||
const common = require('./common');
|
||||
const scrypt = require('../crypto/scrypt').derive;
|
||||
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) {
|
||||
const root = this.getRoot(nonce1, nonce2);
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = [
|
||||
'thfsmmn2jbitcoin.onion',
|
||||
'it2pj4f7657g3rhi.onion',
|
||||
'nkf5e6b7pl4jfd4a.onion',
|
||||
'4zhkir2ofl7orfom.onion',
|
||||
't6xj6wilh4ytvcs7.onion',
|
||||
'i6y6ivorwakd7nw3.onion',
|
||||
'ubqj4rsu3nqtxmtp.onion'
|
||||
'45.33.107.92',
|
||||
'45.76.92.84',
|
||||
'47.93.81.84',
|
||||
'66.178.182.35',
|
||||
'78.47.34.228',
|
||||
'94.176.237.167',
|
||||
'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',
|
||||
];
|
||||
|
||||
@ -32,12 +32,12 @@ function Node(options) {
|
||||
|
||||
AsyncObject.call(this);
|
||||
|
||||
this.config = new Config('bcoin');
|
||||
this.config = new Config('lcoin');
|
||||
this.config.inject(options);
|
||||
this.config.load(options);
|
||||
|
||||
if (options.config)
|
||||
this.config.open('bcoin.conf');
|
||||
this.config.open('lcoin.conf');
|
||||
|
||||
this.network = Network.get(this.config.network);
|
||||
this.startTime = -1;
|
||||
|
||||
@ -15,6 +15,7 @@ const StaticWriter = require('../utils/staticwriter');
|
||||
const InvItem = require('./invitem');
|
||||
const encoding = require('../utils/encoding');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const scrypt = require('../crypto/scrypt').derive;
|
||||
|
||||
/**
|
||||
* The class which all block-like objects inherit from.
|
||||
@ -156,6 +157,17 @@ AbstractBlock.prototype.hash = function hash(enc) {
|
||||
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.
|
||||
* @returns {Buffer}
|
||||
@ -226,7 +238,7 @@ AbstractBlock.prototype.verify = function verify() {
|
||||
*/
|
||||
|
||||
AbstractBlock.prototype.verifyPOW = function verifyPOW() {
|
||||
return consensus.verifyPOW(this.hash(), this.bits);
|
||||
return consensus.verifyPOW(this.powHash(), this.bits);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -49,7 +49,8 @@ function Address(options) {
|
||||
Address.types = {
|
||||
PUBKEYHASH: 2,
|
||||
SCRIPTHASH: 3,
|
||||
WITNESS: 4
|
||||
SCRIPTHASH2: 4,
|
||||
WITNESS: 5
|
||||
};
|
||||
|
||||
/**
|
||||
@ -162,6 +163,8 @@ Address.prototype.getPrefix = function getPrefix(network) {
|
||||
return prefixes.pubkeyhash;
|
||||
case Address.types.SCRIPTHASH:
|
||||
return prefixes.scripthash;
|
||||
case Address.types.SCRIPTHASH2:
|
||||
return prefixes.scripthash2;
|
||||
case Address.types.WITNESS:
|
||||
if (this.hash.length === 20)
|
||||
return prefixes.witnesspubkeyhash;
|
||||
@ -784,7 +787,7 @@ Address.prototype.isPubkeyhash = function isPubkeyhash() {
|
||||
*/
|
||||
|
||||
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;
|
||||
case prefixes.scripthash:
|
||||
return Address.types.SCRIPTHASH;
|
||||
case prefixes.scripthash2:
|
||||
return Address.types.SCRIPTHASH2;
|
||||
case prefixes.witnesspubkeyhash:
|
||||
case prefixes.witnessscripthash:
|
||||
return Address.types.WITNESS;
|
||||
|
||||
@ -1440,6 +1440,10 @@ TX.prototype.checkSanity = function checkSanity() {
|
||||
if (output.value > consensus.MAX_MONEY)
|
||||
return [false, 'bad-txns-vout-toolarge', 100];
|
||||
|
||||
if (!util.isSafeAddition(total, output.value)) {
|
||||
return [false, 'bad-txns-txouttotal-toolarge', 100];
|
||||
}
|
||||
|
||||
total += output.value;
|
||||
|
||||
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)
|
||||
return [-1, 'bad-txns-inputvalues-outofrange', 100];
|
||||
|
||||
if (!util.isSafeAddition(total, coin.value)) {
|
||||
return [-1, 'bad-txns-inputvalues-outofrange', 100];
|
||||
}
|
||||
|
||||
total += coin.value;
|
||||
|
||||
if (total < 0 || total > consensus.MAX_MONEY)
|
||||
|
||||
@ -29,7 +29,7 @@ exports.COIN = 100000000;
|
||||
* @default
|
||||
*/
|
||||
|
||||
exports.MAX_MONEY = 21000000 * exports.COIN;
|
||||
exports.MAX_MONEY = 84000000 * exports.COIN;
|
||||
|
||||
/**
|
||||
* Base block subsidy (consensus).
|
||||
@ -216,7 +216,7 @@ exports.MAX_MULTISIG_PUBKEYS = 20;
|
||||
* @default
|
||||
*/
|
||||
|
||||
exports.BIP16_TIME = 1333238400;
|
||||
exports.BIP16_TIME = 1349049600;
|
||||
|
||||
/**
|
||||
* Convert a compact number to a big number.
|
||||
|
||||
@ -79,7 +79,6 @@ Network.type = null;
|
||||
Network.main = null;
|
||||
Network.testnet = null;
|
||||
Network.regtest = null;
|
||||
Network.segnet4 = null;
|
||||
Network.simnet = null;
|
||||
|
||||
/**
|
||||
@ -418,6 +417,7 @@ function cmpAddress(network, prefix) {
|
||||
switch (prefix) {
|
||||
case prefixes.pubkeyhash:
|
||||
case prefixes.scripthash:
|
||||
case prefixes.scripthash2:
|
||||
case prefixes.witnesspubkeyhash:
|
||||
case prefixes.witnessscripthash:
|
||||
return true;
|
||||
|
||||
@ -48,12 +48,11 @@ main.type = 'main';
|
||||
*/
|
||||
|
||||
main.seeds = [
|
||||
'seed.bitcoin.sipa.be', // Pieter Wuille
|
||||
'dnsseed.bluematt.me', // Matt Corallo
|
||||
'dnsseed.bitcoin.dashjr.org', // Luke Dashjr
|
||||
'seed.bitcoinstats.com', // Christian Decker
|
||||
'seed.bitcoin.jonasschnelli.ch', // Jonas Schnelli
|
||||
'seed.btc.petertodd.org' // Peter Todd
|
||||
'seed-a.litecoin.loshan.co.uk',
|
||||
'dnsseed.thrasher.io',
|
||||
'dnsseed.litecointools.com',
|
||||
'dnsseed.litecoinpool.org',
|
||||
'dnsseed.koin-project.com'
|
||||
];
|
||||
|
||||
/**
|
||||
@ -62,7 +61,7 @@ main.seeds = [
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.magic = 0xd9b4bef9;
|
||||
main.magic = 0xdbb6c0fb;
|
||||
|
||||
/**
|
||||
* Default network port.
|
||||
@ -70,7 +69,7 @@ main.magic = 0xd9b4bef9;
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.port = 8333;
|
||||
main.port = 9333;
|
||||
|
||||
/**
|
||||
* Checkpoint block list.
|
||||
@ -78,30 +77,22 @@ main.port = 8333;
|
||||
*/
|
||||
|
||||
main.checkpointMap = {
|
||||
11111: '1d7c6eb2fd42f55925e92efad68b61edd22fba29fde8783df744e26900000000',
|
||||
33333: 'a6d0b5df7d0df069ceb1e736a216ad187a50b07aaa4e78748a58d52d00000000',
|
||||
74000: '201a66b853f9e7814a820e2af5f5dc79c07144e31ce4c9a39339570000000000',
|
||||
105000: '97dc6b1d15fbeef373a744fee0b254b0d2c820a3ae7f0228ce91020000000000',
|
||||
134444: 'feb0d2420d4a18914c81ac30f494a5d4ff34cd15d34cfd2fb105000000000000',
|
||||
168000: '63b703835cb735cb9a89d733cbe66f212f63795e0172ea619e09000000000000',
|
||||
193000: '17138bca83bdc3e6f60f01177c3877a98266de40735f2a459f05000000000000',
|
||||
210000: '2e3471a19b8e22b7f939c63663076603cf692f19837e34958b04000000000000',
|
||||
216116: '4edf231bf170234e6a811460f95c94af9464e41ee833b4f4b401000000000000',
|
||||
225430: '32595730b165f097e7b806a679cf7f3e439040f750433808c101000000000000',
|
||||
250000: '14d2f24d29bed75354f3f88a5fb50022fc064b02291fdf873800000000000000',
|
||||
279000: '407ebde958e44190fa9e810ea1fc3a7ef601c3b0a0728cae0100000000000000',
|
||||
295000: '83a93246c67003105af33ae0b29dd66f689d0f0ff54e9b4d0000000000000000',
|
||||
300255: 'b2f3a0f0de4120c1089d5f5280a263059f9b6e7c520428160000000000000000',
|
||||
319400: '3bf115fd057391587ca39a531c5d4989e1adec9b2e05c6210000000000000000',
|
||||
343185: '548536d48e7678fcfa034202dd45d4a76b1ad061f38b2b070000000000000000',
|
||||
352940: 'ffc9520143e41c94b6e03c2fa3e62bb76b55ba2df45d75100000000000000000',
|
||||
382320: 'b28afdde92b0899715e40362f56afdb20e3d135bedc68d0a0000000000000000',
|
||||
401465: 'eed16cb3e893ed9366f27c39a9ecd95465d02e3ef40e45010000000000000000',
|
||||
420000: 'a1ff746b2d42b834cb7d6b8981b09c265c2cabc016e8cc020000000000000000',
|
||||
440000: '9bf296b8de5f834f7635d5e258a434ad51b4dbbcf7c08c030000000000000000',
|
||||
450000: '0ba2070c62cd9da1f8cef88a0648c661a411d33e728340010000000000000000',
|
||||
460000: '8c25fc7e414d3e868d6ce0ec473c30ad44e7e8bc1b75ef000000000000000000',
|
||||
470000: '89756d1ed75901437300af10d5ab69070a282e729c536c000000000000000000'
|
||||
1500: '67299ab5a20244afc95e8376d48b5fe4545ad055a707a7cf88d25d9565291a84',
|
||||
4032: '4608cfd9e3d75f9687a935fd6ae2805b720335ce05595ef00efc9871420ee99c',
|
||||
8064: '700d4394a67d98b3fc29b7f0efeeb9baa4b8400c151f6510f29051fc534398eb',
|
||||
16128: '3d15cd1c2ae103ec4b7acd9d4d1ddc6fb66c0e9b1d9f80afa6f9b75918df2e60',
|
||||
23420: '07b501510bce8f974e87ec30258fa57d54fea9c30aa9b2d20bfd1aa89cdf0fd8',
|
||||
50000: 'a6207ad0713e2b2b88323a4fdb2a6727c11904cc2d01a575f0689b02eb37dc69',
|
||||
80000: '0ae9b2cd2e186748cbbe8c6ab420f9a85599a864c7493f5000a376f6027ccb4f',
|
||||
120000: '3161ac52357a6a021b12e7e9ce298e9ec88e82325f15f0a7daf6054f92269dbd',
|
||||
161500: '43ff718479f7bb8d41b8283b12914902dc1cba777c225cf7b44b4f478098e8db',
|
||||
179620: '09f7b9782b0ba55883b2dca7e969fa2fbed70f6e448ed12604c00a995cc6d92a',
|
||||
240000: 'aa885055a13e2eab6e4e0c59c439db739c4cf23676ee17a27c15c2b4c4d14071',
|
||||
383640: '64f3c626f1c396a090057d4be94ba32751a310f1b35ec6af5b21a994f009682b',
|
||||
409004: 'a3085935f1b439cfe9770edcfb67b682d974ad95931d6108faf1d963d6187548',
|
||||
456000: '0420375624e31b407dac0105a4a64ce397f822be060d9387d46c36c61cf734bf',
|
||||
638902: '384fc7ae3bc5ec5cc49ccd3d95fc9a81a5f3fc758c9ae28dd263ece856862315',
|
||||
721000: 'e540989a758adc4116743ee6a235b2ea14b7759dd93b46e27894dfe14d7b8a19'
|
||||
};
|
||||
|
||||
/**
|
||||
@ -110,14 +101,14 @@ main.checkpointMap = {
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.lastCheckpoint = 470000;
|
||||
main.lastCheckpoint = 721000;
|
||||
|
||||
/**
|
||||
* @const {Number}
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.halvingInterval = 210000;
|
||||
main.halvingInterval = 840000;
|
||||
|
||||
/**
|
||||
* Genesis block header.
|
||||
@ -126,13 +117,12 @@ main.halvingInterval = 210000;
|
||||
|
||||
main.genesis = {
|
||||
version: 1,
|
||||
hash: '6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000',
|
||||
hash: 'e2bf047e7e5a191aa4ef34d314979dc9986e0f19251edaba5940fd1fe365a712',
|
||||
prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
|
||||
merkleRoot:
|
||||
'3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a',
|
||||
time: 1231006505,
|
||||
bits: 486604799,
|
||||
nonce: 2083236893,
|
||||
merkleRoot: 'd9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97',
|
||||
time: 1317972665,
|
||||
bits: 504365040, // 0x1e0ffff0
|
||||
nonce: 2084524493,
|
||||
height: 0
|
||||
};
|
||||
|
||||
@ -143,14 +133,13 @@ main.genesis = {
|
||||
|
||||
main.genesisBlock =
|
||||
'0100000000000000000000000000000000000000000000000000000000000000000000'
|
||||
+ '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab'
|
||||
+ '5f49ffff001d1dac2b7c01010000000100000000000000000000000000000000000000'
|
||||
+ '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573'
|
||||
+ '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66'
|
||||
+ '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01'
|
||||
+ '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f'
|
||||
+ '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f'
|
||||
+ 'ac00000000';
|
||||
+ '00d9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97b9aa'
|
||||
+ '8e4ef0ff0f1ecd513f7c01010000000100000000000000000000000000000000000000'
|
||||
+ '00000000000000000000000000ffffffff4804ffff001d0104404e592054696d657320'
|
||||
+ '30352f4f63742f32303131205374657665204a6f62732c204170706c65e28099732056'
|
||||
+ '6973696f6e6172792c2044696573206174203536ffffffff0100f2052a010000004341'
|
||||
+ '040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4'
|
||||
+ 'd4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9ac00000000';
|
||||
|
||||
/**
|
||||
* POW-related constants.
|
||||
@ -165,7 +154,7 @@ main.pow = {
|
||||
*/
|
||||
|
||||
limit: new BN(
|
||||
'00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
||||
'00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
||||
'hex'
|
||||
),
|
||||
|
||||
@ -175,7 +164,7 @@ main.pow = {
|
||||
* @default
|
||||
*/
|
||||
|
||||
bits: 486604799,
|
||||
bits: 504365055,
|
||||
|
||||
/**
|
||||
* Minimum chainwork for best chain.
|
||||
@ -183,7 +172,7 @@ main.pow = {
|
||||
*/
|
||||
|
||||
chainwork: new BN(
|
||||
'00000000000000000000000000000000000000000074093f7ecede98cadd3a32',
|
||||
'00000000000000000000000000000000000000000000000ba50a60f8b56c7fe0',
|
||||
'hex'
|
||||
),
|
||||
|
||||
@ -193,7 +182,7 @@ main.pow = {
|
||||
* @default
|
||||
*/
|
||||
|
||||
targetTimespan: 14 * 24 * 60 * 60,
|
||||
targetTimespan: 3.5 * 24 * 60 * 60,
|
||||
|
||||
/**
|
||||
* Average block time.
|
||||
@ -201,7 +190,7 @@ main.pow = {
|
||||
* @default
|
||||
*/
|
||||
|
||||
targetSpacing: 10 * 60,
|
||||
targetSpacing: 2.5 * 60,
|
||||
|
||||
/**
|
||||
* Retarget interval in blocks.
|
||||
@ -241,37 +230,37 @@ main.block = {
|
||||
* Used for avoiding bip30 checks.
|
||||
*/
|
||||
|
||||
bip34height: 227931,
|
||||
bip34height: 710000,
|
||||
|
||||
/**
|
||||
* Hash of the block that activated bip34.
|
||||
*/
|
||||
|
||||
bip34hash: 'b808089c756add1591b1d17bab44bba3fed9e02f942ab4894b02000000000000',
|
||||
bip34hash: 'cf519deb9a32b4c72612ff0c42bf3a04f262fa41d4c8a7d58e763aa804d209fa',
|
||||
|
||||
/**
|
||||
* Height at which bip65 was activated.
|
||||
*/
|
||||
|
||||
bip65height: 388381,
|
||||
bip65height: 918684,
|
||||
|
||||
/**
|
||||
* Hash of the block that activated bip65.
|
||||
*/
|
||||
|
||||
bip65hash: 'f035476cfaeb9f677c2cdad00fd908c556775ded24b6c2040000000000000000',
|
||||
bip65hash: '1a31cc64827cc248b2afefd849d41dde2bb907e73ff6ef3edce077891e04b3ba',
|
||||
|
||||
/**
|
||||
* Height at which bip66 was activated.
|
||||
*/
|
||||
|
||||
bip66height: 363725,
|
||||
bip66height: 811879,
|
||||
|
||||
/**
|
||||
* Hash of the block that activated bip66.
|
||||
*/
|
||||
|
||||
bip66hash: '3109b588941188a9f1c2576aae462d729b8cce9da1ea79030000000000000000',
|
||||
bip66hash: '941849dc7bbdd271a727db8fb06acd33e23a1b8b5d83f85289fa332801eece7a',
|
||||
|
||||
/**
|
||||
* Safe height to start pruning.
|
||||
@ -298,7 +287,7 @@ main.block = {
|
||||
* logs without spamming.
|
||||
*/
|
||||
|
||||
slowHeight: 325000
|
||||
slowHeight: 900000
|
||||
};
|
||||
|
||||
/**
|
||||
@ -308,10 +297,7 @@ main.block = {
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.bip30 = {
|
||||
91842: 'eccae000e3c8e4e093936360431f3b7603c563c1ff6181390a4d0a0000000000',
|
||||
91880: '21d77ccb4c08386a04ac0196ae10f6a1d2c2a377558ca190f143070000000000'
|
||||
};
|
||||
main.bip30 = {};
|
||||
|
||||
/**
|
||||
* For versionbits.
|
||||
@ -319,7 +305,7 @@ main.bip30 = {
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.activationThreshold = 1916; // 95% of 2016
|
||||
main.activationThreshold = 6048; // 75% of 8064
|
||||
|
||||
/**
|
||||
* Confirmation window for versionbits.
|
||||
@ -327,7 +313,7 @@ main.activationThreshold = 1916; // 95% of 2016
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.minerWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
|
||||
main.minerWindow = 8064; // nPowTargetTimespan / nPowTargetSpacing * 4
|
||||
|
||||
/**
|
||||
* Deployments for versionbits.
|
||||
@ -339,8 +325,8 @@ main.deployments = {
|
||||
csv: {
|
||||
name: 'csv',
|
||||
bit: 0,
|
||||
startTime: 1462060800, // May 1st, 2016
|
||||
timeout: 1493596800, // May 1st, 2017
|
||||
startTime: 1485561600, // January 28, 2017
|
||||
timeout: 1517356801, // January 31st, 2018
|
||||
threshold: -1,
|
||||
window: -1,
|
||||
required: false,
|
||||
@ -349,23 +335,13 @@ main.deployments = {
|
||||
segwit: {
|
||||
name: 'segwit',
|
||||
bit: 1,
|
||||
startTime: 1479168000, // November 15th, 2016.
|
||||
timeout: 1510704000, // November 15th, 2017.
|
||||
startTime: 1485561600, // January 28, 2017
|
||||
timeout: 1517356801, // January 31st, 2018
|
||||
threshold: -1,
|
||||
window: -1,
|
||||
required: true,
|
||||
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: {
|
||||
name: 'testdummy',
|
||||
bit: 28,
|
||||
@ -387,7 +363,6 @@ main.deployments = {
|
||||
main.deploys = [
|
||||
main.deployments.csv,
|
||||
main.deployments.segwit,
|
||||
main.deployments.segsignal,
|
||||
main.deployments.testdummy
|
||||
];
|
||||
|
||||
@ -398,7 +373,7 @@ main.deploys = [
|
||||
*/
|
||||
|
||||
main.keyPrefix = {
|
||||
privkey: 0x80,
|
||||
privkey: 0xb0,
|
||||
xpubkey: 0x0488b21e,
|
||||
xprivkey: 0x0488ade4,
|
||||
xpubkey58: 'xpub',
|
||||
@ -412,11 +387,12 @@ main.keyPrefix = {
|
||||
*/
|
||||
|
||||
main.addressPrefix = {
|
||||
pubkeyhash: 0x00,
|
||||
pubkeyhash: 0x30,
|
||||
scripthash: 0x05,
|
||||
scripthash2: 0x32,
|
||||
witnesspubkeyhash: 0x06,
|
||||
witnessscripthash: 0x0a,
|
||||
bech32: 'bc'
|
||||
bech32: 'ltc'
|
||||
};
|
||||
|
||||
/**
|
||||
@ -434,7 +410,7 @@ main.requireStandard = true;
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.rpcPort = 8332;
|
||||
main.rpcPort = 9332;
|
||||
|
||||
/**
|
||||
* Default min relay rate.
|
||||
@ -442,7 +418,7 @@ main.rpcPort = 8332;
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.minRelay = 1000;
|
||||
main.minRelay = 10000;
|
||||
|
||||
/**
|
||||
* Default normal relay rate.
|
||||
@ -450,7 +426,7 @@ main.minRelay = 1000;
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.feeRate = 100000;
|
||||
main.feeRate = 1000000;
|
||||
|
||||
/**
|
||||
* Maximum normal relay rate.
|
||||
@ -458,7 +434,7 @@ main.feeRate = 100000;
|
||||
* @default
|
||||
*/
|
||||
|
||||
main.maxFeeRate = 400000;
|
||||
main.maxFeeRate = 4000000;
|
||||
|
||||
/**
|
||||
* Whether to allow self-connection.
|
||||
@ -484,85 +460,69 @@ const testnet = {};
|
||||
testnet.type = 'testnet';
|
||||
|
||||
testnet.seeds = [
|
||||
'testnet-seed.bitcoin.jonasschnelli.ch', // Jonas Schnelli
|
||||
'seed.tbtc.petertodd.org', // Peter Todd
|
||||
'testnet-seed.bluematt.me', // Matt Corallo
|
||||
'testnet-seed.bitcoin.schildbach.de' // Andreas Schildbach
|
||||
'testnet-seed.litecointools.com',
|
||||
'seed-b.litecoin.loshan.co.uk',
|
||||
'dnsseed-testnet.thrasher.io'
|
||||
];
|
||||
|
||||
testnet.magic = 0x0709110b;
|
||||
testnet.magic = 0xf1c8d2fd;
|
||||
|
||||
testnet.port = 18333;
|
||||
testnet.port = 19335;
|
||||
|
||||
testnet.checkpointMap = {
|
||||
546: '70cb6af7ebbcb1315d3414029c556c55f3e2fc353c4c9063a76c932a00000000',
|
||||
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'
|
||||
2056: '8932a8789c96c516d8a1080a29c7e7e387d2397a83864f9adcaf97ba318a7417',
|
||||
};
|
||||
|
||||
testnet.lastCheckpoint = 1050000;
|
||||
testnet.lastCheckpoint = 2056;
|
||||
|
||||
testnet.halvingInterval = 210000;
|
||||
testnet.halvingInterval = 840000;
|
||||
|
||||
testnet.genesis = {
|
||||
version: 1,
|
||||
hash: '43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000',
|
||||
hash: 'a0293e4eeb3da6e6f56f81ed595f57880d1a21569e13eefdd951284b5a626649',
|
||||
prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
|
||||
merkleRoot:
|
||||
'3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a',
|
||||
time: 1296688602,
|
||||
bits: 486604799,
|
||||
nonce: 414098458,
|
||||
merkleRoot: 'd9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97',
|
||||
time: 1486949366,
|
||||
bits: 504365040,
|
||||
nonce: 293345,
|
||||
height: 0
|
||||
};
|
||||
|
||||
testnet.genesisBlock =
|
||||
'0100000000000000000000000000000000000000000000000000000000000000000000'
|
||||
+ '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5'
|
||||
+ '494dffff001d1aa4ae1801010000000100000000000000000000000000000000000000'
|
||||
+ '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573'
|
||||
+ '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66'
|
||||
+ '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01'
|
||||
+ '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f'
|
||||
+ '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f'
|
||||
+ 'ac00000000';
|
||||
'010000000000000000000000000000000000000000000000000000000000000000000'
|
||||
+ '000d9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97f6'
|
||||
+ '0ba158f0ff0f1ee179040001010000000100000000000000000000000000000000000'
|
||||
+ '00000000000000000000000000000ffffffff4804ffff001d0104404e592054696d65'
|
||||
+ '732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997'
|
||||
+ '320566973696f6e6172792c2044696573206174203536ffffffff0100f2052a010000'
|
||||
+ '004341040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3e'
|
||||
+ 'b4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9ac'
|
||||
+ '00000000';
|
||||
|
||||
testnet.pow = {
|
||||
limit: new BN(
|
||||
'00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
||||
'00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
||||
'hex'
|
||||
),
|
||||
bits: 486604799,
|
||||
bits: 504365055,
|
||||
chainwork: new BN(
|
||||
'0000000000000000000000000000000000000000000000286d17360c5492b2c4',
|
||||
'0000000000000000000000000000000000000000000000000000364b0cbc3568',
|
||||
'hex'
|
||||
),
|
||||
targetTimespan: 14 * 24 * 60 * 60,
|
||||
targetSpacing: 10 * 60,
|
||||
targetTimespan: 3.5 * 24 * 60 * 60,
|
||||
targetSpacing: 2.5 * 60,
|
||||
retargetInterval: 2016,
|
||||
targetReset: true,
|
||||
noRetargeting: false
|
||||
};
|
||||
|
||||
testnet.block = {
|
||||
bip34height: 21111,
|
||||
bip34hash: 'f88ecd9912d00d3f5c2a8e0f50417d3e415c75b3abe584346da9b32300000000',
|
||||
bip65height: 581885,
|
||||
bip65hash: 'b61e864fbec41dfaf09da05d1d76dc068b0dd82ee7982ff255667f0000000000',
|
||||
bip66height: 330776,
|
||||
bip66hash: '82a14b9e5ea81d4832b8e2cd3c2a6092b5a3853285a8995ec4c8042100000000',
|
||||
bip34height: 76,
|
||||
bip34hash: '73058ccc33da8b5479e3548c3cce4fb32a705fa9803994fd5f498bed71c77580',
|
||||
bip65height: 76,
|
||||
bip65hash: '73058ccc33da8b5479e3548c3cce4fb32a705fa9803994fd5f498bed71c77580',
|
||||
bip66height: 76,
|
||||
bip66hash: '73058ccc33da8b5479e3548c3cce4fb32a705fa9803994fd5f498bed71c77580',
|
||||
pruneAfterHeight: 1000,
|
||||
keepBlocks: 10000,
|
||||
maxTipAge: 24 * 60 * 60,
|
||||
@ -579,8 +539,8 @@ testnet.deployments = {
|
||||
csv: {
|
||||
name: 'csv',
|
||||
bit: 0,
|
||||
startTime: 1456790400, // March 1st, 2016
|
||||
timeout: 1493596800, // May 1st, 2017
|
||||
startTime: 1483228800, // March 1st, 2016
|
||||
timeout: 1517356801, // May 1st, 2017
|
||||
threshold: -1,
|
||||
window: -1,
|
||||
required: false,
|
||||
@ -589,23 +549,13 @@ testnet.deployments = {
|
||||
segwit: {
|
||||
name: 'segwit',
|
||||
bit: 1,
|
||||
startTime: 1462060800, // May 1st 2016
|
||||
timeout: 1493596800, // May 1st 2017
|
||||
startTime: 1483228800, // May 1st 2016
|
||||
timeout: 1517356801, // May 1st 2017
|
||||
threshold: -1,
|
||||
window: -1,
|
||||
required: true,
|
||||
force: false
|
||||
},
|
||||
segsignal: {
|
||||
name: 'segsignal',
|
||||
bit: 4,
|
||||
startTime: 0xffffffff,
|
||||
timeout: 0xffffffff,
|
||||
threshold: 269,
|
||||
window: 336,
|
||||
required: false,
|
||||
force: false
|
||||
},
|
||||
testdummy: {
|
||||
name: 'testdummy',
|
||||
bit: 28,
|
||||
@ -621,7 +571,6 @@ testnet.deployments = {
|
||||
testnet.deploys = [
|
||||
testnet.deployments.csv,
|
||||
testnet.deployments.segwit,
|
||||
testnet.deployments.segsignal,
|
||||
testnet.deployments.testdummy
|
||||
];
|
||||
|
||||
@ -629,22 +578,23 @@ testnet.keyPrefix = {
|
||||
privkey: 0xef,
|
||||
xpubkey: 0x043587cf,
|
||||
xprivkey: 0x04358394,
|
||||
xpubkey58: 'tpub',
|
||||
xprivkey58: 'tprv',
|
||||
xpubkey58: 'xpub',
|
||||
xprivkey58: 'xprv',
|
||||
coinType: 1
|
||||
};
|
||||
|
||||
testnet.addressPrefix = {
|
||||
pubkeyhash: 0x6f,
|
||||
scripthash: 0xc4,
|
||||
scripthash2: 0x3a,
|
||||
witnesspubkeyhash: 0x03,
|
||||
witnessscripthash: 0x28,
|
||||
bech32: 'tb'
|
||||
bech32: 'tltc'
|
||||
};
|
||||
|
||||
testnet.requireStandard = false;
|
||||
|
||||
testnet.rpcPort = 18332;
|
||||
testnet.rpcPort = 19332;
|
||||
|
||||
testnet.minRelay = 1000;
|
||||
|
||||
@ -670,7 +620,7 @@ regtest.seeds = [
|
||||
|
||||
regtest.magic = 0xdab5bffa;
|
||||
|
||||
regtest.port = 48444;
|
||||
regtest.port = 19444;
|
||||
|
||||
regtest.checkpointMap = {};
|
||||
regtest.lastCheckpoint = 0;
|
||||
@ -679,26 +629,25 @@ regtest.halvingInterval = 150;
|
||||
|
||||
regtest.genesis = {
|
||||
version: 1,
|
||||
hash: '06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f',
|
||||
hash: 'f916c456fc51df627885d7d674ed02dc88a225adb3f02ad13eb4938ff3270853',
|
||||
prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
|
||||
merkleRoot:
|
||||
'3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a',
|
||||
merkleRoot: 'd9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97',
|
||||
time: 1296688602,
|
||||
bits: 545259519,
|
||||
nonce: 2,
|
||||
nonce: 0,
|
||||
height: 0
|
||||
};
|
||||
|
||||
regtest.genesisBlock =
|
||||
'0100000000000000000000000000000000000000000000000000000000000000000000'
|
||||
+ '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5'
|
||||
+ '494dffff7f200200000001010000000100000000000000000000000000000000000000'
|
||||
+ '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573'
|
||||
+ '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66'
|
||||
+ '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01'
|
||||
+ '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f'
|
||||
+ '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f'
|
||||
+ 'ac00000000';
|
||||
'010000000000000000000000000000000000000000000000000000000000000000000'
|
||||
+ '000d9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97da'
|
||||
+ 'e5494dffff7f200000000001010000000100000000000000000000000000000000000'
|
||||
+ '00000000000000000000000000000ffffffff4804ffff001d0104404e592054696d65'
|
||||
+ '732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997'
|
||||
+ '320566973696f6e6172792c2044696573206174203536ffffffff0100f2052a010000'
|
||||
+ '004341040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3e'
|
||||
+ 'b4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9ac'
|
||||
+ '00000000';
|
||||
|
||||
regtest.pow = {
|
||||
limit: new BN(
|
||||
@ -707,18 +656,18 @@ regtest.pow = {
|
||||
),
|
||||
bits: 545259519,
|
||||
chainwork: new BN(
|
||||
'0000000000000000000000000000000000000000000000000000000000000002',
|
||||
'0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'hex'
|
||||
),
|
||||
targetTimespan: 14 * 24 * 60 * 60,
|
||||
targetSpacing: 10 * 60,
|
||||
targetTimespan: 3.5 * 24 * 60 * 60,
|
||||
targetSpacing: 2.5 * 60,
|
||||
retargetInterval: 2016,
|
||||
targetReset: true,
|
||||
noRetargeting: true
|
||||
};
|
||||
|
||||
regtest.block = {
|
||||
bip34height: 100000000,
|
||||
bip34height: 0xffffffff,
|
||||
bip34hash: null,
|
||||
bip65height: 1351,
|
||||
bip65hash: null,
|
||||
@ -757,16 +706,6 @@ regtest.deployments = {
|
||||
required: true,
|
||||
force: false
|
||||
},
|
||||
segsignal: {
|
||||
name: 'segsignal',
|
||||
bit: 4,
|
||||
startTime: 0xffffffff,
|
||||
timeout: 0xffffffff,
|
||||
threshold: 269,
|
||||
window: 336,
|
||||
required: false,
|
||||
force: false
|
||||
},
|
||||
testdummy: {
|
||||
name: 'testdummy',
|
||||
bit: 28,
|
||||
@ -782,30 +721,30 @@ regtest.deployments = {
|
||||
regtest.deploys = [
|
||||
regtest.deployments.csv,
|
||||
regtest.deployments.segwit,
|
||||
regtest.deployments.segsignal,
|
||||
regtest.deployments.testdummy
|
||||
];
|
||||
|
||||
regtest.keyPrefix = {
|
||||
privkey: 0x5a,
|
||||
xpubkey: 0xeab4fa05,
|
||||
xprivkey: 0xeab404c7,
|
||||
xpubkey58: 'rpub',
|
||||
xprivkey58: 'rprv',
|
||||
privkey: 0xef,
|
||||
xpubkey: 0x043587cf,
|
||||
xprivkey: 0x04358394,
|
||||
xpubkey58: 'xpub',
|
||||
xprivkey58: 'xprv',
|
||||
coinType: 1
|
||||
};
|
||||
|
||||
regtest.addressPrefix = {
|
||||
pubkeyhash: 0x3c,
|
||||
scripthash: 0x26,
|
||||
witnesspubkeyhash: 0x7a,
|
||||
witnessscripthash: 0x14,
|
||||
bech32: 'rb'
|
||||
pubkeyhash: 0x6f,
|
||||
scripthash: 0xc4,
|
||||
scripthash2: 0x3a,
|
||||
witnesspubkeyhash: 0x03,
|
||||
witnessscripthash: 0x28,
|
||||
bech32: 'rltc'
|
||||
};
|
||||
|
||||
regtest.requireStandard = false;
|
||||
|
||||
regtest.rpcPort = 48332;
|
||||
regtest.rpcPort = 19445;
|
||||
|
||||
regtest.minRelay = 1000;
|
||||
|
||||
@ -873,8 +812,8 @@ simnet.pow = {
|
||||
'0000000000000000000000000000000000000000000000000000000000000002',
|
||||
'hex'
|
||||
),
|
||||
targetTimespan: 14 * 24 * 60 * 60,
|
||||
targetSpacing: 10 * 60,
|
||||
targetTimespan: 3.5 * 24 * 60 * 60,
|
||||
targetSpacing: 2.5 * 60,
|
||||
retargetInterval: 2016,
|
||||
targetReset: true,
|
||||
noRetargeting: false
|
||||
|
||||
@ -13,7 +13,7 @@ const random = require('../crypto/random');
|
||||
const cleanse = require('../crypto/cleanse');
|
||||
const aes = require('../crypto/aes');
|
||||
const pbkdf2 = require('../crypto/pbkdf2');
|
||||
const scrypt = require('../crypto/scrypt');
|
||||
const scrypt = require('../crypto/scrypt').derive;
|
||||
const BufferReader = require('../utils/reader');
|
||||
const StaticWriter = require('../utils/staticwriter');
|
||||
const encoding = require('../utils/encoding');
|
||||
|
||||
@ -25,7 +25,7 @@ const server = exports;
|
||||
*/
|
||||
|
||||
server.create = function create(options) {
|
||||
const config = new Config('bcoin');
|
||||
const config = new Config('lcoin');
|
||||
let logger = new Logger('debug');
|
||||
|
||||
config.inject(options);
|
||||
|
||||
18
package.json
18
package.json
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "bcoin",
|
||||
"name": "lcoin",
|
||||
"version": "1.0.0-beta.15",
|
||||
"description": "Bitcoin bike-shed",
|
||||
"description": "Litecoin bike-shed",
|
||||
"license": "MIT",
|
||||
"repository": "git://github.com/bcoin-org/bcoin.git",
|
||||
"homepage": "https://github.com/bcoin-org/bcoin",
|
||||
"repository": "git://github.com/bcoin-org/lcoin.git",
|
||||
"homepage": "https://github.com/bcoin-org/lcoin",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bcoin-org/bcoin/issues"
|
||||
"url": "https://github.com/bcoin-org/lcoin/issues"
|
||||
},
|
||||
"author": "Fedor Indutny <fedor@indutny.com>",
|
||||
"contributors": [
|
||||
@ -53,10 +53,10 @@
|
||||
},
|
||||
"main": "./lib/bcoin.js",
|
||||
"bin": {
|
||||
"bcoin": "./bin/bcoin",
|
||||
"bcoin-cli": "./bin/cli",
|
||||
"bcoin-node": "./bin/node",
|
||||
"bcoin-spvnode": "./bin/spvnode"
|
||||
"lcoin": "./bin/lcoin",
|
||||
"lcoin-cli": "./bin/cli",
|
||||
"lcoin-node": "./bin/node",
|
||||
"lcoin-spvnode": "./bin/spvnode"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rm -f {browser/,}{bcoin.js,bcoin-worker.js}",
|
||||
|
||||
@ -66,44 +66,35 @@ function createGenesisBlock(options) {
|
||||
|
||||
const main = createGenesisBlock({
|
||||
version: 1,
|
||||
time: 1231006505,
|
||||
bits: 486604799,
|
||||
nonce: 2083236893
|
||||
time: 1317972665,
|
||||
bits: 504365040,
|
||||
nonce: 2084524493,
|
||||
flags: Buffer.from(
|
||||
'NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56',
|
||||
'ascii'),
|
||||
key: Buffer.from('040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9', 'hex')
|
||||
});
|
||||
|
||||
const testnet = createGenesisBlock({
|
||||
version: 1,
|
||||
time: 1296688602,
|
||||
bits: 486604799,
|
||||
nonce: 414098458
|
||||
time: 1486949366,
|
||||
bits: 0x1e0ffff0,
|
||||
nonce: 293345,
|
||||
flags: Buffer.from(
|
||||
'NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56',
|
||||
'ascii'),
|
||||
key: Buffer.from('040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9', 'hex')
|
||||
});
|
||||
|
||||
const regtest = createGenesisBlock({
|
||||
version: 1,
|
||||
time: 1296688602,
|
||||
bits: 545259519,
|
||||
nonce: 2
|
||||
});
|
||||
|
||||
const segnet3 = createGenesisBlock({
|
||||
version: 1,
|
||||
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
|
||||
bits: 0x207fffff,
|
||||
nonce: 0,
|
||||
flags: Buffer.from(
|
||||
'NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56',
|
||||
'ascii'),
|
||||
key: Buffer.from('040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9', 'hex')
|
||||
});
|
||||
|
||||
util.log(main);
|
||||
@ -112,11 +103,6 @@ util.log(testnet);
|
||||
util.log('');
|
||||
util.log(regtest);
|
||||
util.log('');
|
||||
util.log(segnet3);
|
||||
util.log('');
|
||||
util.log(segnet4);
|
||||
util.log('');
|
||||
util.log('');
|
||||
util.log('main hash: %s', main.rhash());
|
||||
util.log('main raw: %s', main.toRaw().toString('hex'));
|
||||
util.log('');
|
||||
@ -126,11 +112,3 @@ util.log('');
|
||||
util.log('regtest hash: %s', regtest.rhash());
|
||||
util.log('regtest raw: %s', regtest.toRaw().toString('hex'));
|
||||
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'));
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
dir=$(dirname "$(which "$0")")
|
||||
url_main='https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/seeds/nodes_main.txt'
|
||||
url_testnet='https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/seeds/nodes_test.txt'
|
||||
url_main='https://raw.githubusercontent.com/litecoin-project/litecoin/master/contrib/seeds/nodes_main.txt'
|
||||
url_testnet='https://raw.githubusercontent.com/litecoin-project/litecoin/master/contrib/seeds/nodes_test.txt'
|
||||
|
||||
getseeds() {
|
||||
echo "$(curl -s "$1")"
|
||||
|
||||
@ -12,7 +12,7 @@ describe('Address', function() {
|
||||
const raw = 'e34cce70c86373273efcc54ce7d2a491bb4a0e84';
|
||||
const p2pkh = Buffer.from(raw, 'hex');
|
||||
const addr = Address.fromPubkeyhash(p2pkh);
|
||||
const expectedAddr = '1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX';
|
||||
const expectedAddr = 'LfwofMun44rKk766Vcft6v9a7XPWBSppiq';
|
||||
assert.strictEqual(addr.toString(), expectedAddr);
|
||||
});
|
||||
|
||||
@ -20,7 +20,7 @@ describe('Address', function() {
|
||||
const raw = '0ef030107fd26e0b6bf40512bca2ceb1dd80adaa';
|
||||
const p2pkh = Buffer.from(raw, 'hex');
|
||||
const addr = Address.fromPubkeyhash(p2pkh);
|
||||
const expectedAddr = '12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG';
|
||||
const expectedAddr = 'LLawTSFdhuPKGSotr5KpwS4rGdkB7J9vLq';
|
||||
assert.strictEqual(addr.toString(), expectedAddr);
|
||||
});
|
||||
|
||||
@ -90,7 +90,7 @@ describe('Address', function() {
|
||||
const raw = '751e76e8199196d454941c45d1b3a323f1433bd6';
|
||||
const p2wpkh = Buffer.from(raw, 'hex');
|
||||
const addr = Address.fromWitnessPubkeyhash(p2wpkh);
|
||||
const expectedAddr = 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4';
|
||||
const expectedAddr = 'ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9';
|
||||
assert.strictEqual(addr.toString(), expectedAddr);
|
||||
});
|
||||
|
||||
@ -102,14 +102,14 @@ describe('Address', function() {
|
||||
+ 'b8c6329604903262', 'hex');
|
||||
const addr = Address.fromWitnessScripthash(p2wpkh);
|
||||
assert.strictEqual(addr.toString(),
|
||||
'bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3');
|
||||
'ltc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qmu8tk5');
|
||||
});
|
||||
|
||||
it('should match testnet segwit p2wpkh v0 address', () => {
|
||||
const raw = '751e76e8199196d454941c45d1b3a323f1433bd6';
|
||||
const p2wpkh = Buffer.from(raw, 'hex');
|
||||
const addr = Address.fromWitnessPubkeyhash(p2wpkh, 'testnet');
|
||||
const expectedAddr = 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx';
|
||||
const expectedAddr = 'tltc1qw508d6qejxtdg4y5r3zarvary0c5xw7klfsuq0';
|
||||
assert.strictEqual(addr.toString(), expectedAddr);
|
||||
});
|
||||
|
||||
@ -121,7 +121,7 @@ describe('Address', function() {
|
||||
+ 'b8c6329604903262', 'hex');
|
||||
const addr = Address.fromWitnessScripthash(p2wpkh, 'testnet');
|
||||
assert.strictEqual(addr.toString(),
|
||||
'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7');
|
||||
'tltc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qsnr4fp');
|
||||
});
|
||||
|
||||
it('should match testnet segwit p2pwsh v0 address 2', () => {
|
||||
@ -132,7 +132,7 @@ describe('Address', function() {
|
||||
+ '4d165dab93e86433', 'hex');
|
||||
const addr = Address.fromWitnessScripthash(p2wpkh, 'testnet');
|
||||
assert.strictEqual(addr.toString(),
|
||||
'tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy');
|
||||
'tltc1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesu9tmgm');
|
||||
});
|
||||
|
||||
it('should handle invalid segwit hrp', () => {
|
||||
|
||||
@ -42,14 +42,14 @@ const validChecksums = [
|
||||
|
||||
const validAddresses = [
|
||||
[
|
||||
'BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4',
|
||||
'LTC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KGMN4N9',
|
||||
Buffer.from([
|
||||
0x00, 0x14, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54,
|
||||
0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6
|
||||
])
|
||||
],
|
||||
[
|
||||
'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7',
|
||||
'tltc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qsnr4fp',
|
||||
Buffer.from([
|
||||
0x00, 0x20, 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04,
|
||||
0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x6c, 0x98, 0x56, 0x78,
|
||||
@ -58,8 +58,7 @@ const validAddresses = [
|
||||
])
|
||||
],
|
||||
[
|
||||
'bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw50'
|
||||
+ '8d6qejxtdg4y5r3zarvary0c5xw7k7grplx',
|
||||
'ltc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k0tul4w',
|
||||
Buffer.from([
|
||||
0x81, 0x28, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54,
|
||||
0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6,
|
||||
@ -68,20 +67,20 @@ const validAddresses = [
|
||||
])
|
||||
],
|
||||
[
|
||||
'BC1SW50QA3JX3S',
|
||||
'LTC1SW50QZGYDF5',
|
||||
Buffer.from([
|
||||
0x90, 0x02, 0x75, 0x1e
|
||||
])
|
||||
],
|
||||
[
|
||||
'bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj',
|
||||
'ltc1zw508d6qejxtdg4y5r3zarvaryvdzur3w',
|
||||
Buffer.from([
|
||||
0x82, 0x10, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54,
|
||||
0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23
|
||||
])
|
||||
],
|
||||
[
|
||||
'tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy',
|
||||
'tltc1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesu9tmgm',
|
||||
Buffer.from([
|
||||
0x00, 0x20, 0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62, 0x21,
|
||||
0xb2, 0xa1, 0x87, 0x90, 0x5e, 0x52, 0x66, 0x36, 0x2b, 0x99, 0xd5,
|
||||
@ -144,7 +143,7 @@ describe('Bech32', function() {
|
||||
|
||||
for (const [addr, script] of validAddresses) {
|
||||
it(`should have valid address for ${addr}`, () => {
|
||||
let hrp = 'bc';
|
||||
let hrp = 'ltc';
|
||||
let ret = null;
|
||||
|
||||
try {
|
||||
@ -154,7 +153,7 @@ describe('Bech32', function() {
|
||||
}
|
||||
|
||||
if (ret === null) {
|
||||
hrp = 'tb';
|
||||
hrp = 'tltc';
|
||||
try {
|
||||
ret = fromAddress(hrp, addr);
|
||||
} catch (e) {
|
||||
@ -174,8 +173,8 @@ describe('Bech32', function() {
|
||||
|
||||
for (const addr of invalidAddresses) {
|
||||
it(`should have invalid address for ${addr}`, () => {
|
||||
assert.throws(() => fromAddress('bc', addr));
|
||||
assert.throws(() => fromAddress('tb', addr));
|
||||
assert.throws(() => fromAddress('ltc', addr));
|
||||
assert.throws(() => fromAddress('tltc', addr));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -72,8 +72,8 @@ const op4 = new Outpoint(
|
||||
'b7c3c4bce1a23baef2da05f9b7e4bff813449ec7e80f980ec7e4cacfadcd3314',
|
||||
300);
|
||||
|
||||
const addr1 = new Address('bc1qmyrddmxglk49ye2wd29wefaavw7es8k5d555lx');
|
||||
const addr2 = new Address('bc1q4645ycu0l9pnvxaxnhemushv0w4cd9flkqh95j');
|
||||
const addr1 = new Address('ltc1qmyrddmxglk49ye2wd29wefaavw7es8k5fgws8k');
|
||||
const addr2 = new Address('ltc1q4645ycu0l9pnvxaxnhemushv0w4cd9fljudpvz');
|
||||
|
||||
let filter1 = null;
|
||||
let filter2 = null;
|
||||
|
||||
@ -198,7 +198,7 @@ describe('HTTP', function() {
|
||||
vbrequired: 0,
|
||||
height: 1,
|
||||
previousblockhash:
|
||||
'0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206',
|
||||
'530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9',
|
||||
target:
|
||||
'7fffff0000000000000000000000000000000000000000000000000000000000',
|
||||
bits: '207fffff',
|
||||
@ -210,7 +210,7 @@ describe('HTTP', function() {
|
||||
sigoplimit: 20000,
|
||||
sizelimit: 1000000,
|
||||
longpollid:
|
||||
'0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206'
|
||||
'530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9'
|
||||
+ '0000000000',
|
||||
submitold: false,
|
||||
coinbaseaux: { flags: '6d696e65642062792062636f696e' },
|
||||
|
||||
@ -55,7 +55,7 @@ describe('Input', function() {
|
||||
const prevout = input.prevout.toRaw();
|
||||
|
||||
assert.strictEqual(type, 'pubkeyhash');
|
||||
assert.strictEqual(addr, '1PM9ZgAV8Z4df1md2zRTF98tPjzTAfk2a6');
|
||||
assert.strictEqual(addr, 'Lha6ptUKDDJgupTnD8QkXACebxMjFtmfTg');
|
||||
assert.strictEqual(input.isCoinbase(), false);
|
||||
|
||||
assert.strictEqual(input.isFinal(), true);
|
||||
|
||||
@ -7,10 +7,10 @@ const assert = require('./util/assert');
|
||||
const KeyRing = require('../lib/primitives/keyring');
|
||||
|
||||
const uncompressed = KeyRing.fromSecret(
|
||||
'5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss');
|
||||
'6vrJ6bnKwaSuimkkRLpNNziSjqwZCG59kfFC9P2kjbUUs5Y6Cw9');
|
||||
|
||||
const compressed = KeyRing.fromSecret(
|
||||
'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1');
|
||||
'TAgaTiX4btdMhNY6eSU5N5jvc71o6hXKdhoeBzEk31AHykGDou8i');
|
||||
|
||||
describe('KeyRing', function() {
|
||||
it('should get uncompressed public key', () => {
|
||||
@ -22,13 +22,13 @@ describe('KeyRing', function() {
|
||||
|
||||
it('should get uncompressed public key address', () => {
|
||||
assert.strictEqual(
|
||||
'1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN',
|
||||
'Lbnu1x4UfToiiFGU8MvPrLpj2GSrtUrxFH',
|
||||
uncompressed.getKeyAddress('base58'));
|
||||
});
|
||||
|
||||
it('should get uncompressed WIF', () => {
|
||||
assert.strictEqual(
|
||||
'5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss',
|
||||
'6vrJ6bnKwaSuimkkRLpNNziSjqwZCG59kfFC9P2kjbUUs5Y6Cw9',
|
||||
uncompressed.toSecret());
|
||||
});
|
||||
|
||||
@ -40,13 +40,13 @@ describe('KeyRing', function() {
|
||||
|
||||
it('should get compressed public key address', () => {
|
||||
assert.strictEqual(
|
||||
'1F3sAm6ZtwLAUnj7d38pGFxtP3RVEvtsbV',
|
||||
'LZGpRyQPybaDjbRGoB87YH2ebFnmKYmRui',
|
||||
compressed.getKeyAddress('base58'));
|
||||
});
|
||||
|
||||
it('should get compressed WIF', () => {
|
||||
assert.strictEqual(
|
||||
'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1',
|
||||
'TAgaTiX4btdMhNY6eSU5N5jvc71o6hXKdhoeBzEk31AHykGDou8i',
|
||||
compressed.toSecret());
|
||||
});
|
||||
});
|
||||
|
||||
@ -49,7 +49,7 @@ function dummyInput(script, hash) {
|
||||
|
||||
const fund = new MTX();
|
||||
fund.addCoin(coin);
|
||||
fund.addOutput(script, 70000);
|
||||
fund.addOutput(script, 700000);
|
||||
|
||||
const [tx, view] = fund.commit();
|
||||
|
||||
@ -72,55 +72,55 @@ describe('Mempool', function() {
|
||||
const key = KeyRing.generate();
|
||||
|
||||
const t1 = new MTX();
|
||||
t1.addOutput(wallet.getAddress(), 50000);
|
||||
t1.addOutput(wallet.getAddress(), 10000);
|
||||
t1.addOutput(wallet.getAddress(), 500000);
|
||||
t1.addOutput(wallet.getAddress(), 100000);
|
||||
|
||||
const script = Script.fromPubkey(key.publicKey);
|
||||
|
||||
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]);
|
||||
|
||||
// balance: 51000
|
||||
// balance: 510000
|
||||
wallet.sign(t1);
|
||||
|
||||
const t2 = new MTX();
|
||||
t2.addTX(t1, 0); // 50000
|
||||
t2.addOutput(wallet.getAddress(), 20000);
|
||||
t2.addOutput(wallet.getAddress(), 20000);
|
||||
t2.addTX(t1, 0); // 500000
|
||||
t2.addOutput(wallet.getAddress(), 200000);
|
||||
t2.addOutput(wallet.getAddress(), 200000);
|
||||
|
||||
// balance: 49000
|
||||
// balance: 4900000
|
||||
wallet.sign(t2);
|
||||
|
||||
const t3 = new MTX();
|
||||
t3.addTX(t1, 1); // 10000
|
||||
t3.addTX(t2, 0); // 20000
|
||||
t3.addOutput(wallet.getAddress(), 23000);
|
||||
t3.addTX(t1, 1); // 100000
|
||||
t3.addTX(t2, 0); // 200000
|
||||
t3.addOutput(wallet.getAddress(), 230000);
|
||||
|
||||
// balance: 47000
|
||||
// balance: 470000
|
||||
wallet.sign(t3);
|
||||
|
||||
const t4 = new MTX();
|
||||
t4.addTX(t2, 1); // 24000
|
||||
t4.addTX(t3, 0); // 23000
|
||||
t4.addOutput(wallet.getAddress(), 11000);
|
||||
t4.addOutput(wallet.getAddress(), 11000);
|
||||
t4.addTX(t2, 1); // 240000
|
||||
t4.addTX(t3, 0); // 230000
|
||||
t4.addOutput(wallet.getAddress(), 110000);
|
||||
t4.addOutput(wallet.getAddress(), 110000);
|
||||
|
||||
// balance: 22000
|
||||
// balance: 220000
|
||||
wallet.sign(t4);
|
||||
|
||||
const f1 = new MTX();
|
||||
f1.addTX(t4, 1); // 11000
|
||||
f1.addOutput(new Address(), 9000);
|
||||
f1.addTX(t4, 1); // 110000
|
||||
f1.addOutput(new Address(), 90000);
|
||||
|
||||
// balance: 11000
|
||||
// balance: 110000
|
||||
wallet.sign(f1);
|
||||
|
||||
const fake = new MTX();
|
||||
fake.addTX(t1, 1); // 1000 (already redeemed)
|
||||
fake.addOutput(wallet.getAddress(), 6000); // 6000 instead of 500
|
||||
fake.addTX(t1, 1); // 10000 (already redeemed)
|
||||
fake.addOutput(wallet.getAddress(), 60000); // 60000 instead of 5000
|
||||
|
||||
// Script inputs but do not sign
|
||||
wallet.template(fake);
|
||||
@ -129,42 +129,42 @@ describe('Mempool', function() {
|
||||
const input = fake.inputs[0];
|
||||
input.script.setData(0, encoding.ZERO_SIG);
|
||||
input.script.compile();
|
||||
// balance: 11000
|
||||
// balance: 110000
|
||||
|
||||
{
|
||||
await mempool.addTX(fake.toTX());
|
||||
await mempool.addTX(t4.toTX());
|
||||
|
||||
const balance = mempool.getBalance();
|
||||
assert.strictEqual(balance, 70000);
|
||||
assert.strictEqual(balance, 700000);
|
||||
}
|
||||
|
||||
{
|
||||
await mempool.addTX(t1.toTX());
|
||||
|
||||
const balance = mempool.getBalance();
|
||||
assert.strictEqual(balance, 60000);
|
||||
assert.strictEqual(balance, 600000);
|
||||
}
|
||||
|
||||
{
|
||||
await mempool.addTX(t2.toTX());
|
||||
|
||||
const balance = mempool.getBalance();
|
||||
assert.strictEqual(balance, 50000);
|
||||
assert.strictEqual(balance, 500000);
|
||||
}
|
||||
|
||||
{
|
||||
await mempool.addTX(t3.toTX());
|
||||
|
||||
const balance = mempool.getBalance();
|
||||
assert.strictEqual(balance, 22000);
|
||||
assert.strictEqual(balance, 220000);
|
||||
}
|
||||
|
||||
{
|
||||
await mempool.addTX(f1.toTX());
|
||||
|
||||
const balance = mempool.getBalance();
|
||||
assert.strictEqual(balance, 20000);
|
||||
assert.strictEqual(balance, 200000);
|
||||
}
|
||||
|
||||
const txs = mempool.getHistory();
|
||||
@ -177,8 +177,8 @@ describe('Mempool', function() {
|
||||
const key = KeyRing.generate();
|
||||
|
||||
const tx = new MTX();
|
||||
tx.addOutput(wallet.getAddress(), 50000);
|
||||
tx.addOutput(wallet.getAddress(), 10000);
|
||||
tx.addOutput(wallet.getAddress(), 500000);
|
||||
tx.addOutput(wallet.getAddress(), 100000);
|
||||
|
||||
const prev = Script.fromPubkey(key.publicKey);
|
||||
const prevHash = random.randomBytes(32).toString('hex');
|
||||
@ -188,7 +188,7 @@ describe('Mempool', function() {
|
||||
|
||||
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]);
|
||||
|
||||
await mempool.addTX(tx.toTX());
|
||||
@ -199,8 +199,8 @@ describe('Mempool', function() {
|
||||
const key = KeyRing.generate();
|
||||
|
||||
const tx = new MTX();
|
||||
tx.addOutput(wallet.getAddress(), 50000);
|
||||
tx.addOutput(wallet.getAddress(), 10000);
|
||||
tx.addOutput(wallet.getAddress(), 500000);
|
||||
tx.addOutput(wallet.getAddress(), 100000);
|
||||
|
||||
const prev = Script.fromPubkey(key.publicKey);
|
||||
const prevHash = random.randomBytes(32).toString('hex');
|
||||
@ -209,7 +209,7 @@ describe('Mempool', function() {
|
||||
tx.setLocktime(200);
|
||||
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]);
|
||||
|
||||
let err;
|
||||
@ -230,8 +230,8 @@ describe('Mempool', function() {
|
||||
key.witness = true;
|
||||
|
||||
const tx = new MTX();
|
||||
tx.addOutput(wallet.getAddress(), 50000);
|
||||
tx.addOutput(wallet.getAddress(), 10000);
|
||||
tx.addOutput(wallet.getAddress(), 500000);
|
||||
tx.addOutput(wallet.getAddress(), 100000);
|
||||
|
||||
const prev = Script.fromProgram(0, key.getKeyHash());
|
||||
const prevHash = random.randomBytes(32).toString('hex');
|
||||
@ -240,7 +240,7 @@ describe('Mempool', function() {
|
||||
|
||||
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;
|
||||
|
||||
tx.inputs[0].witness = new Witness([sig, key.publicKey]);
|
||||
@ -260,15 +260,15 @@ describe('Mempool', function() {
|
||||
const key = KeyRing.generate();
|
||||
|
||||
const tx = new MTX();
|
||||
tx.addOutput(wallet.getAddress(), 50000);
|
||||
tx.addOutput(wallet.getAddress(), 10000);
|
||||
tx.addOutput(wallet.getAddress(), 500000);
|
||||
tx.addOutput(wallet.getAddress(), 100000);
|
||||
|
||||
const prev = Script.fromPubkey(key.publicKey);
|
||||
const prevHash = random.randomBytes(32).toString('hex');
|
||||
|
||||
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].witness.push(Buffer.alloc(0));
|
||||
|
||||
@ -289,8 +289,8 @@ describe('Mempool', function() {
|
||||
key.witness = true;
|
||||
|
||||
const tx = new MTX();
|
||||
tx.addOutput(wallet.getAddress(), 50000);
|
||||
tx.addOutput(wallet.getAddress(), 10000);
|
||||
tx.addOutput(wallet.getAddress(), 500000);
|
||||
tx.addOutput(wallet.getAddress(), 100000);
|
||||
|
||||
const prev = Script.fromProgram(0, key.getKeyHash());
|
||||
const prevHash = random.randomBytes(32).toString('hex');
|
||||
@ -313,8 +313,8 @@ describe('Mempool', function() {
|
||||
const key = KeyRing.generate();
|
||||
|
||||
const tx = new MTX();
|
||||
tx.addOutput(wallet.getAddress(), 50000);
|
||||
tx.addOutput(wallet.getAddress(), 10000);
|
||||
tx.addOutput(wallet.getAddress(), 500000);
|
||||
tx.addOutput(wallet.getAddress(), 100000);
|
||||
|
||||
const prev = Script.fromPubkey(key.publicKey);
|
||||
const prevHash = random.randomBytes(32).toString('hex');
|
||||
@ -338,7 +338,7 @@ describe('Mempool', function() {
|
||||
it('should clear reject cache', async () => {
|
||||
const tx = new MTX();
|
||||
tx.addOutpoint(new Outpoint());
|
||||
tx.addOutput(wallet.getAddress(), 50000);
|
||||
tx.addOutput(wallet.getAddress(), 500000);
|
||||
|
||||
assert(mempool.hasReject(cachedTX.hash()));
|
||||
|
||||
|
||||
@ -251,12 +251,12 @@ describe('Wallet', function() {
|
||||
});
|
||||
|
||||
it('should validate existing address', () => {
|
||||
assert(Address.fromString('1KQ1wMNwXHUYj1nV2xzsRcKUH8gVFpTFUc'));
|
||||
assert(Address.fromString('LdcyCZgmbwibypUeD6zAhdPEVM3mPj4zxH'));
|
||||
});
|
||||
|
||||
it('should fail to validate invalid address', () => {
|
||||
assert.throws(() => {
|
||||
Address.fromString('1KQ1wMNwXHUYj1nv2xzsRcKUH8gVFpTFUc');
|
||||
Address.fromString('LdcyCZgmbwibypueD6zAhdPEVM3mPj4zxH');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user