@omnisat/lasereyes 0.0.20 → 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 +22 -46
- package/dist/index.mjs +20 -44
- 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
|
}
|
|
@@ -1302,7 +1277,7 @@ var LaserEyesProvider = ({
|
|
|
1302
1277
|
network: {
|
|
1303
1278
|
type: import_sats_connect.BitcoinNetworkType.Mainnet
|
|
1304
1279
|
},
|
|
1305
|
-
address:
|
|
1280
|
+
address: paymentAddress,
|
|
1306
1281
|
message
|
|
1307
1282
|
},
|
|
1308
1283
|
onFinish: (response) => {
|
|
@@ -1318,15 +1293,13 @@ 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
|
-
console.log(signed);
|
|
1324
1298
|
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1325
1299
|
} else if (provider === PHANTOM) {
|
|
1326
1300
|
const utf8Bytes = new TextEncoder().encode(message);
|
|
1327
1301
|
const uintArray = new Uint8Array(utf8Bytes);
|
|
1328
1302
|
const response = yield library == null ? void 0 : library.signMessage(address2, uintArray);
|
|
1329
|
-
console.log(response);
|
|
1330
1303
|
const binaryString = String.fromCharCode(...response.signature);
|
|
1331
1304
|
return btoa(binaryString);
|
|
1332
1305
|
} else if (provider === WIZZ) {
|
|
@@ -1349,8 +1322,8 @@ var LaserEyesProvider = ({
|
|
|
1349
1322
|
psbtBase64 = bitcoin2.Psbt.fromHex(psbt).toBase64();
|
|
1350
1323
|
psbtHex = psbt;
|
|
1351
1324
|
} else if (isBase64(psbt)) {
|
|
1352
|
-
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1353
1325
|
psbtBase64 = psbt;
|
|
1326
|
+
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1354
1327
|
} else {
|
|
1355
1328
|
throw new Error("Invalid PSBT format");
|
|
1356
1329
|
}
|
|
@@ -1591,7 +1564,8 @@ var LaserEyesProvider = ({
|
|
|
1591
1564
|
} else if (provider === LEATHER) {
|
|
1592
1565
|
const requestParams = {
|
|
1593
1566
|
hex: psbtHex,
|
|
1594
|
-
broadcast
|
|
1567
|
+
broadcast,
|
|
1568
|
+
network
|
|
1595
1569
|
};
|
|
1596
1570
|
const response = yield library == null ? void 0 : library.request(
|
|
1597
1571
|
"signPsbt",
|
|
@@ -1599,7 +1573,7 @@ var LaserEyesProvider = ({
|
|
|
1599
1573
|
);
|
|
1600
1574
|
const leatherHexResult = response.result;
|
|
1601
1575
|
const signedTx = leatherHexResult.hex;
|
|
1602
|
-
const signed = bitcoin2.Psbt.
|
|
1576
|
+
const signed = bitcoin2.Psbt.fromHex(String(signedTx));
|
|
1603
1577
|
if (finalize && broadcast) {
|
|
1604
1578
|
const finalized = signed.finalizeAllInputs();
|
|
1605
1579
|
const extracted = finalized.extractTransaction();
|
|
@@ -1662,7 +1636,9 @@ var LaserEyesProvider = ({
|
|
|
1662
1636
|
} else if (provider === MAGIC_EDEN) {
|
|
1663
1637
|
return yield import_axios2.default.post("https://mempool.space/api/tx", psbt).then((res) => res.data);
|
|
1664
1638
|
} else if (provider === LEATHER) {
|
|
1665
|
-
|
|
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);
|
|
1666
1642
|
} else if (provider === WIZZ) {
|
|
1667
1643
|
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1668
1644
|
} else {
|
|
@@ -1881,6 +1857,7 @@ var useInscriber = ({
|
|
|
1881
1857
|
LaserEyesProvider,
|
|
1882
1858
|
MAGIC_EDEN,
|
|
1883
1859
|
MAINNET,
|
|
1860
|
+
MEMPOOL_SPACE_SIGNET_URL,
|
|
1884
1861
|
MEMPOOL_SPACE_TESTNET_URL,
|
|
1885
1862
|
MEMPOOL_SPACE_URL,
|
|
1886
1863
|
OKX,
|
|
@@ -1907,6 +1884,7 @@ var useInscriber = ({
|
|
|
1907
1884
|
XVERSE,
|
|
1908
1885
|
XVERSE_MAINNET,
|
|
1909
1886
|
XVERSE_NETWORK,
|
|
1887
|
+
XVERSE_SIGNET,
|
|
1910
1888
|
XVERSE_TESTNET,
|
|
1911
1889
|
createConfig,
|
|
1912
1890
|
createSendBtcPsbt,
|
|
@@ -1914,8 +1892,6 @@ var useInscriber = ({
|
|
|
1914
1892
|
estimateTxSize,
|
|
1915
1893
|
findOrdinalsAddress,
|
|
1916
1894
|
findPaymentAddress,
|
|
1917
|
-
getAddressType,
|
|
1918
|
-
getAddressUtxos,
|
|
1919
1895
|
getBTCBalance,
|
|
1920
1896
|
getBitcoinNetwork,
|
|
1921
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
|
}
|
|
@@ -1224,7 +1199,7 @@ var LaserEyesProvider = ({
|
|
|
1224
1199
|
network: {
|
|
1225
1200
|
type: BitcoinNetworkType.Mainnet
|
|
1226
1201
|
},
|
|
1227
|
-
address:
|
|
1202
|
+
address: paymentAddress,
|
|
1228
1203
|
message
|
|
1229
1204
|
},
|
|
1230
1205
|
onFinish: (response) => {
|
|
@@ -1240,15 +1215,13 @@ 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
|
-
console.log(signed);
|
|
1246
1220
|
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1247
1221
|
} else if (provider === PHANTOM) {
|
|
1248
1222
|
const utf8Bytes = new TextEncoder().encode(message);
|
|
1249
1223
|
const uintArray = new Uint8Array(utf8Bytes);
|
|
1250
1224
|
const response = yield library == null ? void 0 : library.signMessage(address2, uintArray);
|
|
1251
|
-
console.log(response);
|
|
1252
1225
|
const binaryString = String.fromCharCode(...response.signature);
|
|
1253
1226
|
return btoa(binaryString);
|
|
1254
1227
|
} else if (provider === WIZZ) {
|
|
@@ -1271,8 +1244,8 @@ var LaserEyesProvider = ({
|
|
|
1271
1244
|
psbtBase64 = bitcoin2.Psbt.fromHex(psbt).toBase64();
|
|
1272
1245
|
psbtHex = psbt;
|
|
1273
1246
|
} else if (isBase64(psbt)) {
|
|
1274
|
-
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1275
1247
|
psbtBase64 = psbt;
|
|
1248
|
+
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1276
1249
|
} else {
|
|
1277
1250
|
throw new Error("Invalid PSBT format");
|
|
1278
1251
|
}
|
|
@@ -1513,7 +1486,8 @@ var LaserEyesProvider = ({
|
|
|
1513
1486
|
} else if (provider === LEATHER) {
|
|
1514
1487
|
const requestParams = {
|
|
1515
1488
|
hex: psbtHex,
|
|
1516
|
-
broadcast
|
|
1489
|
+
broadcast,
|
|
1490
|
+
network
|
|
1517
1491
|
};
|
|
1518
1492
|
const response = yield library == null ? void 0 : library.request(
|
|
1519
1493
|
"signPsbt",
|
|
@@ -1521,7 +1495,7 @@ var LaserEyesProvider = ({
|
|
|
1521
1495
|
);
|
|
1522
1496
|
const leatherHexResult = response.result;
|
|
1523
1497
|
const signedTx = leatherHexResult.hex;
|
|
1524
|
-
const signed = bitcoin2.Psbt.
|
|
1498
|
+
const signed = bitcoin2.Psbt.fromHex(String(signedTx));
|
|
1525
1499
|
if (finalize && broadcast) {
|
|
1526
1500
|
const finalized = signed.finalizeAllInputs();
|
|
1527
1501
|
const extracted = finalized.extractTransaction();
|
|
@@ -1584,7 +1558,9 @@ var LaserEyesProvider = ({
|
|
|
1584
1558
|
} else if (provider === MAGIC_EDEN) {
|
|
1585
1559
|
return yield axios2.post("https://mempool.space/api/tx", psbt).then((res) => res.data);
|
|
1586
1560
|
} else if (provider === LEATHER) {
|
|
1587
|
-
|
|
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);
|
|
1588
1564
|
} else if (provider === WIZZ) {
|
|
1589
1565
|
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1590
1566
|
} else {
|
|
@@ -1802,6 +1778,7 @@ export {
|
|
|
1802
1778
|
LaserEyesProvider,
|
|
1803
1779
|
MAGIC_EDEN,
|
|
1804
1780
|
MAINNET,
|
|
1781
|
+
MEMPOOL_SPACE_SIGNET_URL,
|
|
1805
1782
|
MEMPOOL_SPACE_TESTNET_URL,
|
|
1806
1783
|
MEMPOOL_SPACE_URL,
|
|
1807
1784
|
OKX,
|
|
@@ -1828,6 +1805,7 @@ export {
|
|
|
1828
1805
|
XVERSE,
|
|
1829
1806
|
XVERSE_MAINNET,
|
|
1830
1807
|
XVERSE_NETWORK,
|
|
1808
|
+
XVERSE_SIGNET,
|
|
1831
1809
|
XVERSE_TESTNET,
|
|
1832
1810
|
createConfig,
|
|
1833
1811
|
createSendBtcPsbt,
|
|
@@ -1835,8 +1813,6 @@ export {
|
|
|
1835
1813
|
estimateTxSize,
|
|
1836
1814
|
findOrdinalsAddress,
|
|
1837
1815
|
findPaymentAddress,
|
|
1838
|
-
getAddressType,
|
|
1839
|
-
getAddressUtxos,
|
|
1840
1816
|
getBTCBalance,
|
|
1841
1817
|
getBitcoinNetwork,
|
|
1842
1818
|
getLeatherNetwork,
|