@secondlayer/stacks 6.1.0 → 6.1.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/dist/shared/stacks-esm-0pc6tmf0.js +50 -0
- package/dist/shared/{stacks-esm-743jfh10.js.map → stacks-esm-0pc6tmf0.js.map} +2 -2
- package/dist/shared/{stacks-esm-0rdxcta7.js → stacks-esm-16d82wyc.js} +10 -10
- package/dist/shared/{stacks-esm-0rdxcta7.js.map → stacks-esm-16d82wyc.js.map} +2 -2
- package/dist/shared/{stacks-esm-cvhazvhd.js → stacks-esm-7a0ehykf.js} +43 -43
- package/dist/shared/{stacks-esm-cvhazvhd.js.map → stacks-esm-7a0ehykf.js.map} +2 -2
- package/dist/shared/{stacks-esm-1jae0a3r.js → stacks-esm-7v18h5dk.js} +4 -4
- package/dist/shared/{stacks-esm-1jae0a3r.js.map → stacks-esm-7v18h5dk.js.map} +2 -2
- package/dist/shared/{stacks-esm-9rnx0zxr.js → stacks-esm-8f5catbf.js} +126 -126
- package/dist/shared/{stacks-esm-9rnx0zxr.js.map → stacks-esm-8f5catbf.js.map} +2 -2
- package/dist/shared/{stacks-esm-7fpqgtyx.js → stacks-esm-8jt6k8p3.js} +13 -13
- package/dist/shared/{stacks-esm-7fpqgtyx.js.map → stacks-esm-8jt6k8p3.js.map} +2 -2
- package/dist/shared/{stacks-esm-hr7fpxtj.js → stacks-esm-a20wyky3.js} +92 -92
- package/dist/shared/{stacks-esm-hr7fpxtj.js.map → stacks-esm-a20wyky3.js.map} +2 -2
- package/dist/shared/{stacks-esm-3pv5avgr.js → stacks-esm-b54n1jdx.js} +54 -54
- package/dist/shared/{stacks-esm-3pv5avgr.js.map → stacks-esm-b54n1jdx.js.map} +2 -2
- package/dist/shared/{stacks-esm-r9q4wnyw.js → stacks-esm-cmtj5vky.js} +162 -162
- package/dist/shared/{stacks-esm-r9q4wnyw.js.map → stacks-esm-cmtj5vky.js.map} +2 -2
- package/dist/shared/{stacks-esm-wv67m4g6.js → stacks-esm-e2qhfgke.js} +36 -36
- package/dist/shared/{stacks-esm-wv67m4g6.js.map → stacks-esm-e2qhfgke.js.map} +2 -2
- package/dist/shared/{stacks-esm-qk0p9fr6.js → stacks-esm-ea4m4bk7.js} +117 -117
- package/dist/shared/{stacks-esm-qk0p9fr6.js.map → stacks-esm-ea4m4bk7.js.map} +2 -2
- package/dist/shared/{stacks-esm-fcfdn2zx.js → stacks-esm-hkw1kvd4.js} +140 -140
- package/dist/shared/{stacks-esm-fcfdn2zx.js.map → stacks-esm-hkw1kvd4.js.map} +2 -2
- package/dist/shared/{stacks-esm-qkj67g80.js → stacks-esm-k108pemv.js} +4 -4
- package/dist/shared/{stacks-esm-qkj67g80.js.map → stacks-esm-k108pemv.js.map} +2 -2
- package/dist/shared/stacks-esm-kbz5s6v8.js +84 -0
- package/dist/shared/{stacks-esm-2mc7ebrm.js.map → stacks-esm-kbz5s6v8.js.map} +2 -2
- package/dist/shared/{stacks-esm-n53kvwmt.js → stacks-esm-mt1thm7k.js} +9 -9
- package/dist/shared/{stacks-esm-n53kvwmt.js.map → stacks-esm-mt1thm7k.js.map} +2 -2
- package/dist/shared/{stacks-esm-v45990hx.js → stacks-esm-n1mekwnb.js} +9 -9
- package/dist/shared/{stacks-esm-v45990hx.js.map → stacks-esm-n1mekwnb.js.map} +2 -2
- package/dist/shared/{stacks-esm-r6dejrgr.js → stacks-esm-nt5hf8ht.js} +34 -34
- package/dist/shared/{stacks-esm-r6dejrgr.js.map → stacks-esm-nt5hf8ht.js.map} +2 -2
- package/dist/shared/{stacks-esm-skmcf5n2.js → stacks-esm-phgy8yqf.js} +210 -210
- package/dist/shared/{stacks-esm-skmcf5n2.js.map → stacks-esm-phgy8yqf.js.map} +2 -2
- package/dist/shared/{stacks-esm-kds4n82p.js → stacks-esm-pxv6ny92.js} +116 -116
- package/dist/shared/{stacks-esm-kds4n82p.js.map → stacks-esm-pxv6ny92.js.map} +2 -2
- package/dist/shared/{stacks-esm-3g33bqsm.js → stacks-esm-qfzxhdqz.js} +19 -19
- package/dist/shared/{stacks-esm-3g33bqsm.js.map → stacks-esm-qfzxhdqz.js.map} +2 -2
- package/dist/shared/{stacks-esm-aw2mj3sj.js → stacks-esm-snj9s2q8.js} +43 -43
- package/dist/shared/{stacks-esm-aw2mj3sj.js.map → stacks-esm-snj9s2q8.js.map} +2 -2
- package/dist/shared/{stacks-esm-q19a17fd.js → stacks-esm-ss9ap75h.js} +28 -28
- package/dist/shared/{stacks-esm-q19a17fd.js.map → stacks-esm-ss9ap75h.js.map} +2 -2
- package/dist/shared/{stacks-esm-x1r01353.js → stacks-esm-t88hc019.js} +18 -18
- package/dist/shared/{stacks-esm-x1r01353.js.map → stacks-esm-t88hc019.js.map} +2 -2
- package/dist/shared/stacks-esm-tdrdye4y.js +48 -0
- package/dist/shared/{stacks-esm-pxhfqfff.js.map → stacks-esm-tdrdye4y.js.map} +2 -2
- package/dist/src/accounts/index.cjs +15 -13
- package/dist/src/accounts/index.cjs.map +2 -2
- package/dist/src/accounts/index.d.cts +1 -1
- package/dist/src/accounts/index.d.ts +1 -1
- package/dist/src/accounts/index.js +26 -26
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.cjs +83 -81
- package/dist/src/actions/index.cjs.map +2 -2
- package/dist/src/actions/index.d.cts +1 -1
- package/dist/src/actions/index.d.ts +1 -1
- package/dist/src/actions/index.js +102 -103
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.cjs +2035 -2036
- package/dist/src/bitcoin/index.cjs.map +8 -8
- package/dist/src/bitcoin/index.d.cts +92 -92
- package/dist/src/bitcoin/index.d.ts +92 -92
- package/dist/src/bitcoin/index.js +88 -90
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.cjs +3313 -3310
- package/dist/src/bns/index.cjs.map +13 -13
- package/dist/src/bns/index.d.cts +1 -1
- package/dist/src/bns/index.d.ts +1 -1
- package/dist/src/bns/index.js +39 -41
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/chains/index.cjs +14 -12
- package/dist/src/chains/index.cjs.map +2 -2
- package/dist/src/chains/index.d.cts +1 -1
- package/dist/src/chains/index.d.ts +1 -1
- package/dist/src/chains/index.js +12 -12
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/clarity/index.cjs +98 -96
- package/dist/src/clarity/index.cjs.map +2 -2
- package/dist/src/clarity/index.d.cts +1 -1
- package/dist/src/clarity/index.d.ts +1 -1
- package/dist/src/clarity/index.js +170 -171
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/connect/index.cjs +19 -19
- package/dist/src/connect/index.cjs.map +2 -2
- package/dist/src/connect/index.d.cts +1 -1
- package/dist/src/connect/index.d.ts +1 -1
- package/dist/src/connect/index.js +19 -19
- package/dist/src/connect/index.js.map +2 -2
- package/dist/src/connect/walletconnect/index.cjs +6 -46
- package/dist/src/connect/walletconnect/index.cjs.map +3 -4
- package/dist/src/connect/walletconnect/index.d.cts +1 -1
- package/dist/src/connect/walletconnect/index.d.ts +1 -1
- package/dist/src/connect/walletconnect/index.js +6 -46
- package/dist/src/connect/walletconnect/index.js.map +3 -4
- package/dist/src/filters/index.cjs +22 -20
- package/dist/src/filters/index.cjs.map +2 -2
- package/dist/src/filters/index.d.cts +1 -1
- package/dist/src/filters/index.d.ts +1 -1
- package/dist/src/filters/index.js +30 -30
- package/dist/src/filters/index.js.map +1 -1
- package/dist/src/index.cjs +1411 -1410
- package/dist/src/index.cjs.map +11 -11
- package/dist/src/index.d.cts +724 -724
- package/dist/src/index.d.ts +724 -724
- package/dist/src/index.js +219 -219
- package/dist/src/index.js.map +2 -2
- package/dist/src/postconditions/index.cjs +26 -24
- package/dist/src/postconditions/index.cjs.map +2 -2
- package/dist/src/postconditions/index.d.cts +1 -1
- package/dist/src/postconditions/index.d.ts +1 -1
- package/dist/src/postconditions/index.js +16 -17
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.cjs +722 -721
- package/dist/src/pox/index.cjs.map +9 -9
- package/dist/src/pox/index.d.cts +1 -1
- package/dist/src/pox/index.d.ts +1 -1
- package/dist/src/pox/index.js +40 -41
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/pox5/index.cjs +141 -137
- package/dist/src/pox5/index.cjs.map +3 -3
- package/dist/src/pox5/index.d.cts +9 -1
- package/dist/src/pox5/index.d.ts +9 -1
- package/dist/src/pox5/index.js +210 -209
- package/dist/src/pox5/index.js.map +3 -3
- package/dist/src/sbtc/index.cjs +71 -69
- package/dist/src/sbtc/index.cjs.map +2 -2
- package/dist/src/sbtc/index.d.cts +1 -1
- package/dist/src/sbtc/index.d.ts +1 -1
- package/dist/src/sbtc/index.js +39 -40
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/simnet/index.cjs +16 -16
- package/dist/src/simnet/index.cjs.map +2 -2
- package/dist/src/simnet/index.d.cts +1 -1
- package/dist/src/simnet/index.d.ts +1 -1
- package/dist/src/simnet/index.js +16 -16
- package/dist/src/simnet/index.js.map +2 -2
- package/dist/src/stackingdao/index.cjs +716 -715
- package/dist/src/stackingdao/index.cjs.map +9 -9
- package/dist/src/stackingdao/index.d.cts +1 -1
- package/dist/src/stackingdao/index.d.ts +1 -1
- package/dist/src/stackingdao/index.js +26 -27
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.cjs +15 -13
- package/dist/src/subscriptions/index.cjs.map +2 -2
- package/dist/src/subscriptions/index.d.cts +1 -1
- package/dist/src/subscriptions/index.d.ts +1 -1
- package/dist/src/subscriptions/index.js +14 -15
- package/dist/src/subscriptions/index.js.map +1 -1
- package/dist/src/transactions/index.cjs +79 -77
- package/dist/src/transactions/index.cjs.map +2 -2
- package/dist/src/transactions/index.d.cts +1 -1
- package/dist/src/transactions/index.d.ts +1 -1
- package/dist/src/transactions/index.js +104 -105
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.cjs +76 -74
- package/dist/src/utils/index.cjs.map +2 -2
- package/dist/src/utils/index.d.cts +1 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.js +131 -131
- package/dist/src/utils/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/shared/stacks-esm-2mc7ebrm.js +0 -84
- package/dist/shared/stacks-esm-743jfh10.js +0 -50
- package/dist/shared/stacks-esm-pxhfqfff.js +0 -48
package/dist/src/sbtc/index.cjs
CHANGED
|
@@ -19,13 +19,15 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
return cached;
|
|
20
20
|
}
|
|
21
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(mod))
|
|
25
|
+
if (!__hasOwnProp.call(to, key))
|
|
26
|
+
__defProp(to, key, {
|
|
27
|
+
get: __accessProp.bind(mod, key),
|
|
28
|
+
enumerable: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
29
31
|
if (canCache)
|
|
30
32
|
cache.set(mod, to);
|
|
31
33
|
return to;
|
|
@@ -64,22 +66,22 @@ var __export = (target, all) => {
|
|
|
64
66
|
// src/sbtc/index.ts
|
|
65
67
|
var exports_sbtc = {};
|
|
66
68
|
__export(exports_sbtc, {
|
|
67
|
-
|
|
68
|
-
sbtcToSats: () => sbtcToSats,
|
|
69
|
-
sbtcContractId: () => sbtcContractId,
|
|
70
|
-
sbtc: () => sbtc,
|
|
71
|
-
satsToSbtc: () => satsToSbtc,
|
|
72
|
-
formatBtcAddress: () => formatBtcAddress,
|
|
73
|
-
bitcoinTxidToHex: () => bitcoinTxidToHex,
|
|
74
|
-
bitcoinTxidFromHex: () => bitcoinTxidFromHex,
|
|
75
|
-
SBTC_UNIT_NAME: () => SBTC_UNIT_NAME,
|
|
76
|
-
SBTC_TOKEN_ABI: () => SBTC_TOKEN_ABI,
|
|
77
|
-
SBTC_EVENT_TOPICS: () => SBTC_EVENT_TOPICS,
|
|
78
|
-
SBTC_DECIMALS: () => SBTC_DECIMALS,
|
|
79
|
-
SBTC_CONTRACTS: () => SBTC_CONTRACTS,
|
|
80
|
-
SBTC_BTC_ADDRESS_VERSION: () => SBTC_BTC_ADDRESS_VERSION,
|
|
69
|
+
SBTC_ASSET_IDENTIFIER_MAINNET: () => SBTC_ASSET_IDENTIFIER_MAINNET,
|
|
81
70
|
SBTC_ASSET_IDENTIFIER_TESTNET: () => SBTC_ASSET_IDENTIFIER_TESTNET,
|
|
82
|
-
|
|
71
|
+
SBTC_BTC_ADDRESS_VERSION: () => SBTC_BTC_ADDRESS_VERSION,
|
|
72
|
+
SBTC_CONTRACTS: () => SBTC_CONTRACTS,
|
|
73
|
+
SBTC_DECIMALS: () => SBTC_DECIMALS,
|
|
74
|
+
SBTC_EVENT_TOPICS: () => SBTC_EVENT_TOPICS,
|
|
75
|
+
SBTC_TOKEN_ABI: () => SBTC_TOKEN_ABI,
|
|
76
|
+
SBTC_UNIT_NAME: () => SBTC_UNIT_NAME,
|
|
77
|
+
bitcoinTxidFromHex: () => bitcoinTxidFromHex,
|
|
78
|
+
bitcoinTxidToHex: () => bitcoinTxidToHex,
|
|
79
|
+
formatBtcAddress: () => formatBtcAddress,
|
|
80
|
+
satsToSbtc: () => satsToSbtc,
|
|
81
|
+
sbtc: () => sbtc,
|
|
82
|
+
sbtcContractId: () => sbtcContractId,
|
|
83
|
+
sbtcToSats: () => sbtcToSats,
|
|
84
|
+
validateBitcoinTxid: () => validateBitcoinTxid
|
|
83
85
|
});
|
|
84
86
|
module.exports = __toCommonJS(exports_sbtc);
|
|
85
87
|
|
|
@@ -665,8 +667,8 @@ function clarityTypeFromByte(byte) {
|
|
|
665
667
|
// src/clarity/deserialize.ts
|
|
666
668
|
function readAddress(reader) {
|
|
667
669
|
const version = reader.readUInt8();
|
|
668
|
-
const
|
|
669
|
-
return c32address(version,
|
|
670
|
+
const hash160 = bytesToHex(reader.readBytes(20));
|
|
671
|
+
return c32address(version, hash160);
|
|
670
672
|
}
|
|
671
673
|
function readLPString(reader, prefixBytes = 1) {
|
|
672
674
|
let length = 0;
|
|
@@ -766,8 +768,8 @@ function withTypeId(type, bytes) {
|
|
|
766
768
|
return concatBytes(new Uint8Array([typeIdByte(type)]), bytes);
|
|
767
769
|
}
|
|
768
770
|
function serializeAddress(c32Address) {
|
|
769
|
-
const [version,
|
|
770
|
-
return concatBytes(new Uint8Array([version]), hexToBytes(
|
|
771
|
+
const [version, hash160] = c32addressDecode(c32Address);
|
|
772
|
+
return concatBytes(new Uint8Array([version]), hexToBytes(hash160));
|
|
771
773
|
}
|
|
772
774
|
function serializeLPString(str, prefixBytes = 1) {
|
|
773
775
|
const content = utf8ToBytes(str);
|
|
@@ -874,13 +876,13 @@ function bufferCV(buffer) {
|
|
|
874
876
|
return { type: "buffer", value: bytesToHex(buffer) };
|
|
875
877
|
}
|
|
876
878
|
function standardPrincipalCV(address) {
|
|
877
|
-
const [version,
|
|
878
|
-
const normalized = c32address(version,
|
|
879
|
+
const [version, hash160] = c32addressDecode(address);
|
|
880
|
+
const normalized = c32address(version, hash160);
|
|
879
881
|
return { type: "address", value: normalized };
|
|
880
882
|
}
|
|
881
883
|
function contractPrincipalCV(address, contractName) {
|
|
882
|
-
const [version,
|
|
883
|
-
const normalized = c32address(version,
|
|
884
|
+
const [version, hash160] = c32addressDecode(address);
|
|
885
|
+
const normalized = c32address(version, hash160);
|
|
884
886
|
if (utf8ToBytes(contractName).byteLength >= 128) {
|
|
885
887
|
throw new Error("Contract name must be less than 128 bytes");
|
|
886
888
|
}
|
|
@@ -1491,8 +1493,8 @@ function deserializeTransaction(input, meta) {
|
|
|
1491
1493
|
|
|
1492
1494
|
// src/transactions/wire/serialize.ts
|
|
1493
1495
|
function serializeAddress2(c32Address) {
|
|
1494
|
-
const [version,
|
|
1495
|
-
return concatBytes(new Uint8Array([version]), hexToBytes(
|
|
1496
|
+
const [version, hash160] = c32addressDecode(c32Address);
|
|
1497
|
+
return concatBytes(new Uint8Array([version]), hexToBytes(hash160));
|
|
1496
1498
|
}
|
|
1497
1499
|
function serializeLPString2(str, prefixBytes = 1) {
|
|
1498
1500
|
const content = utf8ToBytes(str);
|
|
@@ -1531,8 +1533,8 @@ function serializeSpendingCondition(condition) {
|
|
|
1531
1533
|
}
|
|
1532
1534
|
function serializeAuthField(field) {
|
|
1533
1535
|
if (field.type === "publicKey") {
|
|
1534
|
-
const
|
|
1535
|
-
return concatBytes(writeUInt8(
|
|
1536
|
+
const typeId = field.pubKeyEncoding === 0 ? 0 : 1;
|
|
1537
|
+
return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
|
|
1536
1538
|
}
|
|
1537
1539
|
const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
|
|
1538
1540
|
return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
|
|
@@ -2002,11 +2004,11 @@ function replayMultiSigSigHash(tx) {
|
|
|
2002
2004
|
const condition = tx.auth.spendingCondition;
|
|
2003
2005
|
if (isNonSequential(condition.hashMode)) {
|
|
2004
2006
|
const preSign = nonSequentialPreSignHash(tx);
|
|
2005
|
-
let
|
|
2007
|
+
let curSigHash = preSign;
|
|
2006
2008
|
for (const field of condition.fields) {
|
|
2007
|
-
|
|
2009
|
+
curSigHash = sigHashPostSign(curSigHash, field.pubKeyEncoding, field.data);
|
|
2008
2010
|
}
|
|
2009
|
-
return
|
|
2011
|
+
return curSigHash;
|
|
2010
2012
|
}
|
|
2011
2013
|
let curSigHash = initialSigHash(tx);
|
|
2012
2014
|
for (const field of condition.fields) {
|
|
@@ -2127,8 +2129,8 @@ async function signSequentialWithAccount(tx, condition, account, publicKeys, sig
|
|
|
2127
2129
|
const fields = [...condition.fields];
|
|
2128
2130
|
let curSigHash = initialSigHash(tx);
|
|
2129
2131
|
for (const field of fields) {
|
|
2130
|
-
const
|
|
2131
|
-
curSigHash = sigHashPostSign(
|
|
2132
|
+
const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
|
|
2133
|
+
curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);
|
|
2132
2134
|
}
|
|
2133
2135
|
for (let i = fields.length;i < signerIndex; i++) {
|
|
2134
2136
|
const pubKeyField = {
|
|
@@ -2137,8 +2139,8 @@ async function signSequentialWithAccount(tx, condition, account, publicKeys, sig
|
|
|
2137
2139
|
data: publicKeys[i]
|
|
2138
2140
|
};
|
|
2139
2141
|
fields.push(pubKeyField);
|
|
2140
|
-
const
|
|
2141
|
-
curSigHash = sigHashPostSign(
|
|
2142
|
+
const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
|
|
2143
|
+
curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);
|
|
2142
2144
|
}
|
|
2143
2145
|
const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
|
|
2144
2146
|
const sigBytes = await account.sign(hexToBytes(preSign));
|
|
@@ -2432,9 +2434,9 @@ function getOriginSigHash(tx) {
|
|
|
2432
2434
|
if ("fields" in condition) {
|
|
2433
2435
|
return replayMultiSigSigHash(tx);
|
|
2434
2436
|
}
|
|
2435
|
-
const
|
|
2437
|
+
const initialSigHash = signBegin(tx);
|
|
2436
2438
|
const sc = condition;
|
|
2437
|
-
const preSign = sigHashPreSign(
|
|
2439
|
+
const preSign = sigHashPreSign(initialSigHash, AuthType.Standard, sc.fee, sc.nonce);
|
|
2438
2440
|
return sigHashPostSign(preSign, sc.keyEncoding, sc.signature);
|
|
2439
2441
|
}
|
|
2440
2442
|
function signSponsor(tx, privateKey) {
|
|
@@ -2738,8 +2740,8 @@ function indexNotFound(error, sourceName) {
|
|
|
2738
2740
|
}
|
|
2739
2741
|
return true;
|
|
2740
2742
|
}
|
|
2741
|
-
function normalizeTxid(
|
|
2742
|
-
return
|
|
2743
|
+
function normalizeTxid(txid) {
|
|
2744
|
+
return txid.startsWith("0x") ? txid : `0x${txid}`;
|
|
2743
2745
|
}
|
|
2744
2746
|
function decodeResultHex(hex) {
|
|
2745
2747
|
if (!hex)
|
|
@@ -2763,10 +2765,10 @@ function normalizeStatus(txStatus) {
|
|
|
2763
2765
|
}
|
|
2764
2766
|
function extendedApiSource() {
|
|
2765
2767
|
return {
|
|
2766
|
-
async get({ client, txid
|
|
2768
|
+
async get({ client, txid }) {
|
|
2767
2769
|
let data;
|
|
2768
2770
|
try {
|
|
2769
|
-
data = await client.request(`/extended/v1/tx/${encodeURIComponent(normalizeTxid(
|
|
2771
|
+
data = await client.request(`/extended/v1/tx/${encodeURIComponent(normalizeTxid(txid))}`, { method: "GET" });
|
|
2770
2772
|
} catch (error) {
|
|
2771
2773
|
if (error instanceof HttpRequestError && error.status === 404) {
|
|
2772
2774
|
return { receipt: null };
|
|
@@ -2781,7 +2783,7 @@ function extendedApiSource() {
|
|
|
2781
2783
|
return { receipt: null };
|
|
2782
2784
|
return {
|
|
2783
2785
|
receipt: {
|
|
2784
|
-
txid: normalizeTxid(
|
|
2786
|
+
txid: normalizeTxid(txid),
|
|
2785
2787
|
status,
|
|
2786
2788
|
blockHeight: typeof data.block_height === "number" && data.block_height > 0 ? data.block_height : undefined,
|
|
2787
2789
|
blockHash: data.block_hash ?? undefined,
|
|
@@ -2797,11 +2799,11 @@ function indexTxSource(params = {}) {
|
|
|
2797
2799
|
const headers = params.apiKey ? { authorization: `Bearer ${params.apiKey}` } : undefined;
|
|
2798
2800
|
return {
|
|
2799
2801
|
canonicalOnly: true,
|
|
2800
|
-
async get({ client, txid
|
|
2802
|
+
async get({ client, txid }) {
|
|
2801
2803
|
const request = indexRequestFn(client, params.baseUrl, "indexTxSource");
|
|
2802
2804
|
let data;
|
|
2803
2805
|
try {
|
|
2804
|
-
data = await request(`/v1/index/transactions/${normalizeTxid(
|
|
2806
|
+
data = await request(`/v1/index/transactions/${normalizeTxid(txid)}`, {
|
|
2805
2807
|
method: "GET",
|
|
2806
2808
|
headers
|
|
2807
2809
|
});
|
|
@@ -2850,7 +2852,7 @@ async function getBlockHeight(client) {
|
|
|
2850
2852
|
var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
2851
2853
|
async function waitForTransactionReceipt(client, params) {
|
|
2852
2854
|
const {
|
|
2853
|
-
txid
|
|
2855
|
+
txid,
|
|
2854
2856
|
confirmations = 1,
|
|
2855
2857
|
timeout = 180000,
|
|
2856
2858
|
pollingInterval = 3000
|
|
@@ -2861,21 +2863,21 @@ async function waitForTransactionReceipt(client, params) {
|
|
|
2861
2863
|
let unknownSince = null;
|
|
2862
2864
|
let everPending = false;
|
|
2863
2865
|
while (true) {
|
|
2864
|
-
const snapshot = await source.get({ client, txid
|
|
2866
|
+
const snapshot = await source.get({ client, txid });
|
|
2865
2867
|
const receipt = snapshot.receipt;
|
|
2866
2868
|
if (receipt === null) {
|
|
2867
2869
|
unknownSince ??= Date.now();
|
|
2868
2870
|
if (Date.now() - unknownSince >= droppedGracePeriod) {
|
|
2869
|
-
throw new TransactionDroppedError(everPending ? `Transaction ${
|
|
2871
|
+
throw new TransactionDroppedError(everPending ? `Transaction ${txid} left the mempool without being mined` : `Transaction ${txid} was never observed by the status source`, { txid });
|
|
2870
2872
|
}
|
|
2871
2873
|
} else {
|
|
2872
2874
|
unknownSince = null;
|
|
2873
2875
|
switch (receipt.status) {
|
|
2874
2876
|
case "dropped":
|
|
2875
|
-
throw new TransactionDroppedError(`Transaction ${
|
|
2877
|
+
throw new TransactionDroppedError(`Transaction ${txid} was dropped from the mempool`, { txid });
|
|
2876
2878
|
case "abort_by_response":
|
|
2877
2879
|
case "abort_by_post_condition":
|
|
2878
|
-
throw new TransactionAbortedError(`Transaction ${
|
|
2880
|
+
throw new TransactionAbortedError(`Transaction ${txid} aborted (${receipt.status})`, { receipt });
|
|
2879
2881
|
case "pending":
|
|
2880
2882
|
everPending = true;
|
|
2881
2883
|
break;
|
|
@@ -2892,7 +2894,7 @@ async function waitForTransactionReceipt(client, params) {
|
|
|
2892
2894
|
}
|
|
2893
2895
|
}
|
|
2894
2896
|
if (Date.now() - startedAt >= timeout) {
|
|
2895
|
-
throw new WaitForTransactionTimeoutError(`Timed out after ${timeout}ms waiting for transaction ${
|
|
2897
|
+
throw new WaitForTransactionTimeoutError(`Timed out after ${timeout}ms waiting for transaction ${txid}`, { txid });
|
|
2896
2898
|
}
|
|
2897
2899
|
await sleep2(pollingInterval);
|
|
2898
2900
|
}
|
|
@@ -2920,11 +2922,11 @@ async function sendTransaction(client, params) {
|
|
|
2920
2922
|
throw error;
|
|
2921
2923
|
}
|
|
2922
2924
|
} else if (error instanceof TimeoutError) {
|
|
2923
|
-
const
|
|
2924
|
-
const receipt = await getTransaction(client, { txid
|
|
2925
|
+
const txid = getTransactionId(params.transaction);
|
|
2926
|
+
const receipt = await getTransaction(client, { txid }).catch(() => null);
|
|
2925
2927
|
if (receipt === null)
|
|
2926
2928
|
throw error;
|
|
2927
|
-
data = { txid
|
|
2929
|
+
data = { txid };
|
|
2928
2930
|
} else {
|
|
2929
2931
|
throw error;
|
|
2930
2932
|
}
|
|
@@ -2936,16 +2938,16 @@ async function sendTransaction(client, params) {
|
|
|
2936
2938
|
txid: data.txid ?? getTransactionId(params.transaction)
|
|
2937
2939
|
});
|
|
2938
2940
|
}
|
|
2939
|
-
const
|
|
2941
|
+
const txid = typeof data === "string" ? data.replace(/"/g, "") : data.txid ?? getTransactionId(params.transaction);
|
|
2940
2942
|
if (params.wait) {
|
|
2941
2943
|
const confirmations = params.wait === true ? 1 : params.wait;
|
|
2942
2944
|
const receipt = await waitForTransactionReceipt(client, {
|
|
2943
|
-
txid
|
|
2945
|
+
txid,
|
|
2944
2946
|
confirmations
|
|
2945
2947
|
});
|
|
2946
|
-
return { txid
|
|
2948
|
+
return { txid, receipt };
|
|
2947
2949
|
}
|
|
2948
|
-
return { txid
|
|
2950
|
+
return { txid };
|
|
2949
2951
|
}
|
|
2950
2952
|
|
|
2951
2953
|
// src/actions/wallet/nonceManager.ts
|
|
@@ -3507,8 +3509,8 @@ function stripWitness(rawTx) {
|
|
|
3507
3509
|
return scanTx(rawTx).legacy;
|
|
3508
3510
|
}
|
|
3509
3511
|
function bitcoinTxid(rawTx, { display = false } = {}) {
|
|
3510
|
-
const
|
|
3511
|
-
return display ? reverseBytes(
|
|
3512
|
+
const txid = doubleSha256(scanTx(rawTx).legacy);
|
|
3513
|
+
return display ? reverseBytes(txid) : txid;
|
|
3512
3514
|
}
|
|
3513
3515
|
function parseBlockHeader(header) {
|
|
3514
3516
|
if (header.length !== 80) {
|
|
@@ -3905,14 +3907,14 @@ function bitcoinTxidFromHex(hex) {
|
|
|
3905
3907
|
return buf;
|
|
3906
3908
|
}
|
|
3907
3909
|
function satsToSbtc(sats) {
|
|
3908
|
-
const
|
|
3910
|
+
const sign = sats < 0n ? "-" : "";
|
|
3909
3911
|
const abs = sats < 0n ? -sats : sats;
|
|
3910
3912
|
const whole = abs / 100000000n;
|
|
3911
3913
|
const frac = abs % 100000000n;
|
|
3912
3914
|
if (frac === 0n)
|
|
3913
|
-
return `${
|
|
3915
|
+
return `${sign}${whole}`;
|
|
3914
3916
|
const fracStr = frac.toString().padStart(8, "0").replace(/0+$/, "");
|
|
3915
|
-
return `${
|
|
3917
|
+
return `${sign}${whole}.${fracStr}`;
|
|
3916
3918
|
}
|
|
3917
3919
|
function sbtcToSats(amount) {
|
|
3918
3920
|
const trimmed = amount.trim();
|
|
@@ -3948,5 +3950,5 @@ function sbtc() {
|
|
|
3948
3950
|
});
|
|
3949
3951
|
}
|
|
3950
3952
|
|
|
3951
|
-
//# debugId=
|
|
3953
|
+
//# debugId=8C7FC92EE1E7816764756E2164756E21
|
|
3952
3954
|
//# sourceMappingURL=index.cjs.map
|