diff --git a/addresses.js b/addresses.js index 4361cc4..0e37042 100644 --- a/addresses.js +++ b/addresses.js @@ -24,11 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const assert_1 = require("assert"); -const curve = __importStar(require("tiny-secp256k1")); const bitcoin = __importStar(require("bitcoinjs-lib")); +const ecpair_1 = require("ecpair"); const sha3_1 = require("sha3"); +const curve = __importStar(require("tiny-secp256k1")); const btc_1 = require("./btc"); -const ecpair_1 = require("ecpair"); const descriptors_1 = require("./descriptors"); const mainnet = bitcoin.networks.bitcoin; const testnet = bitcoin.networks.testnet; diff --git a/addresses.ts b/addresses.ts index 17ab750..62be251 100644 --- a/addresses.ts +++ b/addresses.ts @@ -1,9 +1,9 @@ import { strict as assert } from 'assert'; -import * as curve from 'tiny-secp256k1'; import * as bitcoin from 'bitcoinjs-lib'; +import { ECPairFactory, ECPairInterface } from 'ecpair'; import { Keccak } from 'sha3'; +import * as curve from 'tiny-secp256k1'; import { input } from './btc'; -import { ECPairFactory, ECPairInterface } from 'ecpair'; import { descsumCreate } from './descriptors'; const mainnet = bitcoin.networks.bitcoin; diff --git a/btc.js b/btc.js index 265dbb1..e4c8249 100644 --- a/btc.js +++ b/btc.js @@ -25,13 +25,13 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.sleep = exports.input = exports.inputOnEOF = exports.toBTCkvB = exports.toSatvB = exports.toBTC = exports.toSat = exports.txidToString = exports.cloneBuf = exports.p2pkh = exports.bech32toScriptPubKey = exports.insertTransaction = exports.removeTransaction = exports.decodeVarUintLE = exports.encodeVarUintLE = exports.createTaprootOutput = exports.bip86 = exports.tapTweak = exports.tapBranch = exports.tapLeaf = exports.ecPrivateDiv = exports.ecPrivateInv = exports.ecPrivateMul = exports.negateIfOddPubkey = exports.OP_CHECKSIGADD = exports.validNetworks = exports.fundAddress = exports.fundOutputScript = exports.getBlockChainInfo = exports.getIndexInfo = exports.getChainTips = exports.testMempoolAccept = exports.getTransaction = exports.getTXOut = exports.decodeRawTransaction = exports.getBlockTemplate = exports.getnewaddress = exports.listUnspent = exports.listunspent = exports.send = exports.fundTransaction = exports.signAndSend = exports.newtx = exports.btc = exports.chainEnvVarKey = exports.setChain = exports.network = exports.networks = exports.Uint256 = exports.descsumCreate = void 0; exports.consoleTrace = void 0; -const child_process_1 = require("child_process"); +const assert_1 = require("assert"); const bitcoin = __importStar(require("bitcoinjs-lib")); -const curve = __importStar(require("tiny-secp256k1")); +const child_process_1 = require("child_process"); +const ecpair_1 = require("ecpair"); const readline_1 = require("readline"); const stream_1 = require("stream"); -const ecpair_1 = require("ecpair"); -const assert_1 = require("assert"); +const curve = __importStar(require("tiny-secp256k1")); var descriptors_1 = require("./descriptors"); Object.defineProperty(exports, "descsumCreate", { enumerable: true, get: function () { return descriptors_1.descsumCreate; } }); const ECPair = (0, ecpair_1.ECPairFactory)(curve); diff --git a/btc.ts b/btc.ts index 22a78f5..7e90788 100644 --- a/btc.ts +++ b/btc.ts @@ -1,10 +1,10 @@ -import { spawn } from 'child_process'; +import { strict as assert } from 'assert'; import * as bitcoin from 'bitcoinjs-lib'; -import * as curve from 'tiny-secp256k1'; +import { spawn } from 'child_process'; +import { ECPairFactory, ECPairInterface } from 'ecpair'; import { createInterface } from 'readline'; import { Writable } from 'stream'; -import { ECPairFactory, ECPairInterface } from 'ecpair'; -import { strict as assert } from 'assert'; +import * as curve from 'tiny-secp256k1'; export { descsumCreate } from './descriptors'; diff --git a/ecdh_stealth.js b/ecdh_stealth.js index 445596c..ab151b7 100644 --- a/ecdh_stealth.js +++ b/ecdh_stealth.js @@ -27,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.StealthAddress = void 0; -const curve = __importStar(require("tiny-secp256k1")); const bitcoin = __importStar(require("bitcoinjs-lib")); const bs58check_1 = __importDefault(require("bs58check")); const crypto_1 = require("crypto"); +const curve = __importStar(require("tiny-secp256k1")); class StealthAddress { constructor(spendKey, viewKey) { if (spendKey.length == 32) { diff --git a/ecdh_stealth.ts b/ecdh_stealth.ts index 3d67635..f0283ab 100644 --- a/ecdh_stealth.ts +++ b/ecdh_stealth.ts @@ -1,7 +1,7 @@ -import * as curve from 'tiny-secp256k1'; import * as bitcoin from 'bitcoinjs-lib'; import bs58check from 'bs58check'; import { randomBytes } from 'crypto'; +import * as curve from 'tiny-secp256k1'; export class StealthAddress { readonly spendPriv?: Buffer; diff --git a/ecdh_stealth_test.js b/ecdh_stealth_test.js index 77048ca..bdb2429 100644 --- a/ecdh_stealth_test.js +++ b/ecdh_stealth_test.js @@ -23,12 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const curve = __importStar(require("tiny-secp256k1")); +const assert_1 = require("assert"); const bitcoin = __importStar(require("bitcoinjs-lib")); -const btc_1 = require("./btc"); const crypto_1 = require("crypto"); -const assert_1 = require("assert"); const ecpair_1 = require("ecpair"); +const curve = __importStar(require("tiny-secp256k1")); +const btc_1 = require("./btc"); const ecdh_stealth_1 = require("./ecdh_stealth"); (0, btc_1.setChain)('regtest'); const network = bitcoin.networks.regtest; diff --git a/ecdh_stealth_test.ts b/ecdh_stealth_test.ts index 80dbbab..8998a29 100644 --- a/ecdh_stealth_test.ts +++ b/ecdh_stealth_test.ts @@ -1,9 +1,9 @@ -import * as curve from 'tiny-secp256k1'; +import { strict as assert } from 'assert'; import * as bitcoin from 'bitcoinjs-lib'; -import { send, setChain, getnewaddress, fundOutputScript, p2pkh } from './btc'; import { randomBytes } from 'crypto'; -import { strict as assert } from 'assert'; import { ECPairFactory } from 'ecpair'; +import * as curve from 'tiny-secp256k1'; +import { fundOutputScript, getnewaddress, p2pkh, send, setChain } from './btc'; import { StealthAddress } from './ecdh_stealth'; setChain('regtest'); diff --git a/ecdsa_sigdata.js b/ecdsa_sigdata.js index c2c60a0..9555c9f 100644 --- a/ecdsa_sigdata.js +++ b/ecdsa_sigdata.js @@ -23,12 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const btc_1 = require("./btc"); -const curve = __importStar(require("tiny-secp256k1")); -const ecpair_1 = require("ecpair"); +const assert_1 = require("assert"); const bitcoin = __importStar(require("bitcoinjs-lib")); const crypto = __importStar(require("crypto")); -const assert_1 = require("assert"); +const ecpair_1 = require("ecpair"); +const curve = __importStar(require("tiny-secp256k1")); +const btc_1 = require("./btc"); (0, btc_1.setChain)('regtest'); const network = bitcoin.networks.regtest; const hashtype = bitcoin.Transaction.SIGHASH_ALL; diff --git a/ecdsa_sigdata.ts b/ecdsa_sigdata.ts index 033a41d..7b0871b 100644 --- a/ecdsa_sigdata.ts +++ b/ecdsa_sigdata.ts @@ -1,9 +1,9 @@ -import { setChain, send, getnewaddress, fundOutputScript, ecPrivateMul, ecPrivateDiv, p2pkh } from './btc'; -import * as curve from 'tiny-secp256k1'; -import { ECPairFactory } from 'ecpair'; +import { strict as assert } from 'assert'; import * as bitcoin from 'bitcoinjs-lib'; import * as crypto from 'crypto'; -import { strict as assert } from 'assert'; +import { ECPairFactory } from 'ecpair'; +import * as curve from 'tiny-secp256k1'; +import { ecPrivateDiv, ecPrivateMul, fundOutputScript, getnewaddress, p2pkh, send, setChain } from './btc'; setChain('regtest'); diff --git a/lightning/lndforcecloser.js b/lightning/lndforcecloser.js index 8a922cd..d7e01d7 100644 --- a/lightning/lndforcecloser.js +++ b/lightning/lndforcecloser.js @@ -23,14 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const bitcoin = __importStar(require("bitcoinjs-lib")); -const btc_1 = require("../btc"); -const curve = __importStar(require("tiny-secp256k1")); -const ecpair_1 = require("ecpair"); +const assert_1 = require("assert"); const bip32_1 = require("bip32"); +const bitcoin = __importStar(require("bitcoinjs-lib")); const child_process_1 = require("child_process"); +const ecpair_1 = require("ecpair"); const os_1 = require("os"); -const assert_1 = require("assert"); +const curve = __importStar(require("tiny-secp256k1")); +const btc_1 = require("../btc"); const channeldb_reader_1 = require("./channeldb_reader"); const ECPair = (0, ecpair_1.ECPairFactory)(curve); const bip32 = (0, bip32_1.BIP32Factory)(curve); diff --git a/lightning/lndforcecloser.ts b/lightning/lndforcecloser.ts index b8e7b11..e30964d 100644 --- a/lightning/lndforcecloser.ts +++ b/lightning/lndforcecloser.ts @@ -1,13 +1,13 @@ -import * as bitcoin from 'bitcoinjs-lib'; -import { btc, setChain, input } from '../btc'; -import * as curve from 'tiny-secp256k1'; -import { ECPairFactory } from 'ecpair'; +import { strict as assert } from 'assert'; import { BIP32Factory } from 'bip32'; +import * as bitcoin from 'bitcoinjs-lib'; import { execSync } from 'child_process'; +import { ECPairFactory } from 'ecpair'; import { homedir } from 'os'; -import { strict as assert } from 'assert'; +import * as curve from 'tiny-secp256k1'; +import { btc, input, setChain } from '../btc'; -import { parseChannelDB, Channel } from './channeldb_reader'; +import { Channel, parseChannelDB } from './channeldb_reader'; const ECPair = ECPairFactory(curve); const bip32 = BIP32Factory(curve); diff --git a/merkle_tree.js b/merkle_tree.js index 453546d..30ba841 100644 --- a/merkle_tree.js +++ b/merkle_tree.js @@ -24,8 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.merkleRoot = exports.pathToMerkleRoot = void 0; -const bitcoin = __importStar(require("bitcoinjs-lib")); const assert_1 = require("assert"); +const bitcoin = __importStar(require("bitcoinjs-lib")); function pathToMerkleRoot(txids, branch) { let t1 = txids.map(txid => { if (!Buffer.isBuffer(txid)) { diff --git a/merkle_tree.ts b/merkle_tree.ts index 19712ed..dc10c98 100644 --- a/merkle_tree.ts +++ b/merkle_tree.ts @@ -1,5 +1,5 @@ -import * as bitcoin from 'bitcoinjs-lib'; import { strict as assert } from 'assert'; +import * as bitcoin from 'bitcoinjs-lib'; type Txid = string | Buffer; diff --git a/miner.js b/miner.js index d06855f..23aedbd 100644 --- a/miner.js +++ b/miner.js @@ -23,15 +23,15 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const child_process_1 = require("child_process"); const bitcoin = __importStar(require("bitcoinjs-lib")); -const btc_1 = require("./btc"); -const merkle_tree_1 = require("./merkle_tree"); +const child_process_1 = require("child_process"); const crypto_1 = require("crypto"); +const ecpair_1 = require("ecpair"); const fs_1 = require("fs"); const path_1 = require("path"); const curve = __importStar(require("tiny-secp256k1")); -const ecpair_1 = require("ecpair"); +const btc_1 = require("./btc"); +const merkle_tree_1 = require("./merkle_tree"); const ECPair = (0, ecpair_1.ECPairFactory)(curve); function readConfig() { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/miner.ts b/miner.ts index ed0dc70..ca5a2e9 100644 --- a/miner.ts +++ b/miner.ts @@ -1,25 +1,24 @@ -import { ChildProcessWithoutNullStreams, spawn } from 'child_process'; import * as bitcoin from 'bitcoinjs-lib'; +import { ChildProcessWithoutNullStreams, spawn } from 'child_process'; +import { randomBytes } from 'crypto'; +import { ECPairFactory } from 'ecpair'; +import { copyFileSync, existsSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from 'fs'; +import { dirname } from 'path'; +import * as curve from 'tiny-secp256k1'; import { - btc, - bech32toScriptPubKey, - getBlockTemplate, BlockTemplate, BlockTemplateTX, TemplateRequest, - consoleTrace, + bech32toScriptPubKey, + btc, + encodeVarUintLE, + getBlockTemplate, insertTransaction, + network, removeTransaction, setChain, - network, - encodeVarUintLE, } from './btc'; import { merkleRoot } from './merkle_tree'; -import { randomBytes } from 'crypto'; -import { writeFileSync, unlinkSync, copyFileSync, readFileSync, readdirSync, existsSync } from 'fs'; -import { dirname } from 'path'; -import * as curve from 'tiny-secp256k1'; -import { ECPairFactory } from 'ecpair'; const ECPair = ECPairFactory(curve); diff --git a/p2tr_ptlc.js b/p2tr_ptlc.js index a2d1aab..5a171c7 100644 --- a/p2tr_ptlc.js +++ b/p2tr_ptlc.js @@ -23,12 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const curve = __importStar(require("tiny-secp256k1")); +const assert_1 = require("assert"); const bitcoin = __importStar(require("bitcoinjs-lib")); -const btc_1 = require("./btc"); -const ecpair_1 = require("ecpair"); const crypto_1 = require("crypto"); -const assert_1 = require("assert"); +const ecpair_1 = require("ecpair"); +const curve = __importStar(require("tiny-secp256k1")); +const btc_1 = require("./btc"); const ECPair = (0, ecpair_1.ECPairFactory)(curve); const network = bitcoin.networks.testnet; const hashtype = bitcoin.Transaction.SIGHASH_DEFAULT; diff --git a/p2tr_ptlc.ts b/p2tr_ptlc.ts index dcd7de1..1a6e4d9 100644 --- a/p2tr_ptlc.ts +++ b/p2tr_ptlc.ts @@ -1,19 +1,19 @@ -import * as curve from 'tiny-secp256k1'; +import { strict as assert } from 'assert'; import * as bitcoin from 'bitcoinjs-lib'; +import { randomBytes } from 'crypto'; +import { ECPairFactory, ECPairInterface } from 'ecpair'; +import * as curve from 'tiny-secp256k1'; import { btc, - send, + cloneBuf, createTaprootOutput, ecPrivateMul, - negateIfOddPubkey, - cloneBuf, input, - tapLeaf, + negateIfOddPubkey, + send, sleep, + tapLeaf, } from './btc'; -import { ECPairFactory, ECPairInterface } from 'ecpair'; -import { randomBytes } from 'crypto'; -import { strict as assert } from 'assert'; const ECPair = ECPairFactory(curve); diff --git a/p2tr_tapscript.js b/p2tr_tapscript.js index 702f8fa..2939bb6 100644 --- a/p2tr_tapscript.js +++ b/p2tr_tapscript.js @@ -23,11 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const curve = __importStar(require("tiny-secp256k1")); const bitcoin = __importStar(require("bitcoinjs-lib")); -const btc_1 = require("./btc"); -const ecpair_1 = require("ecpair"); const crypto_1 = require("crypto"); +const ecpair_1 = require("ecpair"); +const curve = __importStar(require("tiny-secp256k1")); +const btc_1 = require("./btc"); const ECPair = (0, ecpair_1.ECPairFactory)(curve); const network = bitcoin.networks.testnet; const hashtype = bitcoin.Transaction.SIGHASH_DEFAULT; diff --git a/p2tr_tapscript.ts b/p2tr_tapscript.ts index 81b42e5..baa3b36 100644 --- a/p2tr_tapscript.ts +++ b/p2tr_tapscript.ts @@ -1,19 +1,19 @@ -import * as curve from 'tiny-secp256k1'; import * as bitcoin from 'bitcoinjs-lib'; +import { randomBytes } from 'crypto'; +import { ECPairFactory } from 'ecpair'; +import * as curve from 'tiny-secp256k1'; import { - send, bech32toScriptPubKey, + createTaprootOutput, + decodeRawTransaction, fundAddress, getnewaddress, - decodeRawTransaction, negateIfOddPubkey, - tapLeaf, - tapBranch, - createTaprootOutput, OP_CHECKSIGADD, + send, + tapBranch, + tapLeaf, } from './btc'; -import { ECPairFactory } from 'ecpair'; -import { randomBytes } from 'crypto'; const ECPair = ECPairFactory(curve); diff --git a/xpriv.js b/xpriv.js index 49f71ad..2fa3348 100644 --- a/xpriv.js +++ b/xpriv.js @@ -26,12 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -const btc_1 = require("./btc"); -const bitcoin = __importStar(require("bitcoinjs-lib")); const assert_1 = require("assert"); -const bs58 = __importStar(require("bs58")); const bip32_1 = __importDefault(require("bip32")); +const bitcoin = __importStar(require("bitcoinjs-lib")); +const bs58 = __importStar(require("bs58")); const curve = __importStar(require("tiny-secp256k1")); +const btc_1 = require("./btc"); const bip32 = (0, bip32_1.default)(curve); const pad = (s, len) => s + ' '.repeat(len - s.length); const color = (...colors) => (colors.length ? `\x1b[${colors.join(';')}m` : ''); diff --git a/xpriv.ts b/xpriv.ts index cddd03b..eb234d8 100644 --- a/xpriv.ts +++ b/xpriv.ts @@ -1,9 +1,9 @@ -import { input } from './btc'; -import * as bitcoin from 'bitcoinjs-lib'; import { strict as assert } from 'assert'; -import * as bs58 from 'bs58'; import BIP32Factory, { BIP32Interface } from 'bip32'; +import * as bitcoin from 'bitcoinjs-lib'; +import * as bs58 from 'bs58'; import * as curve from 'tiny-secp256k1'; +import { input } from './btc'; const bip32 = BIP32Factory(curve);