@omnisat/lasereyes 0.0.21 → 0.0.22
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/dist/index.d.ts +9 -19
- package/dist/index.js +21 -43
- package/dist/index.mjs +19 -41
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare const UNISAT_MAINNET = "livenet";
|
|
|
8
8
|
declare const UNISAT_TESTNET = "testnet";
|
|
9
9
|
declare const XVERSE_MAINNET = "Mainnet";
|
|
10
10
|
declare const XVERSE_TESTNET = "Testnet";
|
|
11
|
+
declare const XVERSE_SIGNET = "Signet";
|
|
11
12
|
declare const OKX_MAINNET = "livenet";
|
|
12
13
|
declare const OKX_TESTNET = "testnet";
|
|
13
14
|
declare const WIZZ_MAINNET = "livenet";
|
|
@@ -18,7 +19,7 @@ declare const MAINNET = "mainnet";
|
|
|
18
19
|
declare const SIGNET = "signet";
|
|
19
20
|
declare const TESTNET = "testnet";
|
|
20
21
|
declare const REGTEST = "regtest";
|
|
21
|
-
declare const getXverseNetwork: (network: string) => "Mainnet" | "Testnet";
|
|
22
|
+
declare const getXverseNetwork: (network: string) => "Mainnet" | "Testnet" | "Signet";
|
|
22
23
|
declare const getLeatherNetwork: (network: string) => "testnet" | "mainnet";
|
|
23
24
|
declare const getUnisatNetwork: (network: string) => "livenet" | "testnet";
|
|
24
25
|
declare const getWizzNetwork: (network: string) => "livenet" | "testnet";
|
|
@@ -29,7 +30,8 @@ declare const getNetworkForOkx: (network: string) => "testnet" | "mainnet";
|
|
|
29
30
|
declare const getNetworkForWizz: (network: string) => "testnet" | "mainnet";
|
|
30
31
|
declare const MEMPOOL_SPACE_URL = "https://mempool.space";
|
|
31
32
|
declare const MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet";
|
|
32
|
-
declare const
|
|
33
|
+
declare const MEMPOOL_SPACE_SIGNET_URL = "https://mempool.space/signet";
|
|
34
|
+
declare const getMempoolSpaceUrl: (network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST) => "https://mempool.space" | "https://mempool.space/testnet" | "https://mempool.space/signet";
|
|
33
35
|
|
|
34
36
|
declare const OYL = "oyl";
|
|
35
37
|
declare const UNISAT = "unisat";
|
|
@@ -82,7 +84,7 @@ type LaserEyesContextType = {
|
|
|
82
84
|
paymentAddress: string;
|
|
83
85
|
paymentPublicKey: string;
|
|
84
86
|
balance: number | undefined;
|
|
85
|
-
network: typeof MAINNET | typeof TESTNET | typeof REGTEST;
|
|
87
|
+
network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST;
|
|
86
88
|
library: any;
|
|
87
89
|
provider: any;
|
|
88
90
|
accounts: string[];
|
|
@@ -98,7 +100,7 @@ type LaserEyesContextType = {
|
|
|
98
100
|
disconnect: () => void;
|
|
99
101
|
requestAccounts: () => Promise<string[]>;
|
|
100
102
|
getNetwork: () => Promise<string | undefined>;
|
|
101
|
-
switchNetwork: (network: typeof MAINNET | typeof TESTNET | typeof REGTEST) => Promise<void>;
|
|
103
|
+
switchNetwork: (network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST) => Promise<void>;
|
|
102
104
|
getPublicKey: () => Promise<string>;
|
|
103
105
|
getBalance: () => Promise<string>;
|
|
104
106
|
getInscriptions: () => Promise<any[]>;
|
|
@@ -112,18 +114,8 @@ type LaserEyesContextType = {
|
|
|
112
114
|
pushPsbt: (tx: string) => Promise<string | undefined>;
|
|
113
115
|
};
|
|
114
116
|
type Config = {
|
|
115
|
-
network: typeof MAINNET | typeof TESTNET | typeof REGTEST;
|
|
117
|
+
network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST;
|
|
116
118
|
};
|
|
117
|
-
interface BlockchainInfoUTXO {
|
|
118
|
-
tx_hash_big_endian: string;
|
|
119
|
-
tx_hash: string;
|
|
120
|
-
tx_output_n: number;
|
|
121
|
-
script: string;
|
|
122
|
-
value: number;
|
|
123
|
-
value_hex: string;
|
|
124
|
-
confirmations: number;
|
|
125
|
-
tx_index: number;
|
|
126
|
-
}
|
|
127
119
|
interface CommitPsbtResponse {
|
|
128
120
|
inscriberAddress: string;
|
|
129
121
|
psbtHex: string;
|
|
@@ -147,15 +139,13 @@ interface DeScribeCreateResponse {
|
|
|
147
139
|
totalFees: number;
|
|
148
140
|
}
|
|
149
141
|
|
|
150
|
-
declare const getBitcoinNetwork: (network: typeof MAINNET | typeof TESTNET | typeof REGTEST) => bitcoin.networks.Network;
|
|
142
|
+
declare const getBitcoinNetwork: (network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST) => bitcoin.networks.Network;
|
|
151
143
|
declare const findOrdinalsAddress: (addresses: any) => any;
|
|
152
144
|
declare const findPaymentAddress: (addresses: any) => any;
|
|
153
145
|
declare const getBTCBalance: (address: string) => Promise<number>;
|
|
154
|
-
declare const getAddressUtxos: (address: string) => Promise<BlockchainInfoUTXO[]>;
|
|
155
146
|
declare const satoshisToBTC: (satoshis: number) => string;
|
|
156
147
|
declare const isBase64: (str: string) => boolean;
|
|
157
148
|
declare const isHex: (str: string) => boolean;
|
|
158
|
-
declare function getAddressType(address: string): "p2tr" | "p2pkh" | "p2wpkh" | "p2psh" | "p2wsh";
|
|
159
149
|
declare function estimateTxSize(taprootInputCount: number, nonTaprootInputCount: number, outputCount: number): number;
|
|
160
150
|
declare function createSendBtcPsbt(address: string, paymentAddress: string, recipientAddress: string, amount: number, paymentPublicKey: string, network: typeof MAINNET | typeof TESTNET, feeRate?: number): Promise<{
|
|
161
151
|
psbtBase64: string;
|
|
@@ -194,4 +184,4 @@ declare const useInscriber: ({ inscribeApiUrl, }: {
|
|
|
194
184
|
reset: () => void;
|
|
195
185
|
};
|
|
196
186
|
|
|
197
|
-
export { DeScribeCreateResponse, LEATHER, LEATHER_MAINNET, LEATHER_TESTNET, LaserEyesProvider, MAGIC_EDEN, MAINNET, MEMPOOL_SPACE_TESTNET_URL, MEMPOOL_SPACE_URL, OKX, OKX_MAINNET, OKX_TESTNET, OYL, P2PKH, P2PSH, P2SH, P2TR, P2WPKH, P2WSH, PHANTOM, REGTEST, SIGNET, TESTNET, UNISAT, UNISAT_MAINNET, UNISAT_TESTNET, WALLETS, WIZZ, WIZZ_MAINNET, WIZZ_TESTNET, XVERSE, XVERSE_MAINNET, XVERSE_NETWORK, XVERSE_TESTNET, createConfig, createSendBtcPsbt, delay, estimateTxSize, findOrdinalsAddress, findPaymentAddress,
|
|
187
|
+
export { DeScribeCreateResponse, LEATHER, LEATHER_MAINNET, LEATHER_TESTNET, LaserEyesProvider, MAGIC_EDEN, MAINNET, MEMPOOL_SPACE_SIGNET_URL, MEMPOOL_SPACE_TESTNET_URL, MEMPOOL_SPACE_URL, OKX, OKX_MAINNET, OKX_TESTNET, OYL, P2PKH, P2PSH, P2SH, P2TR, P2WPKH, P2WSH, PHANTOM, REGTEST, SIGNET, TESTNET, UNISAT, UNISAT_MAINNET, UNISAT_TESTNET, WALLETS, WIZZ, WIZZ_MAINNET, WIZZ_TESTNET, XVERSE, XVERSE_MAINNET, XVERSE_NETWORK, XVERSE_SIGNET, XVERSE_TESTNET, createConfig, createSendBtcPsbt, delay, estimateTxSize, findOrdinalsAddress, findPaymentAddress, getBTCBalance, getBitcoinNetwork, getLeatherNetwork, getMempoolSpaceUrl, getNetworkForLeather, getNetworkForOkx, getNetworkForUnisat, getNetworkForWizz, getNetworkForXverse, getRedeemScript, getUnisatNetwork, getWizzNetwork, getXverseNetwork, isBase64, isHex, satoshisToBTC, useInscriber, useLaserEyes };
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,7 @@ __export(src_exports, {
|
|
|
79
79
|
LaserEyesProvider: () => LaserEyesProvider,
|
|
80
80
|
MAGIC_EDEN: () => MAGIC_EDEN,
|
|
81
81
|
MAINNET: () => MAINNET,
|
|
82
|
+
MEMPOOL_SPACE_SIGNET_URL: () => MEMPOOL_SPACE_SIGNET_URL,
|
|
82
83
|
MEMPOOL_SPACE_TESTNET_URL: () => MEMPOOL_SPACE_TESTNET_URL,
|
|
83
84
|
MEMPOOL_SPACE_URL: () => MEMPOOL_SPACE_URL,
|
|
84
85
|
OKX: () => OKX,
|
|
@@ -105,6 +106,7 @@ __export(src_exports, {
|
|
|
105
106
|
XVERSE: () => XVERSE,
|
|
106
107
|
XVERSE_MAINNET: () => XVERSE_MAINNET,
|
|
107
108
|
XVERSE_NETWORK: () => XVERSE_NETWORK,
|
|
109
|
+
XVERSE_SIGNET: () => XVERSE_SIGNET,
|
|
108
110
|
XVERSE_TESTNET: () => XVERSE_TESTNET,
|
|
109
111
|
createConfig: () => createConfig,
|
|
110
112
|
createSendBtcPsbt: () => createSendBtcPsbt,
|
|
@@ -112,8 +114,6 @@ __export(src_exports, {
|
|
|
112
114
|
estimateTxSize: () => estimateTxSize,
|
|
113
115
|
findOrdinalsAddress: () => findOrdinalsAddress,
|
|
114
116
|
findPaymentAddress: () => findPaymentAddress,
|
|
115
|
-
getAddressType: () => getAddressType,
|
|
116
|
-
getAddressUtxos: () => getAddressUtxos,
|
|
117
117
|
getBTCBalance: () => getBTCBalance,
|
|
118
118
|
getBitcoinNetwork: () => getBitcoinNetwork,
|
|
119
119
|
getLeatherNetwork: () => getLeatherNetwork,
|
|
@@ -141,6 +141,7 @@ var UNISAT_MAINNET = "livenet";
|
|
|
141
141
|
var UNISAT_TESTNET = "testnet";
|
|
142
142
|
var XVERSE_MAINNET = "Mainnet";
|
|
143
143
|
var XVERSE_TESTNET = "Testnet";
|
|
144
|
+
var XVERSE_SIGNET = "Signet";
|
|
144
145
|
var OKX_MAINNET = "livenet";
|
|
145
146
|
var OKX_TESTNET = "testnet";
|
|
146
147
|
var WIZZ_MAINNET = "livenet";
|
|
@@ -156,6 +157,8 @@ var getXverseNetwork = (network) => {
|
|
|
156
157
|
return XVERSE_MAINNET;
|
|
157
158
|
if (network === TESTNET)
|
|
158
159
|
return XVERSE_TESTNET;
|
|
160
|
+
if (network === SIGNET)
|
|
161
|
+
return XVERSE_SIGNET;
|
|
159
162
|
return XVERSE_MAINNET;
|
|
160
163
|
};
|
|
161
164
|
var getLeatherNetwork = (network) => {
|
|
@@ -216,7 +219,8 @@ var getNetworkForWizz = (network) => {
|
|
|
216
219
|
};
|
|
217
220
|
var MEMPOOL_SPACE_URL = "https://mempool.space";
|
|
218
221
|
var MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet";
|
|
219
|
-
var
|
|
222
|
+
var MEMPOOL_SPACE_SIGNET_URL = "https://mempool.space/signet";
|
|
223
|
+
var getMempoolSpaceUrl = (network) => network === TESTNET ? MEMPOOL_SPACE_TESTNET_URL : network === SIGNET ? MEMPOOL_SPACE_SIGNET_URL : MEMPOOL_SPACE_URL;
|
|
220
224
|
|
|
221
225
|
// src/consts/wallets.ts
|
|
222
226
|
var OYL = "oyl";
|
|
@@ -357,6 +361,8 @@ bitcoin.initEccLib(ecc);
|
|
|
357
361
|
var getBitcoinNetwork = (network) => {
|
|
358
362
|
if (network === TESTNET) {
|
|
359
363
|
return bitcoin.networks.testnet;
|
|
364
|
+
} else if (network === SIGNET) {
|
|
365
|
+
return bitcoin.networks.testnet;
|
|
360
366
|
} else if (network === REGTEST) {
|
|
361
367
|
return bitcoin.networks.regtest;
|
|
362
368
|
} else {
|
|
@@ -381,13 +387,6 @@ var getBTCBalance = (address2) => __async(void 0, null, function* () {
|
|
|
381
387
|
throw new Error("Failed to fetch BTC balance");
|
|
382
388
|
}
|
|
383
389
|
});
|
|
384
|
-
var getAddressUtxos = (address2) => __async(void 0, null, function* () {
|
|
385
|
-
try {
|
|
386
|
-
return yield import_axios.default.get(`https://blockchain.info/unspent?active=${address2}`).then((response) => response.data.unspent_outputs);
|
|
387
|
-
} catch (error) {
|
|
388
|
-
throw new Error("Failed to fetch UTXOs");
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
390
|
var satoshisToBTC = (satoshis) => {
|
|
392
391
|
if (Number.isNaN(satoshis) || satoshis === void 0)
|
|
393
392
|
return "--";
|
|
@@ -402,32 +401,6 @@ var isHex = (str) => {
|
|
|
402
401
|
const hexRegex = /^[a-fA-F0-9]+$/;
|
|
403
402
|
return hexRegex.test(str);
|
|
404
403
|
};
|
|
405
|
-
function getAddressType(address2) {
|
|
406
|
-
try {
|
|
407
|
-
bitcoin.address.fromBase58Check(address2);
|
|
408
|
-
return P2PKH;
|
|
409
|
-
} catch (e) {
|
|
410
|
-
}
|
|
411
|
-
try {
|
|
412
|
-
bitcoin.address.fromBase58Check(address2);
|
|
413
|
-
return P2PSH;
|
|
414
|
-
} catch (e) {
|
|
415
|
-
}
|
|
416
|
-
try {
|
|
417
|
-
const { version, data } = bitcoin.address.fromBech32(address2);
|
|
418
|
-
if (version === 0) {
|
|
419
|
-
if (data.length === 20) {
|
|
420
|
-
return P2WPKH;
|
|
421
|
-
} else if (data.length === 32) {
|
|
422
|
-
return P2WSH;
|
|
423
|
-
}
|
|
424
|
-
} else if (version === 1 && data.length === 32) {
|
|
425
|
-
return P2TR;
|
|
426
|
-
}
|
|
427
|
-
} catch (e) {
|
|
428
|
-
}
|
|
429
|
-
throw new Error("Invalid address");
|
|
430
|
-
}
|
|
431
404
|
function estimateTxSize(taprootInputCount, nonTaprootInputCount, outputCount) {
|
|
432
405
|
const baseTxSize = 10;
|
|
433
406
|
const taprootInputSize = 57;
|
|
@@ -900,6 +873,8 @@ var LaserEyesProvider = ({
|
|
|
900
873
|
yield connectUnisat();
|
|
901
874
|
} else if (walletName === XVERSE) {
|
|
902
875
|
yield connectXverse();
|
|
876
|
+
} else if (walletName === LEATHER) {
|
|
877
|
+
yield connectLeather();
|
|
903
878
|
} else {
|
|
904
879
|
throw new Error("Unsupported wallet..");
|
|
905
880
|
}
|
|
@@ -1318,7 +1293,7 @@ var LaserEyesProvider = ({
|
|
|
1318
1293
|
} else if (provider === LEATHER) {
|
|
1319
1294
|
const signed = yield library == null ? void 0 : library.request("signMessage", {
|
|
1320
1295
|
message,
|
|
1321
|
-
paymentType:
|
|
1296
|
+
paymentType: P2WPKH
|
|
1322
1297
|
});
|
|
1323
1298
|
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1324
1299
|
} else if (provider === PHANTOM) {
|
|
@@ -1347,8 +1322,8 @@ var LaserEyesProvider = ({
|
|
|
1347
1322
|
psbtBase64 = bitcoin2.Psbt.fromHex(psbt).toBase64();
|
|
1348
1323
|
psbtHex = psbt;
|
|
1349
1324
|
} else if (isBase64(psbt)) {
|
|
1350
|
-
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1351
1325
|
psbtBase64 = psbt;
|
|
1326
|
+
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1352
1327
|
} else {
|
|
1353
1328
|
throw new Error("Invalid PSBT format");
|
|
1354
1329
|
}
|
|
@@ -1589,7 +1564,8 @@ var LaserEyesProvider = ({
|
|
|
1589
1564
|
} else if (provider === LEATHER) {
|
|
1590
1565
|
const requestParams = {
|
|
1591
1566
|
hex: psbtHex,
|
|
1592
|
-
broadcast
|
|
1567
|
+
broadcast,
|
|
1568
|
+
network
|
|
1593
1569
|
};
|
|
1594
1570
|
const response = yield library == null ? void 0 : library.request(
|
|
1595
1571
|
"signPsbt",
|
|
@@ -1597,7 +1573,7 @@ var LaserEyesProvider = ({
|
|
|
1597
1573
|
);
|
|
1598
1574
|
const leatherHexResult = response.result;
|
|
1599
1575
|
const signedTx = leatherHexResult.hex;
|
|
1600
|
-
const signed = bitcoin2.Psbt.
|
|
1576
|
+
const signed = bitcoin2.Psbt.fromHex(String(signedTx));
|
|
1601
1577
|
if (finalize && broadcast) {
|
|
1602
1578
|
const finalized = signed.finalizeAllInputs();
|
|
1603
1579
|
const extracted = finalized.extractTransaction();
|
|
@@ -1660,7 +1636,9 @@ var LaserEyesProvider = ({
|
|
|
1660
1636
|
} else if (provider === MAGIC_EDEN) {
|
|
1661
1637
|
return yield import_axios2.default.post("https://mempool.space/api/tx", psbt).then((res) => res.data);
|
|
1662
1638
|
} else if (provider === LEATHER) {
|
|
1663
|
-
|
|
1639
|
+
const decoded = bitcoin2.Psbt.fromHex(psbt);
|
|
1640
|
+
const extracted = decoded.extractTransaction();
|
|
1641
|
+
return yield import_axios2.default.post("https://mempool.space/api/tx", extracted.toHex()).then((res) => res.data);
|
|
1664
1642
|
} else if (provider === WIZZ) {
|
|
1665
1643
|
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1666
1644
|
} else {
|
|
@@ -1879,6 +1857,7 @@ var useInscriber = ({
|
|
|
1879
1857
|
LaserEyesProvider,
|
|
1880
1858
|
MAGIC_EDEN,
|
|
1881
1859
|
MAINNET,
|
|
1860
|
+
MEMPOOL_SPACE_SIGNET_URL,
|
|
1882
1861
|
MEMPOOL_SPACE_TESTNET_URL,
|
|
1883
1862
|
MEMPOOL_SPACE_URL,
|
|
1884
1863
|
OKX,
|
|
@@ -1905,6 +1884,7 @@ var useInscriber = ({
|
|
|
1905
1884
|
XVERSE,
|
|
1906
1885
|
XVERSE_MAINNET,
|
|
1907
1886
|
XVERSE_NETWORK,
|
|
1887
|
+
XVERSE_SIGNET,
|
|
1908
1888
|
XVERSE_TESTNET,
|
|
1909
1889
|
createConfig,
|
|
1910
1890
|
createSendBtcPsbt,
|
|
@@ -1912,8 +1892,6 @@ var useInscriber = ({
|
|
|
1912
1892
|
estimateTxSize,
|
|
1913
1893
|
findOrdinalsAddress,
|
|
1914
1894
|
findPaymentAddress,
|
|
1915
|
-
getAddressType,
|
|
1916
|
-
getAddressUtxos,
|
|
1917
1895
|
getBTCBalance,
|
|
1918
1896
|
getBitcoinNetwork,
|
|
1919
1897
|
getLeatherNetwork,
|
package/dist/index.mjs
CHANGED
|
@@ -50,6 +50,7 @@ var UNISAT_MAINNET = "livenet";
|
|
|
50
50
|
var UNISAT_TESTNET = "testnet";
|
|
51
51
|
var XVERSE_MAINNET = "Mainnet";
|
|
52
52
|
var XVERSE_TESTNET = "Testnet";
|
|
53
|
+
var XVERSE_SIGNET = "Signet";
|
|
53
54
|
var OKX_MAINNET = "livenet";
|
|
54
55
|
var OKX_TESTNET = "testnet";
|
|
55
56
|
var WIZZ_MAINNET = "livenet";
|
|
@@ -65,6 +66,8 @@ var getXverseNetwork = (network) => {
|
|
|
65
66
|
return XVERSE_MAINNET;
|
|
66
67
|
if (network === TESTNET)
|
|
67
68
|
return XVERSE_TESTNET;
|
|
69
|
+
if (network === SIGNET)
|
|
70
|
+
return XVERSE_SIGNET;
|
|
68
71
|
return XVERSE_MAINNET;
|
|
69
72
|
};
|
|
70
73
|
var getLeatherNetwork = (network) => {
|
|
@@ -125,7 +128,8 @@ var getNetworkForWizz = (network) => {
|
|
|
125
128
|
};
|
|
126
129
|
var MEMPOOL_SPACE_URL = "https://mempool.space";
|
|
127
130
|
var MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet";
|
|
128
|
-
var
|
|
131
|
+
var MEMPOOL_SPACE_SIGNET_URL = "https://mempool.space/signet";
|
|
132
|
+
var getMempoolSpaceUrl = (network) => network === TESTNET ? MEMPOOL_SPACE_TESTNET_URL : network === SIGNET ? MEMPOOL_SPACE_SIGNET_URL : MEMPOOL_SPACE_URL;
|
|
129
133
|
|
|
130
134
|
// src/consts/wallets.ts
|
|
131
135
|
var OYL = "oyl";
|
|
@@ -272,6 +276,8 @@ bitcoin.initEccLib(ecc);
|
|
|
272
276
|
var getBitcoinNetwork = (network) => {
|
|
273
277
|
if (network === TESTNET) {
|
|
274
278
|
return bitcoin.networks.testnet;
|
|
279
|
+
} else if (network === SIGNET) {
|
|
280
|
+
return bitcoin.networks.testnet;
|
|
275
281
|
} else if (network === REGTEST) {
|
|
276
282
|
return bitcoin.networks.regtest;
|
|
277
283
|
} else {
|
|
@@ -296,13 +302,6 @@ var getBTCBalance = (address2) => __async(void 0, null, function* () {
|
|
|
296
302
|
throw new Error("Failed to fetch BTC balance");
|
|
297
303
|
}
|
|
298
304
|
});
|
|
299
|
-
var getAddressUtxos = (address2) => __async(void 0, null, function* () {
|
|
300
|
-
try {
|
|
301
|
-
return yield axios.get(`https://blockchain.info/unspent?active=${address2}`).then((response) => response.data.unspent_outputs);
|
|
302
|
-
} catch (error) {
|
|
303
|
-
throw new Error("Failed to fetch UTXOs");
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
305
|
var satoshisToBTC = (satoshis) => {
|
|
307
306
|
if (Number.isNaN(satoshis) || satoshis === void 0)
|
|
308
307
|
return "--";
|
|
@@ -317,32 +316,6 @@ var isHex = (str) => {
|
|
|
317
316
|
const hexRegex = /^[a-fA-F0-9]+$/;
|
|
318
317
|
return hexRegex.test(str);
|
|
319
318
|
};
|
|
320
|
-
function getAddressType(address2) {
|
|
321
|
-
try {
|
|
322
|
-
bitcoin.address.fromBase58Check(address2);
|
|
323
|
-
return P2PKH;
|
|
324
|
-
} catch (e) {
|
|
325
|
-
}
|
|
326
|
-
try {
|
|
327
|
-
bitcoin.address.fromBase58Check(address2);
|
|
328
|
-
return P2PSH;
|
|
329
|
-
} catch (e) {
|
|
330
|
-
}
|
|
331
|
-
try {
|
|
332
|
-
const { version, data } = bitcoin.address.fromBech32(address2);
|
|
333
|
-
if (version === 0) {
|
|
334
|
-
if (data.length === 20) {
|
|
335
|
-
return P2WPKH;
|
|
336
|
-
} else if (data.length === 32) {
|
|
337
|
-
return P2WSH;
|
|
338
|
-
}
|
|
339
|
-
} else if (version === 1 && data.length === 32) {
|
|
340
|
-
return P2TR;
|
|
341
|
-
}
|
|
342
|
-
} catch (e) {
|
|
343
|
-
}
|
|
344
|
-
throw new Error("Invalid address");
|
|
345
|
-
}
|
|
346
319
|
function estimateTxSize(taprootInputCount, nonTaprootInputCount, outputCount) {
|
|
347
320
|
const baseTxSize = 10;
|
|
348
321
|
const taprootInputSize = 57;
|
|
@@ -822,6 +795,8 @@ var LaserEyesProvider = ({
|
|
|
822
795
|
yield connectUnisat();
|
|
823
796
|
} else if (walletName === XVERSE) {
|
|
824
797
|
yield connectXverse();
|
|
798
|
+
} else if (walletName === LEATHER) {
|
|
799
|
+
yield connectLeather();
|
|
825
800
|
} else {
|
|
826
801
|
throw new Error("Unsupported wallet..");
|
|
827
802
|
}
|
|
@@ -1240,7 +1215,7 @@ var LaserEyesProvider = ({
|
|
|
1240
1215
|
} else if (provider === LEATHER) {
|
|
1241
1216
|
const signed = yield library == null ? void 0 : library.request("signMessage", {
|
|
1242
1217
|
message,
|
|
1243
|
-
paymentType:
|
|
1218
|
+
paymentType: P2WPKH
|
|
1244
1219
|
});
|
|
1245
1220
|
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1246
1221
|
} else if (provider === PHANTOM) {
|
|
@@ -1269,8 +1244,8 @@ var LaserEyesProvider = ({
|
|
|
1269
1244
|
psbtBase64 = bitcoin2.Psbt.fromHex(psbt).toBase64();
|
|
1270
1245
|
psbtHex = psbt;
|
|
1271
1246
|
} else if (isBase64(psbt)) {
|
|
1272
|
-
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1273
1247
|
psbtBase64 = psbt;
|
|
1248
|
+
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1274
1249
|
} else {
|
|
1275
1250
|
throw new Error("Invalid PSBT format");
|
|
1276
1251
|
}
|
|
@@ -1511,7 +1486,8 @@ var LaserEyesProvider = ({
|
|
|
1511
1486
|
} else if (provider === LEATHER) {
|
|
1512
1487
|
const requestParams = {
|
|
1513
1488
|
hex: psbtHex,
|
|
1514
|
-
broadcast
|
|
1489
|
+
broadcast,
|
|
1490
|
+
network
|
|
1515
1491
|
};
|
|
1516
1492
|
const response = yield library == null ? void 0 : library.request(
|
|
1517
1493
|
"signPsbt",
|
|
@@ -1519,7 +1495,7 @@ var LaserEyesProvider = ({
|
|
|
1519
1495
|
);
|
|
1520
1496
|
const leatherHexResult = response.result;
|
|
1521
1497
|
const signedTx = leatherHexResult.hex;
|
|
1522
|
-
const signed = bitcoin2.Psbt.
|
|
1498
|
+
const signed = bitcoin2.Psbt.fromHex(String(signedTx));
|
|
1523
1499
|
if (finalize && broadcast) {
|
|
1524
1500
|
const finalized = signed.finalizeAllInputs();
|
|
1525
1501
|
const extracted = finalized.extractTransaction();
|
|
@@ -1582,7 +1558,9 @@ var LaserEyesProvider = ({
|
|
|
1582
1558
|
} else if (provider === MAGIC_EDEN) {
|
|
1583
1559
|
return yield axios2.post("https://mempool.space/api/tx", psbt).then((res) => res.data);
|
|
1584
1560
|
} else if (provider === LEATHER) {
|
|
1585
|
-
|
|
1561
|
+
const decoded = bitcoin2.Psbt.fromHex(psbt);
|
|
1562
|
+
const extracted = decoded.extractTransaction();
|
|
1563
|
+
return yield axios2.post("https://mempool.space/api/tx", extracted.toHex()).then((res) => res.data);
|
|
1586
1564
|
} else if (provider === WIZZ) {
|
|
1587
1565
|
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1588
1566
|
} else {
|
|
@@ -1800,6 +1778,7 @@ export {
|
|
|
1800
1778
|
LaserEyesProvider,
|
|
1801
1779
|
MAGIC_EDEN,
|
|
1802
1780
|
MAINNET,
|
|
1781
|
+
MEMPOOL_SPACE_SIGNET_URL,
|
|
1803
1782
|
MEMPOOL_SPACE_TESTNET_URL,
|
|
1804
1783
|
MEMPOOL_SPACE_URL,
|
|
1805
1784
|
OKX,
|
|
@@ -1826,6 +1805,7 @@ export {
|
|
|
1826
1805
|
XVERSE,
|
|
1827
1806
|
XVERSE_MAINNET,
|
|
1828
1807
|
XVERSE_NETWORK,
|
|
1808
|
+
XVERSE_SIGNET,
|
|
1829
1809
|
XVERSE_TESTNET,
|
|
1830
1810
|
createConfig,
|
|
1831
1811
|
createSendBtcPsbt,
|
|
@@ -1833,8 +1813,6 @@ export {
|
|
|
1833
1813
|
estimateTxSize,
|
|
1834
1814
|
findOrdinalsAddress,
|
|
1835
1815
|
findPaymentAddress,
|
|
1836
|
-
getAddressType,
|
|
1837
|
-
getAddressUtxos,
|
|
1838
1816
|
getBTCBalance,
|
|
1839
1817
|
getBitcoinNetwork,
|
|
1840
1818
|
getLeatherNetwork,
|