-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Config Refresh #4049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Config Refresh #4049
Changes from all commits
a5eb24b
4dc58b0
4344e93
6ccf30e
b858f14
8e4d17a
01bbf5a
4f4dc51
903cb21
66894c5
5bb2f09
44e8381
2e19c59
dc1eb4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| [1mdiff --git a/packages/bitcore-cli/package.json b/packages/bitcore-cli/package.json[m | ||
| [1mindex e291ea3ba..875c2d210 100644[m | ||
| [1m--- a/packages/bitcore-cli/package.json[m | ||
| [1m+++ b/packages/bitcore-cli/package.json[m | ||
| [36m@@ -30,8 +30,7 @@[m | ||
| },[m | ||
| [m | ||
| "scripts": {[m | ||
| [31m- "test": "npm run compile && mocha 'build/test/**/*.js'",[m | ||
| [31m- "coverage": "npm run compile && nyc mocha 'build/test/**/*.js'",[m | ||
| [32m+[m[32m "test": "npm run compile && nyc mocha 'build/test/**/*.js' --timeout 5000",[m | ||
| "build": "tsc",[m | ||
| "postbuild": "node createBin -v",[m | ||
| "clean": "rm -rf ./build",[m | ||
| [1mdiff --git a/packages/bitcore-client/package.json b/packages/bitcore-client/package.json[m | ||
| [1mindex ffe3e25eb..12e2e6ff4 100644[m | ||
| [1m--- a/packages/bitcore-client/package.json[m | ||
| [1m+++ b/packages/bitcore-client/package.json[m | ||
| [36m@@ -23,8 +23,7 @@[m | ||
| "watch": "tsc --watch",[m | ||
| "precompile": "cd ../bitcore-node && npm run clean && npm run build:prod",[m | ||
| "compile": "npm run clean && npm run build",[m | ||
| [31m- "test": "npm run compile && mocha -r tsx --exit 'test/**/*.test.ts'",[m | ||
| [31m- "coverage": "npm run compile && nyc mocha -r tsx --exit 'test/**/*.test.ts'",[m | ||
| [32m+[m[32m "test": "npm run compile && nyc mocha --exit 'ts_build/test/**/*.test.js'",[m | ||
| "precommit": "npm run lint",[m | ||
| "lint": "eslint .",[m | ||
| "fix:errors": "eslint --fix --quiet .",[m | ||
| [1mdiff --git a/packages/bitcore-client/test/unit/wallet.test.ts b/packages/bitcore-client/test/unit/wallet.test.ts[m | ||
| [1mindex a9947ce4e..a75d02ed4 100644[m | ||
| [1m--- a/packages/bitcore-client/test/unit/wallet.test.ts[m | ||
| [1m+++ b/packages/bitcore-client/test/unit/wallet.test.ts[m | ||
| [36m@@ -1,10 +1,10 @@[m | ||
| import * as chai from 'chai';[m | ||
| import * as CWC from '@bitpay-labs/crypto-wallet-core';[m | ||
| import { AddressTypes, Wallet } from '../../src/wallet';[m | ||
| [31m-import { Api as bcnApi } from '../../../bitcore-node/build/src/services/api';[m | ||
| [31m-import { Storage as bcnStorage } from '../../../bitcore-node/build/src/services/storage';[m | ||
| [32m+[m[32mimport { Api as bcnApi } from '../../../bitcore-node/src/services/api';[m | ||
| [32m+[m[32mimport { Storage as bcnStorage } from '../../../bitcore-node/src/services/storage';[m | ||
| import crypto from 'crypto';[m | ||
| [31m-import { Modules } from '../../../bitcore-node/build/src/modules';[m | ||
| [32m+[m[32mimport { Modules } from '../../../bitcore-node/src/modules';[m | ||
| import request from 'request-promise-native';[m | ||
| import requestStream from 'request';[m | ||
| import { Server } from 'http';[m | ||
| [36m@@ -136,7 +136,7 @@[m [mdescribe('Wallet', function() {[m | ||
| expect(err.message).to.equal('Must provide changeIdx for UTXO chains');[m | ||
| }[m | ||
| });[m | ||
| [31m- [m | ||
| [32m+[m | ||
| it('should throw an error if neither rawTx nor txid is provided', async () => {[m | ||
| try {[m | ||
| await wallet.bumpTxFee({ changeIdx: 0 });[m | ||
| [36m@@ -171,12 +171,12 @@[m [mdescribe('Wallet', function() {[m | ||
| sandbox.stub(wallet, 'getTransactionByTxid').resolves({ '_id': '65982807d85e75f781a0d56f', 'txid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'network': 'regtest', 'chain': 'BTC', 'blockHeight': -1, 'blockHash': '', 'blockTime': '2024-01-05T16:02:15.678Z', 'blockTimeNormalized': '2024-01-05T16:02:15.678Z', 'coinbase': false, 'locktime': -1, 'inputCount': 5, 'outputCount': 1, 'size': 780, 'fee': 2409, 'value': 950891, 'confirmations': 0, 'coins': { 'inputs': [{ '_id': '659825bed85e75f781a01812', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 1, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '330716a75c23512202e45ffee478bdce7a33f298edf7eef30a42dbde06746c48', 'mintHeight': 154, 'spentHeight': -1, 'address': 'n2vpyzbBPBEni9FgkeQSnXvAQAfnRmKxFZ', 'script': '76a914eade85745090388e64a9341a82d8f94371430d1a88ac', 'value': 244000, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982587d85e75f781a0046f', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 1, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '7b83f82a22f94fc3e615743a5e6fb2345ed79aad8a2b564af2ace49da1e27ebb', 'mintHeight': 152, 'spentHeight': -1, 'address': 'muEU9KaNEw5doymy59ScrgEE3Eq4CQ45U9', 'script': '76a91496739b4ef4e793c05a78624da38d96f2c4059c6b88ac', 'value': 239400, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982511d85e75f7819fdd40', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': 'fb4d8039024c80a655fea29e01faf202f30e936af5738e31c5841a84215ca4d6', 'mintHeight': 149, 'spentHeight': -1, 'address': 'muEU9KaNEw5doymy59ScrgEE3Eq4CQ45U9', 'script': '76a91496739b4ef4e793c05a78624da38d96f2c4059c6b88ac', 'value': 239400, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '659824d7d85e75f7819fc75d', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '8221ed6891f6ba82ab72bb8298a661e21b47b04408861b0c3268c4a04a0435b3', 'mintHeight': 145, 'spentHeight': -1, 'address': 'miEzS8fSvtDjwkEjY14FEuWumFKg8nTPV9', 'script': '76a9141de381fc20d34d20e11a5543f536a4b74f495a9888ac', 'value': 228000, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982389d85e75f7819f57ff', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '95f713c2d7e09ab57ec3016bb767b26e6ee849cf487e86d8ed6126ae1b893e0f', 'mintHeight': 143, 'spentHeight': -1, 'address': 'msnM9VB5usfBahZNo57ZUq9uzwRxQXksUz', 'script': '76a914868ad3308906626182d1c6cd703cc7ce78b3a28d88ac', 'value': 2500, 'confirmations': -1, 'sequenceNumber': 4294967293 }], 'outputs': [{ '_id': '65982807d85e75f781a0d55d', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '', 'mintTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintHeight': -1, 'spentHeight': -2, 'address': 'mwwrGzk9q8xugY97C8BiNbcgqXNyjH4kp8', 'script': '76a914b4376347e4cffb1e9a475b2661bbe74de3c1f86a88ac', 'value': 950891, 'confirmations': -1 }] } });[m | ||
| sandbox.stub(wallet.client, 'importAddresses').resolves();[m | ||
| sandbox.spy(CWC.BitcoreLib.Transaction.prototype, 'feePerByte');[m | ||
| [31m- [m | ||
| [32m+[m | ||
| await wallet.generateAddressPair(1310066242, true);[m | ||
| await wallet.generateAddressPair(1087984800, true);[m | ||
| await wallet.generateAddressPair(1310064953, true);[m | ||
| await wallet.generateAddressPair(1310062823, true);[m | ||
| [31m- [m | ||
| [32m+[m | ||
| const { tx: newTx } = await wallet.bumpTxFee({[m | ||
| txid: '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5',[m | ||
| changeIdx: 0,[m | ||
| [36m@@ -204,7 +204,7 @@[m [mdescribe('Wallet', function() {[m | ||
| await wallet.unlock('abc123');[m | ||
| });[m | ||
| [m | ||
| [31m- [m | ||
| [32m+[m | ||
| it('should throw an error if neither rawTx nor txid is provided', async () => {[m | ||
| try {[m | ||
| await wallet.bumpTxFee({ changeIdx: 0 });[m | ||
| [36m@@ -230,7 +230,7 @@[m [mdescribe('Wallet', function() {[m | ||
| it('should bump the fee of a transaction with feeRate', async function() {[m | ||
| sandbox.stub(wallet, 'getTransactionByTxid').resolves({ 'txid': '0x0cf410cfe7fb268ad06ae115edfa8a30a8dea3979336a647b09b5a789c4b53d5', 'network': 'regtest', 'chain': 'ETH', 'blockHeight': 43245, 'blockHash': '0x9edb8d10883a360f7ff0c26860b6a159f5b7a74226949a4365691a879fafcdfc', 'blockTime': '2024-01-08T16:31:46.000Z', 'blockTimeNormalized': '2024-01-08T16:31:46.000Z', 'fee': 42000000000000, 'value': 1000000000000000000, 'gasLimit': 200000, 'gasPrice': 2000000000, 'nonce': 0, 'to': '0x7ee308b49e36Ab516cd0186B3a47CFD31d2499A1', 'from': '0x5FbdD2712d05D1a73e0b3Eba5efE8c3d42a336C3', 'effects': [], 'data': '0x', 'internal': [], 'calls': [], 'confirmations': 33 });[m | ||
| sandbox.stub(wallet.client, 'importAddresses').resolves();[m | ||
| [31m- [m | ||
| [32m+[m | ||
| const { tx: newTx, params } = await wallet.bumpTxFee({[m | ||
| txid: '0x0cf410cfe7fb268ad06ae115edfa8a30a8dea3979336a647b09b5a789c4b53d5',[m | ||
| feeRate: 300[m | ||
| [36m@@ -549,4 +549,3 @@[m [mdescribe('Wallet', function() {[m | ||
| });[m | ||
| });[m | ||
| });[m | ||
| [31m-[m | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,4 +15,4 @@ RUN npm run compile | |||||
|
|
||||||
| # Start the server | ||||||
| WORKDIR /bitcore/packages/bitcore-node | ||||||
| CMD ["node", "./build/src/server.js"] | ||||||
| CMD ["node", ".*.tsserver.js"] | ||||||
|
||||||
| CMD ["node", ".*.tsserver.js"] | |
| CMD ["node", "./build/src/server.js"] |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,83 @@ | ||||||||
| #!/bin/sh | ||||||||
|
|
||||||||
| dir=$(pwd) | ||||||||
|
||||||||
| dir=$(pwd) | |
| script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) | |
| dir=$(CDPATH= cd -- "$script_dir/.." && pwd) |
Copilot
AI
Apr 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are no pid files, pid_paths=$dir/pids/* may not expand and the loop will try to cat a literal glob. Add an explicit check that pid files exist (or use a glob-safe listing) before iterating, and avoid calling kill with an empty pid list.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { StateStorage } from '../../models/state'; | |
| import { TransactionStorage } from '../../models/transaction'; | ||
| import { ChainStateProvider } from '../../providers/chain-state'; | ||
| import { Libs } from '../../providers/libs'; | ||
| import { Config } from '../../services/config'; | ||
| import { BaseP2PWorker } from '../../services/p2p'; | ||
| import { SpentHeightIndicators } from '../../types/Coin'; | ||
| import { IUtxoNetworkConfig } from '../../types/Config'; | ||
|
|
@@ -80,6 +81,9 @@ export class BitcoinP2PWorker extends BaseP2PWorker<IBtcBlock> { | |
| ); | ||
| this.events.emit('SYNCDONE'); | ||
| }); | ||
| process.on('SIGUSR1', async () => { | ||
| await this.reload(); | ||
| }); | ||
| } | ||
|
|
||
| cacheInv(type: number, hash: string): void { | ||
|
|
@@ -217,6 +221,36 @@ export class BitcoinP2PWorker extends BaseP2PWorker<IBtcBlock> { | |
| } | ||
| } | ||
|
|
||
| async reload() { | ||
| this.chainConfig = Config.chainConfig({ chain: this.chain, network: this.network }) as IUtxoNetworkConfig; | ||
| const configPeerUris: string[] = []; | ||
|
|
||
| for (const peer of Object.values(this.chainConfig.trustedPeers) as any[]) { | ||
| const uri = peer.host + ':' + peer.port; | ||
| configPeerUris.push(uri); | ||
| const hashes = Object.values(this.pool._addrs).map((a: any) => a.hash); | ||
| const addr = this.pool._addAddr({ ip: { v4: peer.host }, port: peer.port }); | ||
| if (!hashes.includes(addr.hash)) { | ||
|
Comment on lines
+229
to
+233
|
||
| logger.info(`Adding peer ${uri}`); | ||
| } | ||
| } | ||
|
|
||
| for (const addr of Object.values(this.pool._addrs) as any[]) { | ||
| const uri = addr.ip.v4 + ':' + addr.port; | ||
| if (!configPeerUris.includes(uri)) { | ||
| this.pool._addrs = (this.pool._addrs as any[]).filter(({ hash }) => hash !== addr.hash); | ||
| if (this.pool._connectedPeers[addr.hash]) { | ||
| logger.info(`Removing peer ${uri}`); | ||
| } else { | ||
| logger.info(`Removing unconnected peer ${uri}`); | ||
| continue; | ||
| } | ||
| this.pool._connectedPeers[addr.hash].disconnect(); | ||
| delete this.pool._connectedPeers[addr.hash]; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| public async getHeaders(candidateHashes: string[]): Promise<BitcoinHeaderObj[]> { | ||
| let received = false; | ||
| return new Promise<BitcoinHeaderObj[]>(async resolve => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ import os from 'os'; | |||||
| import { Web3 } from '@bitpay-labs/crypto-wallet-core'; | ||||||
| import { LRUCache } from 'lru-cache'; | ||||||
| import request from 'request'; | ||||||
| import config from '../../../config'; | ||||||
| import { Config } from '../../../../src/services/config'; | ||||||
|
||||||
| import { Config } from '../../../../src/services/config'; | |
| import { Config } from '../../../services/config'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file appears to be an accidentally committed terminal-colored
git diffoutput (contains ANSI escape sequences) rather than source code/config. It should be removed from the repository (and the intended changes applied to the real files instead, if needed).