@pioneer-platform/utxo-network 8.25.2 → 8.27.0
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +41 -0
- package/build +22 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +17 -8
- package/lib/utils.js +6 -3
- package/package.json +6 -6
- package/tsconfig.json +5 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
[0m[2m[35m$[0m [2m[1mtsc -p
|
|
2
|
+
[0m[2m[35m$[0m [2m[1mtsc -p . --skipLibCheck[0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @pioneer-platform/utxo-network
|
|
2
2
|
|
|
3
|
+
## 8.27.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- chore: feat(pioneer-sdk): Add transaction history integration
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @pioneer-platform/blockbook@8.29.0
|
|
13
|
+
|
|
14
|
+
## 8.26.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- feat(pioneer-sdk): Add transaction history integration
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @pioneer-platform/blockbook@8.28.0
|
|
24
|
+
|
|
25
|
+
## 8.25.4
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- chore: fix: transaction event channel mismatch + add networkId to event payload
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @pioneer-platform/blockbook@8.27.5
|
|
32
|
+
- @pioneer-platform/unchained@8.24.1
|
|
33
|
+
- @pioneer-platform/nodes@8.26.2
|
|
34
|
+
|
|
35
|
+
## 8.25.3
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- fix: transaction event channel mismatch + add networkId to event payload
|
|
40
|
+
- Updated dependencies
|
|
41
|
+
- @pioneer-platform/blockbook@8.27.4
|
|
42
|
+
- @pioneer-platform/nodes@8.26.1
|
|
43
|
+
|
|
3
44
|
## 8.25.2
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/build
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Fast Bun build (replaces slow tsc)
|
|
3
|
+
|
|
4
|
+
OUTDIR="${1:-lib}"
|
|
5
|
+
ENTRY="${2:-src/index.ts}"
|
|
6
|
+
|
|
7
|
+
# Clean output
|
|
8
|
+
rm -rf "$OUTDIR"
|
|
9
|
+
mkdir -p "$OUTDIR"
|
|
10
|
+
|
|
11
|
+
# Build with Bun (10x faster than tsc)
|
|
12
|
+
bun build "$ENTRY" \
|
|
13
|
+
--outdir "$OUTDIR" \
|
|
14
|
+
--target node \
|
|
15
|
+
--format cjs \
|
|
16
|
+
--sourcemap \
|
|
17
|
+
--minify
|
|
18
|
+
|
|
19
|
+
# Generate TypeScript declarations
|
|
20
|
+
bunx tsc --emitDeclarationOnly --outDir "$OUTDIR" --project .
|
|
21
|
+
|
|
22
|
+
echo "✅ Built $OUTDIR"
|
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { FeeRates } from './types/client-types';
|
|
|
3
3
|
export declare const init: (servers: any) => Promise<boolean>;
|
|
4
4
|
export declare const getInfo: (coin: string) => Promise<any>;
|
|
5
5
|
export declare const txsMulti: (coin: string, addresses: any) => Promise<void>;
|
|
6
|
-
export declare const txsByXpub: (coin: string, addresses: any) => Promise<
|
|
6
|
+
export declare const txsByXpub: (coin: string, addresses: any) => Promise<any>;
|
|
7
7
|
export declare const utxosByXpub: (coin: string, xpub: any) => Promise<any>;
|
|
8
8
|
export declare const getPubkeyInfo: (coin: string, xpub: any) => Promise<any>;
|
|
9
9
|
export declare const getBalanceByXpub: (coin: string, xpub: any) => Promise<{
|
package/lib/index.js
CHANGED
|
@@ -248,7 +248,16 @@ const init_network = async function (servers) {
|
|
|
248
248
|
// @TODO
|
|
249
249
|
// const blockbooks = servers.filter((server: { type: string; }) => server.type === 'blockbook');
|
|
250
250
|
// log.debug(tag,"blockbooks: ",blockbooks)
|
|
251
|
-
|
|
251
|
+
// CRITICAL: Initialize blockbook if not already initialized (for standalone/test usage)
|
|
252
|
+
// Check if blockbook has been initialized by checking if it has any URLs configured
|
|
253
|
+
const blockbookUrls = blockbook.getBlockbooks ? blockbook.getBlockbooks() : {};
|
|
254
|
+
if (!blockbookUrls || Object.keys(blockbookUrls).length === 0) {
|
|
255
|
+
log.info(tag, 'Blockbook not initialized - initializing now for transaction history support');
|
|
256
|
+
await blockbook.init();
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
log.debug(tag, 'Blockbook already initialized by server');
|
|
260
|
+
}
|
|
252
261
|
// @TODO
|
|
253
262
|
//load daemon servers
|
|
254
263
|
//load unchained servers
|
|
@@ -651,14 +660,14 @@ let get_transaction = async function (coin, txid, format) {
|
|
|
651
660
|
}
|
|
652
661
|
};
|
|
653
662
|
let get_txs_by_xpub = async function (coin, xpub) {
|
|
654
|
-
let tag = ' | get_txs_by_xpub | ';
|
|
663
|
+
let tag = TAG + ' | get_txs_by_xpub | ';
|
|
655
664
|
try {
|
|
656
|
-
log.debug(tag, "
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
//
|
|
661
|
-
|
|
665
|
+
log.debug(tag, "Getting transactions for xpub: ", xpub.substring(0, 20) + '...');
|
|
666
|
+
// Use blockbook's txsByXpub which uses details=txs to get transaction data
|
|
667
|
+
const xpubData = await blockbook.txsByXpub(coin, xpub);
|
|
668
|
+
log.debug(tag, `Blockbook returned ${xpubData?.transactions?.length || 0} transactions`);
|
|
669
|
+
// Return the transactions array from the xpub data
|
|
670
|
+
return xpubData?.transactions || [];
|
|
662
671
|
}
|
|
663
672
|
catch (e) {
|
|
664
673
|
log.error(tag, stringifyError(e));
|
package/lib/utils.js
CHANGED
|
@@ -38,6 +38,9 @@ const Bitcoin = __importStar(require("bitcoinjs-lib")); // https://github.com/bi
|
|
|
38
38
|
const sochain = __importStar(require("./sochain-api"));
|
|
39
39
|
const xchain_util_1 = require("@xchainjs/xchain-util");
|
|
40
40
|
const const_1 = require("./const");
|
|
41
|
+
// Define AssetBTC locally since it's not exported in xchain-util@0.2.8
|
|
42
|
+
// AssetType.NATIVE = 0
|
|
43
|
+
const AssetBTC = { chain: 'BTC', symbol: 'BTC', ticker: 'BTC', type: 0 };
|
|
41
44
|
const TX_EMPTY_SIZE = 4 + 1 + 1 + 4; //10
|
|
42
45
|
const TX_INPUT_BASE = 32 + 4 + 1 + 4; // 41
|
|
43
46
|
const TX_INPUT_PUBKEYHASH = 107;
|
|
@@ -127,7 +130,7 @@ const getBalance = async (params) => {
|
|
|
127
130
|
const balance = await sochain.getBalance(params);
|
|
128
131
|
return [
|
|
129
132
|
{
|
|
130
|
-
asset:
|
|
133
|
+
asset: AssetBTC,
|
|
131
134
|
amount: balance,
|
|
132
135
|
},
|
|
133
136
|
];
|
|
@@ -148,7 +151,7 @@ exports.getBalance = getBalance;
|
|
|
148
151
|
const getChange = async ({ valueOut, sochainUrl, network, address }) => {
|
|
149
152
|
try {
|
|
150
153
|
const balances = await (0, exports.getBalance)({ sochainUrl, network, address });
|
|
151
|
-
const [btcBalance] = balances.filter((balance) => (0, xchain_util_1.assetToString)(balance.asset) === (0, xchain_util_1.assetToString)(
|
|
154
|
+
const [btcBalance] = balances.filter((balance) => (0, xchain_util_1.assetToString)(balance.asset) === (0, xchain_util_1.assetToString)(AssetBTC));
|
|
152
155
|
let change = 0;
|
|
153
156
|
if (btcBalance && btcBalance.amount.amount().minus(valueOut).isGreaterThan(DUST_THRESHOLD)) {
|
|
154
157
|
change = btcBalance.amount.amount().minus(valueOut).toNumber();
|
|
@@ -209,7 +212,7 @@ const buildTx = async ({ amount, recipient, memo, feeRate, sender, network, soch
|
|
|
209
212
|
return Promise.reject(Error('No utxos to send'));
|
|
210
213
|
}
|
|
211
214
|
const balance = await (0, exports.getBalance)({ sochainUrl, network, address: sender });
|
|
212
|
-
const [btcBalance] = balance.filter((balance) => balance.asset.symbol ===
|
|
215
|
+
const [btcBalance] = balance.filter((balance) => balance.asset.symbol === AssetBTC.symbol);
|
|
213
216
|
if (!btcBalance) {
|
|
214
217
|
return Promise.reject(new Error('No btcBalance found'));
|
|
215
218
|
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/utxo-network",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.27.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "pnpm run build && node __tests__/test-module.js",
|
|
8
8
|
"start": "pnpm run build:live",
|
|
9
|
-
"build": "tsc -p .",
|
|
9
|
+
"build": "tsc -p . --skipLibCheck",
|
|
10
10
|
"prepublish": "tsc -p .",
|
|
11
11
|
"build:live": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@pioneer-platform/blockbook": "^8.
|
|
14
|
+
"@pioneer-platform/blockbook": "^8.29.0",
|
|
15
15
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
16
|
-
"@pioneer-platform/nodes": "^8.26.
|
|
16
|
+
"@pioneer-platform/nodes": "^8.26.2",
|
|
17
17
|
"@pioneer-platform/pioneer-caip": "^9.19.0",
|
|
18
|
-
"@pioneer-platform/unchained": "^8.24.
|
|
18
|
+
"@pioneer-platform/unchained": "^8.24.1",
|
|
19
19
|
"@types/request-promise-native": "^1.0.17",
|
|
20
20
|
"@xchainjs/xchain-client": "^0.7.0",
|
|
21
|
-
"@xchainjs/xchain-util": "
|
|
21
|
+
"@xchainjs/xchain-util": "0.2.8",
|
|
22
22
|
"axiom": "^0.1.6",
|
|
23
23
|
"axios": "^1.6.0",
|
|
24
24
|
"bitcoin-promise": "^1.3.1",
|
package/tsconfig.json
CHANGED
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
"resolveJsonModule": true,
|
|
19
19
|
"skipLibCheck": true,
|
|
20
20
|
"forceConsistentCasingInFileNames": true,
|
|
21
|
-
"types": ["node"]
|
|
21
|
+
"types": ["node"],
|
|
22
|
+
"baseUrl": "../../../..",
|
|
23
|
+
"paths": {
|
|
24
|
+
"@xchainjs/*": ["node_modules/@xchainjs/*"]
|
|
25
|
+
}
|
|
22
26
|
},
|
|
23
27
|
"include": ["src"],
|
|
24
28
|
"exclude": ["node_modules", "**/__tests__/*"]
|