UNPKG

@thorwallet/xchain-bitcoincash

Version:

Custom bitcoincash client and utilities used by XChainJS clients

1,912 lines (1,689 loc) 2.44 MB
import { toLegacyAddress as toLegacyAddress$1, toCashAddress as toCashAddress$1, Network, isValidAddress, detectAddressNetwork } from 'bchaddrjs'; import buffer from 'buffer'; import axios from 'axios'; import crypto$2$1 from 'crypto'; import stream from 'stream'; import string_decoder$1 from 'string_decoder'; import events from 'events'; import { NativeModules } from 'react-native'; import hexLite from 'hex-lite'; import os from 'os'; import readableStream from 'readable-stream'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } function getCjsExportFromNamespace (n) { return n && n['default'] || n; } var safeBuffer = createCommonjsModule(function (module, exports) { /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ /* eslint-disable node/no-deprecated-api */ var Buffer = buffer.Buffer; // alternative to using Object.keys for old browsers function copyProps (src, dst) { for (var key in src) { dst[key] = src[key]; } } if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { module.exports = buffer; } else { // Copy properties from require('buffer') copyProps(buffer, exports); exports.Buffer = SafeBuffer; } function SafeBuffer (arg, encodingOrOffset, length) { return Buffer(arg, encodingOrOffset, length) } SafeBuffer.prototype = Object.create(Buffer.prototype); // Copy static methods from Buffer copyProps(Buffer, SafeBuffer); SafeBuffer.from = function (arg, encodingOrOffset, length) { if (typeof arg === 'number') { throw new TypeError('Argument must not be a number') } return Buffer(arg, encodingOrOffset, length) }; SafeBuffer.alloc = function (size, fill, encoding) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } var buf = Buffer(size); if (fill !== undefined) { if (typeof encoding === 'string') { buf.fill(fill, encoding); } else { buf.fill(fill); } } else { buf.fill(0); } return buf }; SafeBuffer.allocUnsafe = function (size) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } return Buffer(size) }; SafeBuffer.allocUnsafeSlow = function (size) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } return buffer.SlowBuffer(size) }; }); var safeBuffer_1 = safeBuffer.Buffer; /* info from: https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/chainparams.cpp */ var common = { name: 'BitcoinCash', per1: 1e8, unit: 'BCH' }; var main = Object.assign({}, { hashGenesisBlock: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', // nDefaultPort port: 8333, portRpc: 8332, protocol: { // pchMessageStart magic: 0xe8f3e1e3 // careful, sent over wire as little endian }, // vSeeds seedsDns: [ 'seed.bitcoinabc.org', 'seed-abc.bitcoinforks.org', 'btccash-seeder.bitcoinunlimited.info', 'seed.bitprim.org', 'seed.deadalnix.me', 'seeder.criptolayer.net' ], // base58Prefixes versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 145, private: 0x80, public: 0x00, scripthash: 0x05 } }, common); var test = Object.assign({}, { hashGenesisBlock: '000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943', port: 18333, portRpc: 18332, protocol: { magic: 0xf4f3e5f4 }, seedsDns: [ 'testnet-seed.bitcoinabc.org', 'testnet-seed-abc.bitcoinforks.org', 'testnet-seed.bitprim.org', 'testnet-seed.deadalnix.me', 'testnet-seeder.criptolayer.net' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common); var regtest = Object.assign({}, { hashGenesisBlock: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', port: 18444, portRpc: 18332, protocol: { magic: 0xfabfb5da }, seedsDns: [], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common); var bch = { main: main, test: test, regtest: regtest }; /* info from: https://github.com/rat4/blackcoin/blob/master/src/chainparams.cpp */ var common$1 = { name: 'BlackCoin', per1: 1e8, unit: 'BLK' }; var main$1 = Object.assign({}, { hashGenesisBlock: '000001faef25dec4fbcf906e6242621df2c183bf232f263d0ba5b101911e4563', port: 15714, portRpc: 15715, protocol: { magic: 0x05223570 // careful, sent over wire as little endian }, seedsDns: [ 'rat4.blackcoin.co', 'seed.blackcoin.co', 'archon.darkfox.id.au', 'foxy.seeds.darkfox.id.au', '6.syllabear.us.to', 'bcseed.syllabear.us.to' ], versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 0xa, private: 0x99, public: 0x19, scripthash: 0x55 } }, common$1); var blk = { main: main$1, test: null }; /* info from: https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp */ var common$2 = { name: 'Bitcoin', per1: 1e8, unit: 'BTC', messagePrefix: '\x18Bitcoin Signed Message:\n' }; var main$2 = Object.assign({}, { hashGenesisBlock: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', // nDefaultPort port: 8333, portRpc: 8332, protocol: { // pchMessageStart magic: 0xd9b4bef9 // careful, sent over wire as little endian }, bech32: 'bc', // vSeeds seedsDns: [ 'seed.bitcoin.sipa.be', 'dnsseed.bluematt.me', 'seed.bitcoinstats.com', 'seed.bitcoin.jonasschnelli.ch', 'seed.btc.petertodd.org', 'seed.bitcoin.sprovoost.nl', 'dnsseed.emzy.de' ], // base58Prefixes versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 0, private: 0x80, public: 0x00, scripthash: 0x05 } }, common$2); var test$1 = Object.assign({}, { hashGenesisBlock: '000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943', port: 18333, portRpc: 18332, protocol: { magic: 0x0709110b }, bech32: 'tb', seedsDns: [ 'testnet-seed.alexykot.me', 'testnet-seed.bitcoin.schildbach.de', 'testnet-seed.bitcoin.petertodd.org', 'testnet-seed.bluematt.me' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common$2); var regtest$1 = Object.assign({}, { hashGenesisBlock: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', port: 18444, portRpc: 18332, protocol: { magic: 0xdab5bffa }, bech32: 'bcrt', seedsDns: [], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common$2); var btc = { main: main$2, test: test$1, regtest: regtest$1 }; /* info from: https://github.com/BTCGPU/BTCGPU/blob/master/src/chainparams.cpp */ var common$3 = { name: 'Bitcoin Gold', unit: 'BTG' }; var main$3 = Object.assign({}, { hashGenesisBlock: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', // nDefaultPort port: 8338, protocol: { // pchMessageStart magic: 0x446d47e1 // careful, sent over wire as little endian }, bech32: 'btg', // vSeeds seedsDns: [ 'eu-dnsseed.bitcoingold-official.org', 'dnsseed.bitcoingold.org', 'dnsseed.btcgpu.org' ], // base58Prefixes versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 156, private: 0x80, public: 0x26, scripthash: 0x17 } }, common$3); var test$2 = Object.assign({}, { hashGenesisBlock: '0x00000000e0781ebe24b91eedc293adfea2f557b53ec379e78959de3853e6f9f6', port: 18338, portRpc: 18332, protocol: { magic: 0x456e48e2 }, bech32: 'tbtg', seedsDns: [ 'test-dnsseed.bitcoingold.org', 'test-dnsseed.btcgpu.org', 'eu-test-dnsseed.bitcoingold-official.org' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 156, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common$3); var btg = { main: main$3, test: test$2 }; /* info from: https://github.com/dashpay/dash/blob/master/src/chainparams.cpp */ var common$4 = { name: 'Dash', unit: 'DASH' }; var main$4 = Object.assign({}, { hashGenesisBlock: '00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6', // nDefaultPort port: 9999, portRpc: 9998, protocol: { magic: 0xbd6b0cbf // careful, sent over wire as little endian }, // vSeeds seedsDns: [ 'dash.org', 'dnsseed.dash.org', 'dashdot.io', 'dnsseed.dashdot.io', 'masternode.io', 'dnsseed.masternode.io', 'dashpay.io', 'dnsseed.dashpay.io' ], // base58Prefixes versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 5, private: 0xcc, public: 0x4c, scripthash: 0x10 } }, common$4); var test$3 = Object.assign({}, { hashGenesisBlock: '00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c', port: 19999, portRpc: 19998, seedsDns: [ 'dashdot.io', 'testnet-seed.dashdot.io', 'masternode.io', 'test.dnsseed.masternode.io' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xef, public: 0x8c, scripthash: 0x13 } }, common$4); var dash = { main: main$4, test: test$3 }; var common$5 = { name: 'Decred', unit: 'DCR' }; // https://github.com/decred/dcrd/blob/ef71103c95cbf77e5a0418e3d413b5906e710b25/chaincfg/params.go // https://github.com/decred/bitcore/blob/a92381b2b0023b28a1b7eb03e6cb0bfb7800200d/lib/networks.js var main$5 = Object.assign({}, { hashGenesisBlock: '298e5cc3d985bfe7f81dc135f360abe089edd4396b86d2de66b0cef42b21d980', port: 9108, portRpc: 9109, protocol: { magic: 0xf900b4d9 }, seedsDns: [ 'mainnet-seed.decred.mindcry.org', 'mainnet-seed.decred.netpurgatory.com', 'mainnet.decredseed.org', 'mainnet-seed.decred.org' ], versions: { bip32: { private: 0x02fda4e8, public: 0x02fda926 }, bip44: 42, private: 0x22de, public: 0x073f, scripthash: 0x071a } }, common$5); var test$4 = Object.assign({}, { hashGenesisBlock: '5b7466edf6739adc9b32aaedc54e24bdc59a05f0ced855088835fe3cbe58375f', port: 19108, portRpc: 19109, protocol: { magic: 0x48e7a065 }, seedsDns: [ 'testnet-seed.decred.mindcry.org', 'testnet-seed.decred.netpurgatory.org', 'testnet.decredseed.org', 'testnet-seed.decred.org' ], versions: { bip32: { private: 0x04358397, public: 0x043587d1 }, bip44: 42, private: 0x230e, public: 0x0f21, scripthash: 0x0efc } }, common$5); var dcr = { main: main$5, test: test$4 }; /* info from: https://github.com/digibyte/digibyte/blob/9e4c0b3ddfd10a7ab852240ff716a7b93af89a07/src/chainparams.cpp */ var common$6 = { name: 'DigiByte', per1: 1e8, unit: 'DGB' }; var main$6 = Object.assign({}, { hashGenesisBlock: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', // nDefaultPort port: 12024, portRpc: 14022, protocol: { // pchMessageStart magic: 0xfac3b6da // careful, sent over wire as little endian }, bech32: 'dgb', // vSeeds seedsDns: [ 'seed.digibyte.io', 'digiexplorer.info', 'digihash.co' ], // base58Prefixes versions: { bip44: 0x80000014, private: 0x80, public: 0x1e, scripthash: 0x3f, // new 'S' prefix scripthash2: 0x05 // old '3' prefix } }, common$6); var dgb = { main: main$6 }; // https://github.com/dogecoin/dogecoin/blob/master/src/chainparams.cpp var common$7 = { name: 'Dogecoin', unit: 'DOGE' }; var main$7 = Object.assign({}, { hashGenesisBlock: '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691', port: 22556, protocol: { magic: 0xc0c0c0c0 }, seedsDns: [ 'seed.dogecoin.com', 'seed.multidoge.org', 'seed2.multidoge.org', 'seed.doger.dogecoin.com' ], versions: { bip32: { private: 0x02fac398, public: 0x02facafd }, bip44: 3, private: 0x9e, public: 0x1e, scripthash: 0x16 } }, common$7); var test$5 = Object.assign({}, { hashGenesisBlock: 'bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e', versions: { bip44: 1, private: 0xf1, public: 0x71, scripthash: 0xc4 } }, common$7); var doge = { main: main$7, test: test$5 }; // https://github.com/litecoin-project/litecoin/blob/master-0.10/src/chainparams.cpp var common$8 = { name: 'Litecoin', unit: 'LTC' }; var main$8 = Object.assign({}, { hashGenesisBlock: '12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2', port: 9333, protocol: { magic: 0xdbb6c0fb }, bech32: 'ltc', seedsDns: [ 'dnsseed.litecointools.com', 'dnsseed.litecoinpool.org', 'dnsseed.ltc.xurious.com', 'dnsseed.koin-project.com', 'dnsseed.weminemnc.com' ], versions: { bip32: { private: 0x019d9cfe, public: 0x019da462 }, bip44: 2, private: 0xb0, public: 0x30, scripthash: 0x32, scripthash2: 0x05 // old '3' prefix. available for backward compatibility. } }, common$8); var test$6 = Object.assign({}, { hashGenesisBlock: 'f5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f', bech32: 'tltc', versions: { bip32: { private: 0x0436ef7d, public: 0x0436f6e1 }, bip44: 1, private: 0xef, public: 0x6f, scripthash: 0x3a, scripthash2: 0xc4 } }, common$8); var ltc = { main: main$8, test: test$6 }; // https://github.com/viacoin/viacoin/blob/master/src/chainparams.cpp var common$9 = { name: 'Viacoin', unit: 'VIA' }; var main$9 = Object.assign({}, { hashGenesisBlock: '4e9b54001f9976049830128ec0331515eaabe35a70970d79971da1539a400ba1', port: 5223, protocol: { magic: 0xcbc6680f }, seedsDns: [ 'seed.viacoin.net', 'viaseeder.barbatos.fr', 'mainnet.viacoin.net' ], versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 14, private: 0xc7, public: 0x47, scripthash: 0x21 } }, common$9); var test$7 = Object.assign({}, { hashGenesisBlock: '770aa712aa08fdcbdecc1c8df1b3e2d4e17a7cf6e63a28b785b32e74c96cb27d', port: 25223, protocol: { magic: 0x92efc5a9 }, seedsDns: [ 'testnet.viacoin.net', 'seed-testnet.viacoin.net' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xff, public: 0x7f, scripthash: 0xc4 } }, common$9); var via = { main: main$9, test: test$7 }; // https://github.com/monacoinproject/monacoin/blob/master-0.13/src/chainparams.cpp var common$a = { name: 'Monacoin', unit: 'MONA' }; var main$a = Object.assign({}, { hashGenesisBlock: 'ff9f1c0116d19de7c9963845e129f9ed1bfc0b376eb54fd7afa42e0d418c8bb6', port: 9401, portRpc: 9402, protocol: { magic: 0xdbb6c0fb }, bech32: 'mona', seedsDns: [ 'dnsseed.monacoin.org' ], versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 22, private: 0xb0, private2: 0xb2, // old wif public: 0x32, scripthash: 0x37, scripthash2: 0x05 // old '3' prefix. available for backward compatibility. } }, common$a); var test$8 = Object.assign({}, { hashGenesisBlock: 'a2b106ceba3be0c6d097b2a6a6aacf9d638ba8258ae478158f449c321061e0b2', port: 19403, portRpc: 19402, protocol: { magic: 0xf1c8d2fd }, bech32: 'tmona', seedsDns: [ 'testnet-dnsseed.monacoin.org' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xef, public: 0x6f, scripthash: 0x75, scripthash2: 0xc4 } }, common$a); var mona = { main: main$a, test: test$8 }; var common$b = { name: 'NuBits', per1: 1e6, unit: 'NBT' }; var main$b = Object.assign({}, { hashGenesisBlock: '000003cc2da5a0a289ad0a590c20a8b975219ddc1204efd169e947dd4cbad73f', // nDefaultPort port: 7890, portRpc: 14002, protocol: { // pchMessageStart magic: 0xd9b4bef9 // careful, sent over wire as little endian }, // vSeeds seedsDns: [ ], // base58Prefixes versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 12, private: 0x96, public: 0x19, scripthash: 0x1a } }, common$b); var nbt = { main: main$b }; var common$c = { name: 'Namecoin', unit: 'NMC' }; var main$c = Object.assign({}, { hashGenesisBlock: '000000000062b72c5e2ceb45fbc8587e807c155b0da735e6483dfba2f0a9c770', versions: { bip44: 7, private: 0xb4, public: 0x34, scripthash: 0x05 } }, common$c); var nmc = { main: main$c, test: null }; // https://github.com/peercoin/peercoin/tree/v0.7.0ppc/src // https://github.com/peercoin/peercoin/blob/v0.7.0ppc/src/${filename} var common$d = { name: 'Peercoin', per1: 1e6, // util.h:40 unit: 'PPC', messagePrefix: '\x18Peercoin Signed Message:\n' // main.cpp:77 }; var main$d = Object.assign({}, { hashGenesisBlock: '0000000032fe677166d54963b62a4677d8957e87c508eaa4fd7eb1c880cd27e3', // main.h:84 // nDefaultPort port: 9901, // protocol.h:18 portRpc: 9902, // protocol.h:19 protocol: { // pchMessageStart magic: 0xe5e9e8e6 // careful, sent over wire as little endian protocol.cpp:31 }, // vSeeds seedsDns: [ // net.cpp:1209 'seed.peercoin.net', 'seed2.peercoin.net', 'seed.peercoin-library.org', 'ppcseed.ns.7server.net' ], versions: { // not implemented in Peercoin <= v0.7.x nodes, only 3rd party wallets // https://github.com/jmacwhyte/recovery-phrase-recovery/blob/52073aba08e9d01032c0b5aff8c682911fe2e5fc/js/bitcoinjs-extensions.js#L58 bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 6, // https://github.com/satoshilabs/slips/blob/master/slip-0044.md private: 0xb7, // base58.h:402 ; 128 + PUBKEY_ADDRESS public: 0x37, // base58.h:276 scripthash: 0x75 // base58.h:277 } }, common$d); var test$9 = Object.assign({}, { hashGenesisBlock: '00000001f757bb737f6596503e17cd17b0658ce630cc727c0cca81aec47c9f06', port: 9903, portRpc: 9904, protocol: { magic: 0xefc0f2cb }, seedsDns: [ 'tseed.peercoin.net', 'tseed2.peercoin.net', 'tseed.peercoin-library.org' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common$d); var ppc = { main: main$d, test: test$9 }; /* info from: https://github.com/qtumproject/qtum/blob/master/src/chainparams.cpp */ var common$e = { name: 'Qtum', unit: 'QTUM' }; var main$e = Object.assign({}, { hashGenesisBlock: '000075aef83cf2853580f8ae8ce6f8c3096cfa21d98334d6e3f95e5582ed986c', // nDefaultPort port: 3888, protocol: { // pchMessageStart magic: 0xd3a6cff1 // careful, sent over wire as little endian }, bech32: 'qc', // vSeeds seedsDns: [ 'qtum3.dynu.net' ], // base58Prefixes versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 2301, private: 0x80, public: 0x3A, scripthash: 0x32 } }, common$e); var qtum = { main: main$e }; // https://github.com/RavenProject/Ravencoin/blob/master/src/chainparams.cpp var common$f = { name: 'Ravencoin', unit: 'RVN' }; var main$f = Object.assign({}, { hashGenesisBlock: '0000006b444bc2f2ffe627be9d9e7e7a0730000870ef6eb6da46c8eae389df90', port: 8767, protocol: { magic: 0x4e564152 }, seedsDns: [ 'seed-raven.bitactivate.com', 'seed-raven.ravencoin.com', 'seed-raven.ravencoin.org' ], versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 175, private: 0x80, public: 0x3c, scripthash: 0x7a } }, common$f); var test$a = Object.assign({}, { hashGenesisBlock: '000000ecfc5e6324a079542221d00e10362bdc894d56500c414060eea8a3ad5a', port: 18770, protocol: { magic: 0x544e5652 }, seedsDns: [ 'seed-testnet-raven.bitactivate.com', 'seed-testnet-raven.ravencoin.com', 'seed-testnet-raven.ravencoin.org' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 1, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common$f); var rvn = { main: main$f, test: test$a }; var common$g = { name: 'ReddCoin', unit: 'RDD' }; var main$g = Object.assign({}, { hashGenesisBlock: 'b868e0d95a3c3c0e0dadc67ee587aaf9dc8acbf99e3b4b3110fad4eb74c1decc', versions: { bip44: 4, private: 0xbd, public: 0x3d, scripthash: 0x05 } }, common$g); var test$b = Object.assign({}, { hashGenesisBlock: 'a12ac9bd4cd26262c53a6277aafc61fe9dfe1e2b05eaa1ca148a5be8b394e35a', versions: { bip44: 1, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common$g); var rdd = { main: main$g, test: test$b }; /* info from: https://github.com/vertcoin/vertcoin/blob/master/src/chainparams.cpp */ var common$h = { name: 'Vertcoin', unit: 'VTC' }; var main$h = Object.assign({}, { hashGenesisBlock: '4d96a915f49d40b1e5c2844d1ee2dccb90013a990ccea12c492d22110489f0c4', // nDefaultPort port: 5889, protocol: { // pchMessageStart magic: 0xdab5bffa // careful, sent over wire as little endian }, bech32: 'vtc', // vSeeds seedsDns: [ 'useast1.vtconline.org', 'vtc.gertjaap.org', 'seed.vtc.bryangoodson.org', 'dnsseed.pknight.ca', 'seed.orderofthetaco.org', 'seed.alexturek.org', 'vertcoin.mbl.cash' ], // base58Prefixes versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 28, private: 0x80, public: 0x47, scripthash: 0x05 } }, common$h); var test$c = Object.assign({}, { hashGenesisBlock: 'cee8f24feb7a64c8f07916976aa4855decac79b6741a8ec2e32e2747497ad2c9', port: 15889, // portRpc: 18332, protocol: { magic: 0x74726576 }, bech32: 'tvtc', seedsDns: [ 'jlovejoy.mit.edu', 'gertjaap.ddns.net', 'fr1.vtconline.org', 'tvtc.vertcoin.org' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, private: 0xef, public: 0x4a, scripthash: 0xc4 } }, common$h); var regtest$2 = Object.assign({}, { hashGenesisBlock: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', port: 18444, // portRpc: 18332, protocol: { magic: 0xdab5bffa }, seedsDns: [], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, private: 0xef, public: 0x6f, scripthash: 0xc4 } }, common$h); var vtc = { main: main$h, test: test$c, regtest: regtest$2 }; /* info from: https://github.com/zcash/zcash/blob/v1.0.12/src/chainparamsbase.cpp https://github.com/zcash/zcash/blob/v1.0.12/src/chainparams.cpp */ var common$i = { name: 'Zcash', unit: 'ZEC' }; var main$i = Object.assign({}, { hashGenesisBlock: '00040fe8ec8471911baa1db1266ea15dd06b4a8a5c453883c000b031973dce08', // nDefaultPort port: 8233, portRpc: 8232, protocol: { // pchMessageStart magic: 0x6427e924 // careful, sent over wire as little endian }, // vSeeds seedsDns: [ 'dnsseed.z.cash', 'dnsseed.str4d.xyz', 'dnsseed.znodes.org' ], // base58Prefixes versions: { bip32: { private: 0x0488ade4, public: 0x0488b21e }, bip44: 133, private: 0x80, public: 0x1cb8, scripthash: 0x1cbd } }, common$i); var test$d = Object.assign({}, { hashGenesisBlock: '0x05a60a92d99d85997cce3b87616c089f6124d7342af37106edc76126334a2c38', port: 18233, portRpc: 18232, protocol: { magic: 0xbff91afa }, seedsDns: [ 'dnsseed.testnet.z.cash' ], versions: { bip32: { private: 0x04358394, public: 0x043587cf }, bip44: 133, private: 0xef, public: 0x1d25, scripthash: 0x1cba } }, common$i); var zec = { main: main$i, test: test$d }; var Buffer$1 = safeBuffer.Buffer; // annoyingly, this is for browserify var coins = [ bch, blk, btc, btg, dash, dcr, dgb, doge, ltc, via, mona, nbt, nmc, ppc, qtum, rvn, rdd, vtc, zec ]; var supportedCoins = {}; coins.forEach(function (coin) { var unit = coin.main.unit.toLowerCase(); var name = coin.main.name.toLowerCase(); coin.main.testnet = false; coin.main.toBitcoinJS = toBitcoinJS.bind(coin.main); coin.main.toBitcore = toBitcore.bind(coin.main); supportedCoins[unit] = coin.main; supportedCoins[name] = coin.main; if (coin.test) { coin.test.testnet = true; coin.test.toBitcoinJS = toBitcoinJS.bind(coin.test); coin.test.toBitcore = toBitcore.bind(coin.test); supportedCoins[unit + '-test'] = coin.test; supportedCoins[name + '-test'] = coin.test; } if (coin.regtest) { coin.regtest.testnet = true; coin.regtest.toBitcoinJS = toBitcoinJS.bind(coin.regtest); coin.regtest.toBitcore = toBitcore.bind(coin.regtest); supportedCoins[unit + '-regtest'] = coin.regtest; supportedCoins[name + '-regtest'] = coin.regtest; } }); function coininfo (input) { var coin = input.toLowerCase(); if (!(coin in supportedCoins)) { return null } else { return supportedCoins[coin] } } coins.forEach(function (coin) { coininfo[coin.main.name.toLowerCase()] = coin; }); function toBitcoinJS () { return Object.assign({}, this, { messagePrefix: this.messagePrefix || ('\x19' + this.name + ' Signed Message:\n'), bech32: this.bech32, bip32: { public: (this.versions.bip32 || {}).public, private: (this.versions.bip32 || {}).private }, pubKeyHash: this.versions.public, scriptHash: this.versions.scripthash, wif: this.versions.private, dustThreshold: null // TODO }) } function toBitcore () { // reverse magic var nm = Buffer$1.allocUnsafe(4); nm.writeUInt32BE(this.protocol ? this.protocol.magic : 0, 0); nm = nm.readUInt32LE(0); return Object.assign({}, this, { name: this.testnet ? 'testnet' : 'livenet', alias: this.testnet ? 'testnet' : 'mainnet', pubkeyhash: this.versions.public, privatekey: this.versions.private, scripthash: this.versions.scripthash, xpubkey: (this.versions.bip32 || {}).public, xprivkey: (this.versions.bip32 || {}).private, networkMagic: nm, port: this.port, dnsSeeds: this.seedsDns || [] }) } var coininfo_1 = coininfo; var bignumber = createCommonjsModule(function (module) { (function (globalObject) { /* * bignumber.js v9.0.1 * A JavaScript library for arbitrary-precision arithmetic. * https://github.com/MikeMcl/bignumber.js * Copyright (c) 2020 Michael Mclaughlin <M8ch88l@gmail.com> * MIT Licensed. * * BigNumber.prototype methods | BigNumber methods * | * absoluteValue abs | clone * comparedTo | config set * decimalPlaces dp | DECIMAL_PLACES * dividedBy div | ROUNDING_MODE * dividedToIntegerBy idiv | EXPONENTIAL_AT * exponentiatedBy pow | RANGE * integerValue | CRYPTO * isEqualTo eq | MODULO_MODE * isFinite | POW_PRECISION * isGreaterThan gt | FORMAT * isGreaterThanOrEqualTo gte | ALPHABET * isInteger | isBigNumber * isLessThan lt | maximum max * isLessThanOrEqualTo lte | minimum min * isNaN | random * isNegative | sum * isPositive | * isZero | * minus | * modulo mod | * multipliedBy times | * negated | * plus | * precision sd | * shiftedBy | * squareRoot sqrt | * toExponential | * toFixed | * toFormat | * toFraction | * toJSON | * toNumber | * toPrecision | * toString | * valueOf | * */ var BigNumber, isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = '[BigNumber Error] ', tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ', BASE = 1e14, LOG_BASE = 14, MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1 // MAX_INT32 = 0x7fffffff, // 2^31 - 1 POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], SQRT_BASE = 1e7, // EDITABLE // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and // the arguments to toExponential, toFixed, toFormat, and toPrecision. MAX = 1E9; // 0 to MAX_INT32 /* * Create and return a BigNumber constructor. */ function clone(configObject) { var div, convertBase, parseNumeric, P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null }, ONE = new BigNumber(1), //----------------------------- EDITABLE CONFIG DEFAULTS ------------------------------- // The default values below must be integers within the inclusive ranges stated. // The values can also be changed at run-time using BigNumber.set. // The maximum number of decimal places for operations involving division. DECIMAL_PLACES = 20, // 0 to MAX // The rounding mode used when rounding to the above decimal places, and when using // toExponential, toFixed, toFormat and toPrecision, and round (default value). // UP 0 Away from zero. // DOWN 1 Towards zero. // CEIL 2 Towards +Infinity. // FLOOR 3 Towards -Infinity. // HALF_UP 4 Towards nearest neighbour. If equidistant, up. // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. ROUNDING_MODE = 4, // 0 to 8 // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS] // The exponent value at and beneath which toString returns exponential notation. // Number type: -7 TO_EXP_NEG = -7, // 0 to -MAX // The exponent value at and above which toString returns exponential notation. // Number type: 21 TO_EXP_POS = 21, // 0 to MAX // RANGE : [MIN_EXP, MAX_EXP] // The minimum exponent value, beneath which underflow to zero occurs. // Number type: -324 (5e-324) MIN_EXP = -1e7, // -1 to -MAX // The maximum exponent value, above which overflow to Infinity occurs. // Number type: 308 (1.7976931348623157e+308) // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow. MAX_EXP = 1e7, // 1 to MAX // Whether to use cryptographically-secure random number generation, if available. CRYPTO = false, // true or false // The modulo mode used when calculating the modulus: a mod n. // The quotient (q = a / n) is calculated according to the corresponding rounding mode. // The remainder (r) is calculated as: r = a - n * q. // // UP 0 The remainder is positive if the dividend is negative, else is negative. // DOWN 1 The remainder has the same sign as the dividend. // This modulo mode is commonly known as 'truncated division' and is // equivalent to (a % n) in JavaScript. // FLOOR 3 The remainder has the same sign as the divisor (Python %). // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function. // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). // The remainder is always positive. // // The truncated division, floored division, Euclidian division and IEEE 754 remainder // modes are commonly used for the modulus operation. // Although the other rounding modes can also be used, they may not give useful results. MODULO_MODE = 1, // 0 to 9 // The maximum number of significant digits of the result of the exponentiatedBy operation. // If POW_PRECISION is 0, there will be unlimited significant digits. POW_PRECISION = 0, // 0 to MAX // The format specification used by the BigNumber.prototype.toFormat method. FORMAT = { prefix: '', groupSize: 3, secondaryGroupSize: 0, groupSeparator: ',', decimalSeparator: '.', fractionGroupSize: 0, fractionGroupSeparator: '\xA0', // non-breaking space suffix: '' }, // The alphabet used for base conversion. It must be at least 2 characters long, with no '+', // '-', '.', whitespace, or repeated character. // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'; //------------------------------------------------------------------------------------------ // CONSTRUCTOR /* * The BigNumber constructor and exported function. * Create and return a new instance of a BigNumber object. * * v {number|string|BigNumber} A numeric value. * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive. */ function BigNumber(v, b) { var alphabet, c, caseChanged, e, i, isNum, len, str, x = this; // Enable constructor call without `new`. if (!(x instanceof BigNumber)) return new BigNumber(v, b); if (b == null) { if (v && v._isBigNumber === true) { x.s = v.s; if (!v.c || v.e > MAX_EXP) { x.c = x.e = null; } else if (v.e < MIN_EXP) { x.c = [x.e = 0]; } else { x.e = v.e; x.c = v.c.slice(); } return; } if ((isNum = typeof v == 'number') && v * 0 == 0) { // Use `1 / n` to handle minus zero also. x.s = 1 / v < 0 ? (v = -v, -1) : 1; // Fast path for integers, where n < 2147483648 (2**31). if (v === ~~v) { for (e = 0, i = v; i >= 10; i /= 10, e++); if (e > MAX_EXP) { x.c = x.e = null; } else { x.e = e; x.c = [v]; } return; } str = String(v); } else { if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum); x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1; } // Decimal point? if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); // Exponential form? if ((i = str.search(/e/i)) > 0) { // Determine exponent. if (e < 0) e = i; e += +str.slice(i + 1); str = str.substring(0, i); } else if (e < 0) { // Integer. e = str.length; } } else { // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' intCheck(b, 2, ALPHABET.length, 'Base'); // Allow exponential notation to be used with base 10 argument, while // also rounding to DECIMAL_PLACES as with other bases. if (b == 10) { x = new BigNumber(v); return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE); } str = String(v); if (isNum = typeof v == 'number') { // Avoid potential interpretation of Infinity and NaN as base 44+ values. if (v * 0 != 0) return parseNumeric(x, str, isNum, b); x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1; // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) { throw Error (tooManyDigits + v); } } else { x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1; } alphabet = ALPHABET.slice(0, b); e = i = 0; // Check that str is a valid base b number. // Don't use RegExp, so alphabet can contain special characters. for (len = str.length; i < len; i++) { if (alphabet.indexOf(c = str.charAt(i)) < 0) { if (c == '.') { // If '.' is not the first character and it has not be found before. if (i > e) { e = len; continue; } } else if (!caseChanged) { // Allow e.g. hexadecimal 'FF' as well as 'ff'. if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) { caseChanged = true; i = -1; e = 0; continue; } } return parseNumeric(x, String(v), isNum, b); } } // Prevent later check for length on converted number. isNum = false; str = convertBase(str, b, 10, x.s); // Decimal point? if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); else e = str.length; } // Determine leading zeros. for (i = 0; str.charCodeAt(i) === 48; i++); // Determine trailing zeros. for (len = str.length; str.charCodeAt(--len) === 48;); if (str = str.slice(i, ++len)) { len -= i; // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' if (isNum && BigNumber.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) { throw Error (tooManyDigits + (x.s * v)); } // Overflow? if ((e = e - i - 1) > MAX_EXP) { // Infinity. x.c = x.e = null; // Underflow? } else if (e < MIN_EXP) { // Zero. x.c = [x.e = 0]; } else { x.e = e; x.c = []; // Transform base // e is the base 10 exponent. // i is where to slice str to get the first element of the coefficient array. i = (e + 1) % LOG_BASE; if (e < 0) i += LOG_BASE; // i < 1 if (i < len) { if (i) x.c.push(+str.slice(0, i)); for (len -= LOG_BASE; i < len;) { x.c.push(+str.slice(i, i += LOG_BASE)); } i = LOG_BASE - (str = str.slice(i)).length; } else { i -= len; } for (; i--; str += '0'); x.c.push(+str); } } else { // Zero. x.c = [x.e = 0]; } } // CONSTRUCTOR PROPERTIES BigNumber.clone = clone; BigNumber.ROUND_UP = 0; BigNumber.ROUND_DOWN = 1; BigNumber.ROUND_CEIL = 2; BigNumber.ROUND_FLOOR = 3; BigNumber.ROUND_HALF_UP = 4; BigNumber.ROUND_HALF_DOWN = 5; BigNumber.ROUND_HALF_EVEN = 6; BigNumber.ROUND_HALF_CEIL = 7; BigNumber.ROUND_HALF_FLOOR = 8; BigNumber.EUCLID = 9; /* * Configure infrequently-changing library-wide settings. * * Accept an object with the following optional properties (if the value of a property is * a number, it must be an integer within the inclusive range stated): * * DECIMAL_PLACES {number} 0 to MAX * ROUNDING_MODE {number} 0 to 8 * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX] * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX] * CRYPTO {boolean} true or false * MODULO_MODE {number} 0 to 9 * POW_PRECISION {number} 0 to MAX * ALPHABET {string} A string of two or more unique characters which does * not contain '.'. * FORMAT {object} An object with some of the following properties: * prefix {string} * groupSize {number} * secondaryGroupSize {number} * groupSeparator {string} * decimalSeparator {string} * fractionGroupSize {number} * fractionGroupSeparator {string} * suffix {string} * * (The values assigned to the above FORMAT object properties are not checked for validity.) * * E.g. * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 }) * * Ignore properties/parameters set to null or undefined, except for ALPHABET. * * Return an object with the properties current values. */ BigNumber.config = BigNumber.set = function (obj) { var p, v; if (obj != null) { if (typeof obj == 'object') { // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive. // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}' if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) { v = obj[p]; intCheck(v, 0, MAX, p); DECIMAL_PLACES = v; } // ROUNDING_MODE {number} Integer, 0 to 8 inclusive. // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}' if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) { v = obj[p]; intCheck(v, 0, 8, p); ROUNDING_MODE = v; } // EXPONENTIAL_AT {number|number[]} // Integer, -MAX to MAX inclusive or // [integer -MAX to 0 inclusive, 0 to MAX inclusive]. // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}' if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) { v = obj[p]; if (v && v.pop) { intCheck(v[0], -MAX, 0, p); intCheck(v[1], 0, MAX, p); TO_EXP_NEG = v[0]; TO_EXP_POS = v[1]; } else { intCheck(v, -MAX, MAX, p); TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v); } } // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive]. // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}' if (obj.hasOwnProperty(p = 'RANGE')) { v = obj[p]; if (v && v.pop) { intCheck(v[0], -MAX, -1, p); intCheck(v[1], 1, MAX, p); MIN_EXP = v[0]; MAX_EXP = v[1]; } else { intCheck(v, -MAX, MAX, p); if (v) { MIN_EXP = -(MAX_EXP = v < 0 ? -v : v); } else { throw Error (bignumberError + p + ' cannot be zero: ' + v); } } } // CRYPTO {boolean} true or false. // '[BigNumber Error] CRYPTO not true or false: {v}' // '[BigNumber Error] crypto unavailable' if (obj.hasOwnProperty(p = 'CRYPTO')) { v = obj[p]; if (v === !!v) { if (v) { if (typeof crypto != 'undefined' && crypto && (crypto.getRandomValues || crypto.randomBytes)) { CRYPTO = v; } else { CRYPTO = !v; throw Error (bignumberError + 'crypto unavailable'); } } else { CRYPTO = v; } } else { throw Error (bignumberError + p + ' not true or false: ' + v); } } // MODULO_MODE {number} Integer, 0 to 9 inclusive. // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}' if (obj.hasOwnProperty(p = 'MODULO_MODE')) { v = obj[p]; intCheck(v, 0, 9, p); MODULO_MODE = v; } // POW_PRECISION {number} Integer, 0 to MAX inclusive. // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}' if (obj.hasOwnProperty(p = 'POW_PRECISION')) { v = obj[p]; intCheck(v, 0, MAX, p); POW_PRECISION = v; } // FORMAT {object} // '[BigNumber Error] FORMAT not an object: {v}' if (obj.hasOwnProperty(p = 'FORMAT')) { v = obj[p]; if (typeof v == 'object') FORMAT = v; else throw Error (bignumberError + p + ' not an object: ' + v); } // ALPHABET {string} // '[BigNumber Error] ALPHABET invalid: {v}' if (obj.hasOwnProperty(p = 'ALPHABET')) { v = obj[p]; // Disallow if less than two characters, // or if it contains '+', '-', '.', whitespace, or a repeated character. if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) { ALPHABET = v; } else { throw Error (bignumberError + p + ' invalid: ' + v); } } } else { // '[BigNumber Error] Object expected: {v}' throw Error (bignumberError + 'Object expected: ' + obj); } } return { DECIMAL_PLACES: DECIMAL_PLACES, ROUNDING_MODE: ROUNDING_MODE, EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS], RANGE: [MIN_EXP, MAX_EXP], CRYPTO: CRYPTO, MODULO_MODE: MODULO_MODE, POW_PRECISION: POW_PRECISION, FORMAT: FORMAT, ALPHABET: ALPHABET }; }; /* * Return true if v is a BigNumber instance, otherwise return false. * * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed. * * v {any} * * '[BigNumber Error] Invalid BigNumber: {v}' */ BigNumber.isBigNumber = funct