@pioneer-platform/utxo-network 8.30.0 → 8.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/lib/index.js +42 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @pioneer-platform/utxo-network
|
|
2
2
|
|
|
3
|
+
## 8.30.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 163653b: chore: fix(swap): Fix critical swap amount bug causing 0 ETH transfers
|
|
8
|
+
- Updated dependencies [163653b]
|
|
9
|
+
- @pioneer-platform/blockbook@8.32.2
|
|
10
|
+
|
|
3
11
|
## 8.30.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/lib/index.js
CHANGED
|
@@ -116,7 +116,7 @@ const sochain = __importStar(require("./sochain-api"));
|
|
|
116
116
|
const Utils = __importStar(require("./utils"));
|
|
117
117
|
let coins = [
|
|
118
118
|
'TBTC',
|
|
119
|
-
'BCH'
|
|
119
|
+
//'BCH', // Disabled - use blockbook REST API instead
|
|
120
120
|
//'BTC',
|
|
121
121
|
//'DOGE','DASH','DGB','BCH','LTC'
|
|
122
122
|
];
|
|
@@ -185,7 +185,47 @@ exports.getBalances = getBalances;
|
|
|
185
185
|
// return get_txs_by_height(height,address);
|
|
186
186
|
// },
|
|
187
187
|
const getBlockHeight = async function (coin) {
|
|
188
|
-
|
|
188
|
+
const tag = TAG + " | getBlockHeight | ";
|
|
189
|
+
// If coin is in nodeMap (direct RPC), use that
|
|
190
|
+
if (nodeMap[coin]) {
|
|
191
|
+
return nodeMap[coin].getBlockCount();
|
|
192
|
+
}
|
|
193
|
+
// Otherwise, use blockbook REST API
|
|
194
|
+
try {
|
|
195
|
+
const blockbookUrls = blockbook.getBlockbooks();
|
|
196
|
+
const url = blockbookUrls[coin];
|
|
197
|
+
if (!url) {
|
|
198
|
+
const availableCoins = Object.keys(blockbookUrls).join(', ');
|
|
199
|
+
throw new Error(`No blockbook URL configured for ${coin}. Available: ${availableCoins}`);
|
|
200
|
+
}
|
|
201
|
+
// Use the first URL if it's an array, otherwise use as-is
|
|
202
|
+
let baseUrl;
|
|
203
|
+
if (Array.isArray(url)) {
|
|
204
|
+
baseUrl = url[0];
|
|
205
|
+
}
|
|
206
|
+
else if (typeof url === 'string') {
|
|
207
|
+
baseUrl = url;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
throw new Error(`Invalid URL type for ${coin}: ${typeof url}`);
|
|
211
|
+
}
|
|
212
|
+
if (!baseUrl || baseUrl === 'undefined') {
|
|
213
|
+
throw new Error(`Invalid base URL for ${coin}: ${baseUrl}`);
|
|
214
|
+
}
|
|
215
|
+
// Fetch blockchain info from /api/v2/ endpoint
|
|
216
|
+
const response = await axiosInstance.get(`${baseUrl}/api/v2/`);
|
|
217
|
+
const info = response.data;
|
|
218
|
+
if (info && info.blockbook && info.blockbook.bestHeight) {
|
|
219
|
+
return info.blockbook.bestHeight;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
throw new Error(`No block height data returned from blockbook for ${coin}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
log.error(tag, `Failed to get block height for ${coin}: ${stringifyError(error)}`);
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
189
229
|
};
|
|
190
230
|
exports.getBlockHeight = getBlockHeight;
|
|
191
231
|
const getTransaction = function (coin, txid, format) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/utxo-network",
|
|
3
|
-
"version": "8.30.
|
|
3
|
+
"version": "8.30.1",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build:live": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@pioneer-platform/blockbook": "^8.32.
|
|
14
|
+
"@pioneer-platform/blockbook": "^8.32.2",
|
|
15
15
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
16
16
|
"@pioneer-platform/nodes": "^8.30.0",
|
|
17
17
|
"@pioneer-platform/pioneer-caip": "^9.19.0",
|