@babylonlabs-io/ts-sdk 3.3.1 → 4.1.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/dist/{BTCVaultRegistry.abi-BzNTa_EU.js → BTCVaultRegistry.abi-DnP4UkB5.js} +9 -140
- package/dist/BTCVaultRegistry.abi-DnP4UkB5.js.map +1 -0
- package/dist/{BTCVaultRegistry.abi-BH2-LHxN.cjs → BTCVaultRegistry.abi-DzbfZ9_s.cjs} +2 -2
- package/dist/BTCVaultRegistry.abi-DzbfZ9_s.cjs.map +1 -0
- package/dist/{PayoutManager-xEGvTbhL.js → PayoutManager-BUWP-H-q.js} +3 -3
- package/dist/PayoutManager-BUWP-H-q.js.map +1 -0
- package/dist/{PayoutManager-B1Ev0r7o.cjs → PayoutManager-Dopxq_Jv.cjs} +2 -2
- package/dist/PayoutManager-Dopxq_Jv.cjs.map +1 -0
- package/dist/{PeginManager-D2R4Q1bN.cjs → PeginManager-CMbRRTnr.cjs} +2 -2
- package/dist/PeginManager-CMbRRTnr.cjs.map +1 -0
- package/dist/{PeginManager-CQ9bVPR3.js → PeginManager-Cas6_j7t.js} +7 -7
- package/dist/PeginManager-Cas6_j7t.js.map +1 -0
- package/dist/{ProtocolParams.abi-Cv77fsUe.js → ProtocolParams.abi-CuDl7AuC.js} +3 -3
- package/dist/{ProtocolParams.abi-Cv77fsUe.js.map → ProtocolParams.abi-CuDl7AuC.js.map} +1 -1
- package/dist/{ProtocolParams.abi-BgEZaQ2I.cjs → ProtocolParams.abi-DWfIh6VH.cjs} +2 -2
- package/dist/{ProtocolParams.abi-BgEZaQ2I.cjs.map → ProtocolParams.abi-DWfIh6VH.cjs.map} +1 -1
- package/dist/VaultErrors.abi-Dc3UnB_h.js +5 -0
- package/dist/{VaultErrors.abi-Boz4w97c.js.map → VaultErrors.abi-Dc3UnB_h.js.map} +1 -1
- package/dist/VaultErrors.abi-Hjn1CdLs.cjs +2 -0
- package/dist/{VaultErrors.abi-DQ18kM0L.cjs.map → VaultErrors.abi-Hjn1CdLs.cjs.map} +1 -1
- package/dist/{buildAndBroadcastReclaim-CQANDXVJ.js → buildAndBroadcastReclaim-ByXYSUwj.js} +372 -337
- package/dist/buildAndBroadcastReclaim-ByXYSUwj.js.map +1 -0
- package/dist/buildAndBroadcastReclaim-OBWjvzuC.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-OBWjvzuC.cjs.map +1 -0
- package/dist/challengeAssert-eUMgmpMk.cjs +2 -0
- package/dist/challengeAssert-eUMgmpMk.cjs.map +1 -0
- package/dist/{challengeAssert-B2otuf7y.js → challengeAssert-pJP7MKhG.js} +164 -164
- package/dist/challengeAssert-pJP7MKhG.js.map +1 -0
- package/dist/constants-BCg6O0PX.cjs +2 -0
- package/dist/constants-BCg6O0PX.cjs.map +1 -0
- package/dist/constants-CmDDuM3L.js +50 -0
- package/dist/constants-CmDDuM3L.js.map +1 -0
- package/dist/{index-BRsWXDlv.js → index-B-9aXMxk.js} +6 -6
- package/dist/{index-BRsWXDlv.js.map → index-B-9aXMxk.js.map} +1 -1
- package/dist/{index-C6avwx1s.cjs → index-Dn7RlsKK.cjs} +2 -2
- package/dist/{index-C6avwx1s.cjs.map → index-Dn7RlsKK.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +68 -67
- package/dist/pegin-registration-client-DLlaZbsZ.cjs +2 -0
- package/dist/pegin-registration-client-DLlaZbsZ.cjs.map +1 -0
- package/dist/{pegin-registration-client-Cvjk4ILq.js → pegin-registration-client-ZI0k10_3.js} +90 -96
- package/dist/pegin-registration-client-ZI0k10_3.js.map +1 -0
- package/dist/{primeVpAuth-D4UWXQ76.js → primeVpAuth-C-ET0XF4.js} +2 -2
- package/dist/{primeVpAuth-D4UWXQ76.js.map → primeVpAuth-C-ET0XF4.js.map} +1 -1
- package/dist/{primeVpAuth-CXNXYKrh.cjs → primeVpAuth-Ch-ig2My.cjs} +2 -2
- package/dist/{primeVpAuth-CXNXYKrh.cjs.map → primeVpAuth-Ch-ig2My.cjs.map} +1 -1
- package/dist/registration-records-CKc0OVuK.cjs +2 -0
- package/dist/registration-records-CKc0OVuK.cjs.map +1 -0
- package/dist/{registration-records-DJJC2NiO.js → registration-records-D39ApuHS.js} +141 -141
- package/dist/registration-records-D39ApuHS.js.map +1 -0
- package/dist/{signer-set-reader-GrFe_rsW.cjs → signer-set-reader-CJfV-GDz.cjs} +2 -2
- package/dist/signer-set-reader-CJfV-GDz.cjs.map +1 -0
- package/dist/{signer-set-reader-CSUe92zE.js → signer-set-reader-DiwLeqik.js} +3 -3
- package/dist/signer-set-reader-DiwLeqik.js.map +1 -0
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +4 -4
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts +5 -1
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/protocol-params-validation.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/registration-logs-error.d.ts +6 -6
- package/dist/tbv/core/clients/eth/registration-records.d.ts +1 -1
- package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/types.d.ts +32 -13
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.d.ts +4 -2
- package/dist/tbv/core/clients/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.js +6 -6
- package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.js +1 -1
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +5 -111
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +2 -2
- package/dist/tbv/core/contracts/abis/vaultErrors.abi.json.d.ts +1 -1
- package/dist/tbv/core/contracts/index.cjs +1 -1
- package/dist/tbv/core/contracts/index.js +3 -3
- package/dist/tbv/core/deposit-terms/__tests__/rebuildDepositTermsCore.test.d.ts +1 -1
- package/dist/tbv/core/deposit-terms/commissionCeiling.d.ts +1 -1
- package/dist/tbv/core/deposit-terms/depositTerms.d.ts +11 -9
- package/dist/tbv/core/deposit-terms/depositTerms.d.ts.map +1 -1
- package/dist/tbv/core/deposit-terms/rebuildDepositTermsCore.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +69 -68
- package/dist/tbv/core/managers/PayoutManager.d.ts +9 -3
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +13 -3
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/primitives/__tests__/vaultCoreVersion.test.d.ts +1 -1
- package/dist/tbv/core/primitives/challengers.d.ts +12 -5
- package/dist/tbv/core/primitives/challengers.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +1 -1
- package/dist/tbv/core/primitives/index.js +3 -3
- package/dist/tbv/core/primitives/psbt/__tests__/deriveExpectedPeginPayoutScriptPubKey.test.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/constants.d.ts +38 -13
- package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts +3 -6
- package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +29 -9
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
- package/dist/tbv/core/recovery/peginParamsCandidates.d.ts +1 -1
- package/dist/tbv/core/recovery/reconstructPeginParams.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/__tests__/realWasmWatchtowerArtifacts.test.d.ts +2 -2
- package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts +2 -1
- package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts +3 -3
- package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts +1 -1
- package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/planDelegatedClaimSigning.d.ts +2 -1
- package/dist/tbv/core/services/delegated-claim/planDelegatedClaimSigning.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/readDelegatedClaimVaultContext.d.ts +1 -1
- package/dist/tbv/core/services/delegated-claim/readDelegatedClaimVaultContext.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts +3 -3
- package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/types.d.ts +8 -9
- package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/__tests__/signDepositorGraph.realGraph.test.d.ts +3 -3
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +19 -4
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +17 -3
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +44 -43
- package/dist/tbv/core/services/participants/readStampedParticipantKeys.d.ts +19 -7
- package/dist/tbv/core/services/participants/readStampedParticipantKeys.d.ts.map +1 -1
- package/dist/tbv/core/services/refund/__tests__/readRefundPrePeginContext.test.d.ts +12 -0
- package/dist/tbv/core/services/refund/__tests__/readRefundPrePeginContext.test.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts +41 -12
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
- package/dist/tbv/core/services/refund/index.d.ts +1 -0
- package/dist/tbv/core/services/refund/index.d.ts.map +1 -1
- package/dist/tbv/core/services/refund/readRefundPrePeginContext.d.ts +41 -0
- package/dist/tbv/core/services/refund/readRefundPrePeginContext.d.ts.map +1 -0
- package/dist/tbv/core/wasm/index.cjs.map +1 -1
- package/dist/tbv/core/wasm/index.d.ts +8 -11
- package/dist/tbv/core/wasm/index.d.ts.map +1 -1
- package/dist/tbv/core/wasm/index.js.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +69 -68
- package/dist/toRefundInputs-BSQjDOK9.cjs +2 -0
- package/dist/toRefundInputs-BSQjDOK9.cjs.map +1 -0
- package/dist/{toRefundInputs-DH-1bRNY.js → toRefundInputs-BbbvPb2A.js} +175 -173
- package/dist/toRefundInputs-BbbvPb2A.js.map +1 -0
- package/dist/{types-BC2TGzcp.cjs → types-BnZIbDHb.cjs} +2 -2
- package/dist/types-BnZIbDHb.cjs.map +1 -0
- package/dist/{types-24A9Qoxb.js → types-K_aM5GZO.js} +39 -39
- package/dist/types-K_aM5GZO.js.map +1 -0
- package/dist/{verifyKeyPathSchnorrSignature-IIj3Z2se.js → verifyKeyPathSchnorrSignature-DPXOFOol.js} +2 -2
- package/dist/{verifyKeyPathSchnorrSignature-IIj3Z2se.js.map → verifyKeyPathSchnorrSignature-DPXOFOol.js.map} +1 -1
- package/dist/{verifyKeyPathSchnorrSignature-BRTpEH9X.cjs → verifyKeyPathSchnorrSignature-DcxCojp0.cjs} +2 -2
- package/dist/{verifyKeyPathSchnorrSignature-BRTpEH9X.cjs.map → verifyKeyPathSchnorrSignature-DcxCojp0.cjs.map} +1 -1
- package/dist/verifyScriptPathSchnorrSignature-CgDa9Rcg.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-CgDa9Rcg.cjs.map +1 -0
- package/dist/{verifyScriptPathSchnorrSignature-owu3BfyT.js → verifyScriptPathSchnorrSignature-D-fdi-sG.js} +462 -459
- package/dist/verifyScriptPathSchnorrSignature-D-fdi-sG.js.map +1 -0
- package/package.json +3 -3
- package/dist/BTCVaultRegistry.abi-BH2-LHxN.cjs.map +0 -1
- package/dist/BTCVaultRegistry.abi-BzNTa_EU.js.map +0 -1
- package/dist/PayoutManager-B1Ev0r7o.cjs.map +0 -1
- package/dist/PayoutManager-xEGvTbhL.js.map +0 -1
- package/dist/PeginManager-CQ9bVPR3.js.map +0 -1
- package/dist/PeginManager-D2R4Q1bN.cjs.map +0 -1
- package/dist/VaultErrors.abi-Boz4w97c.js +0 -5
- package/dist/VaultErrors.abi-DQ18kM0L.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-CQANDXVJ.js.map +0 -1
- package/dist/buildAndBroadcastReclaim-DPk36Uhp.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-DPk36Uhp.cjs.map +0 -1
- package/dist/challengeAssert-B2otuf7y.js.map +0 -1
- package/dist/challengeAssert-C3eMcM5Y.cjs +0 -2
- package/dist/challengeAssert-C3eMcM5Y.cjs.map +0 -1
- package/dist/constants-CAm10Qwp.cjs +0 -2
- package/dist/constants-CAm10Qwp.cjs.map +0 -1
- package/dist/constants-CvQZuxKv.js +0 -48
- package/dist/constants-CvQZuxKv.js.map +0 -1
- package/dist/pegin-registration-client-CdRyXP3j.cjs +0 -2
- package/dist/pegin-registration-client-CdRyXP3j.cjs.map +0 -1
- package/dist/pegin-registration-client-Cvjk4ILq.js.map +0 -1
- package/dist/registration-records-DJJC2NiO.js.map +0 -1
- package/dist/registration-records-XQMIKjGV.cjs +0 -2
- package/dist/registration-records-XQMIKjGV.cjs.map +0 -1
- package/dist/signer-set-reader-CSUe92zE.js.map +0 -1
- package/dist/signer-set-reader-GrFe_rsW.cjs.map +0 -1
- package/dist/toRefundInputs-DH-1bRNY.js.map +0 -1
- package/dist/toRefundInputs-DRmK83fv.cjs +0 -2
- package/dist/toRefundInputs-DRmK83fv.cjs.map +0 -1
- package/dist/types-24A9Qoxb.js.map +0 -1
- package/dist/types-BC2TGzcp.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-CahYx5Td.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-CahYx5Td.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-owu3BfyT.js.map +0 -1
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { Transaction as b, Psbt as
|
|
1
|
+
import { Transaction as b, Psbt as H, payments as j } from "bitcoinjs-lib";
|
|
2
2
|
import { Buffer as f } from "buffer";
|
|
3
|
-
import { loadTbvWasm as J, tapInternalPubkey as
|
|
4
|
-
import { u as
|
|
5
|
-
import { n as
|
|
6
|
-
import { R as q, a as X, N as M, b as D, c as G, d as
|
|
7
|
-
import { D as
|
|
3
|
+
import { loadTbvWasm as J, tapInternalPubkey as k, getAssertNoPayoutScriptInfo as Z, getChallengeAssertScriptInfo as ee } from "./tbv/core/wasm/index.js";
|
|
4
|
+
import { u as R, T as A, s as g, d as N, h as m, S as B, p as te, k as oe, l as Q } from "./bitcoin-C-TuHb-v.js";
|
|
5
|
+
import { n as re, l as ne, d as se, P as x, m as ie } from "./verifyScriptPathSchnorrSignature-D-fdi-sG.js";
|
|
6
|
+
import { R as q, a as X, N as M, b as D, c as G, d as ae, A as ue, C as z, e as _, f as ce, g as le, h as he, i as pe } from "./constants-CmDDuM3L.js";
|
|
7
|
+
import { D as Y } from "./fundPeginTransaction-CwhRbCQC.js";
|
|
8
8
|
import { X as F } from "./validation-OSC0xTHB.js";
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
if (!Array.isArray(
|
|
9
|
+
const de = (1n << 64n) - 1n;
|
|
10
|
+
function fe(t, n) {
|
|
11
|
+
if (!Array.isArray(t))
|
|
12
12
|
throw new Error(
|
|
13
|
-
`${n} must be an array of positive bigints (got ${typeof
|
|
13
|
+
`${n} must be an array of positive bigints (got ${typeof t}).`
|
|
14
14
|
);
|
|
15
|
-
if (
|
|
15
|
+
if (t.length === 0)
|
|
16
16
|
throw new Error(`${n} must not be empty.`);
|
|
17
|
-
return
|
|
18
|
-
if (typeof
|
|
17
|
+
return t.forEach((e, i) => {
|
|
18
|
+
if (typeof e != "bigint")
|
|
19
19
|
throw new Error(
|
|
20
|
-
`${n}[${i}] must be a bigint (got ${typeof
|
|
20
|
+
`${n}[${i}] must be a bigint (got ${typeof e}); refusing to feed it into satoshi math.`
|
|
21
21
|
);
|
|
22
|
-
if (
|
|
23
|
-
throw new Error(`${n}[${i}] must be > 0 (got ${
|
|
24
|
-
if (
|
|
22
|
+
if (e <= 0n)
|
|
23
|
+
throw new Error(`${n}[${i}] must be > 0 (got ${e}).`);
|
|
24
|
+
if (e > de)
|
|
25
25
|
throw new Error(
|
|
26
|
-
`${n}[${i}] must fit in a u64 (got ${
|
|
26
|
+
`${n}[${i}] must fit in a u64 (got ${e}); refusing to feed it into satoshi math.`
|
|
27
27
|
);
|
|
28
|
-
}),
|
|
28
|
+
}), t;
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
const { WasmPrePeginTx: n } = await J(), { prePeginParams:
|
|
32
|
-
|
|
30
|
+
async function Re(t) {
|
|
31
|
+
const { WasmPrePeginTx: n } = await J(), { prePeginParams: e, fundedPrePeginTxHex: i, htlcVout: a, refundFee: c, hashlock: s } = t, r = re(
|
|
32
|
+
e.authAnchorHash
|
|
33
33
|
), o = new n(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
[...
|
|
34
|
+
e.vaultCoreVersion,
|
|
35
|
+
e.depositorPubkey,
|
|
36
|
+
e.vaultProviderPubkey,
|
|
37
|
+
e.vaultKeeperPubkeys,
|
|
38
|
+
e.universalChallengerPubkeys,
|
|
39
|
+
[...e.hashlocks],
|
|
40
40
|
new BigUint64Array(
|
|
41
|
-
|
|
41
|
+
fe(e.pegInAmounts, "pegInAmounts")
|
|
42
42
|
),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
e.timelockRefund,
|
|
44
|
+
e.feeRate,
|
|
45
|
+
e.minPeginFeeRate,
|
|
46
|
+
e.numLocalChallengers,
|
|
47
|
+
e.councilQuorum,
|
|
48
|
+
e.councilSize,
|
|
49
|
+
e.network,
|
|
50
50
|
r
|
|
51
51
|
);
|
|
52
52
|
let u = null;
|
|
53
53
|
try {
|
|
54
|
-
const p = o.getHtlcScriptPubKey(a).toLowerCase(), l =
|
|
54
|
+
const p = o.getHtlcScriptPubKey(a).toLowerCase(), l = ne(e, s), d = l.scriptPubKey.toString("hex");
|
|
55
55
|
if (p !== d)
|
|
56
56
|
throw new Error(
|
|
57
57
|
`WASM HTLC scriptPubKey ${p} does not match the independently derived scriptPubKey ${d}.`
|
|
58
58
|
);
|
|
59
|
-
const
|
|
59
|
+
const E = o.getHtlcValue(a);
|
|
60
60
|
u = o.fromFundedTransaction(i);
|
|
61
61
|
const w = u.buildRefundTx(c, a), T = i.startsWith("0x") ? i.slice(2) : i, v = b.fromHex(T), P = v.outs[a];
|
|
62
62
|
if (!P)
|
|
63
63
|
throw new Error(
|
|
64
64
|
`HTLC output at vout ${a} not found in funded Pre-PegIn tx (tx has ${v.outs.length} outputs)`
|
|
65
65
|
);
|
|
66
|
-
const I =
|
|
66
|
+
const I = R(
|
|
67
67
|
new Uint8Array(P.script)
|
|
68
68
|
).toLowerCase();
|
|
69
69
|
if (I !== d)
|
|
70
70
|
throw new Error(
|
|
71
|
-
`HTLC scriptPubKey mismatch at vout ${a}: reconstructed template expects ${d}, funded tx carries ${I}. Refund refused — the (
|
|
71
|
+
`HTLC scriptPubKey mismatch at vout ${a}: reconstructed template expects ${d}, funded tx carries ${I}. Refund refused — the rebuilt HTLC does not commit to the funded output. Check the participant keys first: the vault provider, vault keeper and universal challenger keys must be the operation keys at the vault's frozen epochs (readRefundPrePeginContext, or readStampedParticipantKeys), not roster, indexer or current keys. Then check the hashlock at this vout and timelockRefund, and that the funded transaction is this vault's Pre-PegIn (its txid must equal the vault's on-chain prePeginTxHash).`
|
|
72
72
|
);
|
|
73
73
|
const $ = BigInt(P.value);
|
|
74
|
-
if ($ !==
|
|
74
|
+
if ($ !== E)
|
|
75
75
|
throw new Error(
|
|
76
|
-
`HTLC value mismatch at vout ${a}: reconstructed template expects ${
|
|
76
|
+
`HTLC value mismatch at vout ${a}: reconstructed template expects ${E} sat, funded tx carries ${$} sat. Refund refused — the pegInAmounts vector does not match the on-chain commitment.`
|
|
77
77
|
);
|
|
78
78
|
const h = b.fromHex(w);
|
|
79
79
|
if (h.version !== q)
|
|
@@ -88,22 +88,22 @@ async function Ct(e) {
|
|
|
88
88
|
throw new Error(
|
|
89
89
|
`Refund transaction must have exactly 1 input, got ${h.ins.length}`
|
|
90
90
|
);
|
|
91
|
-
const y = h.ins[0],
|
|
91
|
+
const y = h.ins[0], L = v.getId(), O = R(
|
|
92
92
|
new Uint8Array(y.hash).slice().reverse()
|
|
93
93
|
);
|
|
94
|
-
if (
|
|
94
|
+
if (O !== L)
|
|
95
95
|
throw new Error(
|
|
96
|
-
`Refund input does not reference the Pre-PegIn transaction. Expected ${
|
|
96
|
+
`Refund input does not reference the Pre-PegIn transaction. Expected ${L}, got ${O}`
|
|
97
97
|
);
|
|
98
98
|
if (y.index !== a)
|
|
99
99
|
throw new Error(
|
|
100
100
|
`Refund input index ${y.index} does not match expected htlcVout ${a}`
|
|
101
101
|
);
|
|
102
|
-
if (y.sequence !==
|
|
102
|
+
if (y.sequence !== e.timelockRefund)
|
|
103
103
|
throw new Error(
|
|
104
|
-
`Refund input sequence ${y.sequence} does not match timelockRefund ${
|
|
104
|
+
`Refund input sequence ${y.sequence} does not match timelockRefund ${e.timelockRefund}.`
|
|
105
105
|
);
|
|
106
|
-
const S = new
|
|
106
|
+
const S = new H();
|
|
107
107
|
if (S.setVersion(h.version), S.setLocktime(h.locktime), S.addInput({
|
|
108
108
|
hash: y.hash,
|
|
109
109
|
index: y.index,
|
|
@@ -119,114 +119,114 @@ async function Ct(e) {
|
|
|
119
119
|
controlBlock: l.refundControlBlock
|
|
120
120
|
}
|
|
121
121
|
],
|
|
122
|
-
tapInternalKey: f.from(
|
|
122
|
+
tapInternalKey: f.from(k),
|
|
123
123
|
tapMerkleRoot: l.tapMerkleRoot
|
|
124
124
|
}), h.outs.length !== 1)
|
|
125
125
|
throw new Error(
|
|
126
126
|
`Refund transaction must have exactly 1 output, got ${h.outs.length}`
|
|
127
127
|
);
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
).toLowerCase(),
|
|
131
|
-
new Uint8Array(
|
|
128
|
+
const C = h.outs[0], U = g(
|
|
129
|
+
N(e.depositorPubkey)
|
|
130
|
+
).toLowerCase(), K = R(
|
|
131
|
+
new Uint8Array(C.script)
|
|
132
132
|
).toLowerCase();
|
|
133
|
-
if (
|
|
133
|
+
if (K !== U)
|
|
134
134
|
throw new Error(
|
|
135
|
-
`Refund output scriptPubKey ${
|
|
135
|
+
`Refund output scriptPubKey ${K} does not match the depositor's BIP-86 address ${U}. Refund refused — the reclaimed funds would not return to the depositor.`
|
|
136
136
|
);
|
|
137
|
-
const
|
|
138
|
-
if (BigInt(
|
|
137
|
+
const V = $ - c;
|
|
138
|
+
if (BigInt(C.value) !== V)
|
|
139
139
|
throw new Error(
|
|
140
|
-
`Refund output value ${BigInt(
|
|
140
|
+
`Refund output value ${BigInt(C.value)} sat does not equal the HTLC value ${$} sat minus the requested fee ${c} sat (expected ${V} sat). Refund refused — the reclaimed amount would be burned as excess fee.`
|
|
141
141
|
);
|
|
142
142
|
return S.addOutput({
|
|
143
|
-
script:
|
|
144
|
-
value:
|
|
143
|
+
script: C.script,
|
|
144
|
+
value: C.value
|
|
145
145
|
}), { psbtHex: S.toHex() };
|
|
146
146
|
} finally {
|
|
147
147
|
u == null || u.free(), o.free();
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
const
|
|
151
|
-
function
|
|
152
|
-
if (!Number.isInteger(
|
|
150
|
+
const ge = 2, we = 4294967293, me = 214, $e = 299, xe = 4;
|
|
151
|
+
function Ee(t) {
|
|
152
|
+
if (!Number.isInteger(t) || t < 1)
|
|
153
153
|
throw new Error(
|
|
154
|
-
`Reclaim input count must be a positive integer, got ${
|
|
154
|
+
`Reclaim input count must be a positive integer, got ${t}.`
|
|
155
155
|
);
|
|
156
156
|
return Math.ceil(
|
|
157
|
-
(
|
|
157
|
+
(me + $e * t) / xe
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
|
-
function
|
|
161
|
-
if (!Number.isFinite(
|
|
160
|
+
function He(t, n) {
|
|
161
|
+
if (!Number.isFinite(t) || t <= 0)
|
|
162
162
|
throw new Error(
|
|
163
|
-
`Reclaim fee rate must be a positive number, got ${
|
|
163
|
+
`Reclaim fee rate must be a positive number, got ${t}.`
|
|
164
164
|
);
|
|
165
|
-
return BigInt(Math.ceil(
|
|
165
|
+
return BigInt(Math.ceil(t * Ee(n)));
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
const { depositorPubkey: n, inputs:
|
|
169
|
-
if (
|
|
167
|
+
function _e(t) {
|
|
168
|
+
const { depositorPubkey: n, inputs: e, feeSats: i } = t;
|
|
169
|
+
if (e.length === 0)
|
|
170
170
|
throw new Error("Reclaim requires at least one input; got none.");
|
|
171
171
|
if (i <= 0n)
|
|
172
172
|
throw new Error(
|
|
173
173
|
`Reclaim fee must be positive, got ${i} sat. Refusing to build a transaction that would not relay.`
|
|
174
174
|
);
|
|
175
|
-
const a =
|
|
175
|
+
const a = se(n), c = R(
|
|
176
176
|
new Uint8Array(a.scriptPubKey)
|
|
177
|
-
).toLowerCase(), s = new
|
|
178
|
-
s.setVersion(
|
|
177
|
+
).toLowerCase(), s = new H();
|
|
178
|
+
s.setVersion(ge), s.setLocktime(0);
|
|
179
179
|
let r = 0n;
|
|
180
180
|
const o = /* @__PURE__ */ new Set();
|
|
181
|
-
if (
|
|
182
|
-
const
|
|
181
|
+
if (e.forEach((l, d) => {
|
|
182
|
+
const E = b.fromHex(
|
|
183
183
|
g(l.depositorSignedPeginTxHex)
|
|
184
|
-
), w =
|
|
184
|
+
), w = E.getId(), T = E.outs[x];
|
|
185
185
|
if (!T)
|
|
186
186
|
throw new Error(
|
|
187
|
-
`PegIn ${w} has no output at vout ${
|
|
187
|
+
`PegIn ${w} has no output at vout ${x} (tx has ${E.outs.length}); there is no depositor-claim reserve to reclaim.`
|
|
188
188
|
);
|
|
189
189
|
const v = g(l.observed.txid).toLowerCase();
|
|
190
190
|
if (v !== w)
|
|
191
191
|
throw new Error(
|
|
192
192
|
`Input ${d}: the observation is of ${v}, but this input spends PegIn ${w}. Reclaim refused — the reserve that was looked up is not the one being swept.`
|
|
193
193
|
);
|
|
194
|
-
if (l.observed.vout !==
|
|
194
|
+
if (l.observed.vout !== x)
|
|
195
195
|
throw new Error(
|
|
196
|
-
`Input ${d}: the observation is of vout ${l.observed.vout}, but the depositor-claim reserve is at vout ${
|
|
196
|
+
`Input ${d}: the observation is of vout ${l.observed.vout}, but the depositor-claim reserve is at vout ${x}. Reclaim refused.`
|
|
197
197
|
);
|
|
198
|
-
const P =
|
|
198
|
+
const P = R(
|
|
199
199
|
new Uint8Array(T.script)
|
|
200
200
|
).toLowerCase();
|
|
201
201
|
if (P !== c)
|
|
202
202
|
throw new Error(
|
|
203
|
-
`Input ${d}: PegIn ${w} vout ${
|
|
203
|
+
`Input ${d}: PegIn ${w} vout ${x} pays ${P}, but the connected wallet's depositor-claim script is ${c}. Reclaim refused — this reserve belongs to a different wallet.`
|
|
204
204
|
);
|
|
205
205
|
const I = g(
|
|
206
206
|
l.observed.scriptPubKey
|
|
207
207
|
).toLowerCase();
|
|
208
208
|
if (I !== c)
|
|
209
209
|
throw new Error(
|
|
210
|
-
`Input ${d}: the observed UTXO ${w}:${
|
|
210
|
+
`Input ${d}: the observed UTXO ${w}:${x} pays ${I}, expected ${c}. Reclaim refused — chain state disagrees with the contract's PegIn.`
|
|
211
211
|
);
|
|
212
212
|
const $ = BigInt(T.value);
|
|
213
213
|
if ($ !== l.observed.value)
|
|
214
214
|
throw new Error(
|
|
215
|
-
`Input ${d}: PegIn ${w} vout ${
|
|
215
|
+
`Input ${d}: PegIn ${w} vout ${x} carries ${$} sat, but the observed UTXO carries ${l.observed.value} sat. Reclaim refused.`
|
|
216
216
|
);
|
|
217
217
|
if ($ !== l.expectedValue)
|
|
218
218
|
throw new Error(
|
|
219
|
-
`Input ${d}: PegIn ${w} vout ${
|
|
219
|
+
`Input ${d}: PegIn ${w} vout ${x} carries ${$} sat, but this vault's parameters compute a depositor-claim value of ${l.expectedValue} sat. Reclaim refused.`
|
|
220
220
|
);
|
|
221
|
-
const h = `${w}:${
|
|
221
|
+
const h = `${w}:${x}`;
|
|
222
222
|
if (o.has(h))
|
|
223
223
|
throw new Error(
|
|
224
224
|
`Input ${d} repeats outpoint ${h}, which is already being swept by an earlier input. Reclaim refused.`
|
|
225
225
|
);
|
|
226
226
|
o.add(h), r += $, s.addInput({
|
|
227
227
|
hash: w,
|
|
228
|
-
index:
|
|
229
|
-
sequence:
|
|
228
|
+
index: x,
|
|
229
|
+
sequence: we,
|
|
230
230
|
witnessUtxo: { script: T.script, value: T.value },
|
|
231
231
|
tapLeafScript: [
|
|
232
232
|
{
|
|
@@ -242,28 +242,28 @@ function Ht(e) {
|
|
|
242
242
|
`Reclaim fee ${i} sat is not less than the swept total ${r} sat. Refusing to build a transaction with no output.`
|
|
243
243
|
);
|
|
244
244
|
const u = r - i;
|
|
245
|
-
if (u <=
|
|
245
|
+
if (u <= Y)
|
|
246
246
|
throw new Error(
|
|
247
|
-
`Reclaim output ${u} sat is at or below the dust threshold ${
|
|
247
|
+
`Reclaim output ${u} sat is at or below the dust threshold ${Y} sat. The reserve is not at risk — it stays where it is until fee rates fall.`
|
|
248
248
|
);
|
|
249
249
|
const p = g(
|
|
250
|
-
|
|
250
|
+
N(n)
|
|
251
251
|
);
|
|
252
252
|
return s.addOutput({
|
|
253
253
|
script: f.from(m(p)),
|
|
254
254
|
value: Number(u)
|
|
255
255
|
}), { psbtHex: s.toHex(), outputValue: u, totalInputValue: r };
|
|
256
256
|
}
|
|
257
|
-
function
|
|
258
|
-
const { requestedPsbtHex: n, signaturesHex:
|
|
257
|
+
function ke(t) {
|
|
258
|
+
const { requestedPsbtHex: n, signaturesHex: e, signerXOnlyPubkeyHex: i } = t, a = g(i);
|
|
259
259
|
if (a.length !== F)
|
|
260
260
|
throw new Error(
|
|
261
261
|
`Signer x-only pubkey must be ${F} hex chars (32 bytes), got ${a.length}.`
|
|
262
262
|
);
|
|
263
|
-
const c = f.from(m(a)), s =
|
|
264
|
-
if (
|
|
263
|
+
const c = f.from(m(a)), s = H.fromHex(n);
|
|
264
|
+
if (e.length !== s.data.inputs.length)
|
|
265
265
|
throw new Error(
|
|
266
|
-
`Cannot finalize: got ${
|
|
266
|
+
`Cannot finalize: got ${e.length} signature(s) for ${s.data.inputs.length} input(s). Every input must be signed — refusing to broadcast a partially signed transaction.`
|
|
267
267
|
);
|
|
268
268
|
return s.data.inputs.forEach((r, o) => {
|
|
269
269
|
if (r.tapKeySig)
|
|
@@ -280,7 +280,7 @@ function Nt(e) {
|
|
|
280
280
|
throw new Error(
|
|
281
281
|
`Cannot finalize: input ${o} tapLeafScript has leaf version 0x${p.leafVersion.toString(16)}, expected 0x${A.toString(16)}.`
|
|
282
282
|
);
|
|
283
|
-
const l = g(
|
|
283
|
+
const l = g(e[o]);
|
|
284
284
|
if (l.length !== B)
|
|
285
285
|
throw new Error(
|
|
286
286
|
`Signature for input ${o} must be ${B} hex chars (64 bytes), got ${l.length}.`
|
|
@@ -289,7 +289,7 @@ function Nt(e) {
|
|
|
289
289
|
tapScriptSig: [
|
|
290
290
|
{
|
|
291
291
|
pubkey: c,
|
|
292
|
-
leafHash:
|
|
292
|
+
leafHash: ie(p.leafVersion, p.script),
|
|
293
293
|
signature: f.from(m(l))
|
|
294
294
|
}
|
|
295
295
|
]
|
|
@@ -297,14 +297,14 @@ function Nt(e) {
|
|
|
297
297
|
}), s.finalizeAllInputs(), s.extractTransaction().toHex();
|
|
298
298
|
}
|
|
299
299
|
const W = 65535;
|
|
300
|
-
async function
|
|
301
|
-
const n = g(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
), c = m(i), s = m(a), r = new
|
|
305
|
-
r.setVersion(
|
|
306
|
-
for (let o = 0; o <
|
|
307
|
-
const u =
|
|
300
|
+
async function Ne(t) {
|
|
301
|
+
const n = g(t.noPayoutTxHex), e = b.fromHex(n), { noPayoutScript: i, noPayoutControlBlock: a } = await Z(
|
|
302
|
+
t.connectorParams,
|
|
303
|
+
t.challengerPubkey
|
|
304
|
+
), c = m(i), s = m(a), r = new H();
|
|
305
|
+
r.setVersion(e.version), r.setLocktime(e.locktime);
|
|
306
|
+
for (let o = 0; o < e.ins.length; o++) {
|
|
307
|
+
const u = e.ins[o], p = t.prevouts[o];
|
|
308
308
|
if (!p)
|
|
309
309
|
throw new Error(`Missing prevout data for input ${o}`);
|
|
310
310
|
const l = {
|
|
@@ -322,24 +322,24 @@ async function kt(e) {
|
|
|
322
322
|
script: f.from(c),
|
|
323
323
|
controlBlock: f.from(s)
|
|
324
324
|
}
|
|
325
|
-
], l.tapInternalKey = f.from(
|
|
325
|
+
], l.tapInternalKey = f.from(k)), r.addInput(l);
|
|
326
326
|
}
|
|
327
|
-
for (const o of
|
|
327
|
+
for (const o of e.outs)
|
|
328
328
|
r.addOutput({
|
|
329
329
|
script: o.script,
|
|
330
330
|
value: o.value
|
|
331
331
|
});
|
|
332
332
|
return r.toHex();
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
const i = b.fromHex(g(
|
|
334
|
+
function Le(t, n, e) {
|
|
335
|
+
const i = b.fromHex(g(t));
|
|
336
336
|
if (i.outs.length !== 1)
|
|
337
337
|
throw new Error(
|
|
338
338
|
`NoPayout transaction must have exactly 1 output, got ${i.outs.length}`
|
|
339
339
|
);
|
|
340
|
-
const a = m(
|
|
340
|
+
const a = m(te(n)), { output: c } = j.p2tr({
|
|
341
341
|
internalPubkey: f.from(a),
|
|
342
|
-
network:
|
|
342
|
+
network: oe(e)
|
|
343
343
|
});
|
|
344
344
|
if (!c)
|
|
345
345
|
throw new Error(
|
|
@@ -350,11 +350,11 @@ function Ot(e, n, t) {
|
|
|
350
350
|
"NoPayout transaction does not pay to the expected challenger BIP-86 P2TR address"
|
|
351
351
|
);
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
const { noPayoutTx: n, timelockChallengeAssert:
|
|
355
|
-
if (!Number.isInteger(
|
|
353
|
+
function Oe(t) {
|
|
354
|
+
const { noPayoutTx: n, timelockChallengeAssert: e } = t;
|
|
355
|
+
if (!Number.isInteger(e) || e < 1 || e > W)
|
|
356
356
|
throw new Error(
|
|
357
|
-
`timelockChallengeAssert must be an integer in 1..${W}, got ${
|
|
357
|
+
`timelockChallengeAssert must be an integer in 1..${W}, got ${e}`
|
|
358
358
|
);
|
|
359
359
|
if (n.version !== M)
|
|
360
360
|
throw new Error(
|
|
@@ -371,21 +371,21 @@ function Lt(e) {
|
|
|
371
371
|
[
|
|
372
372
|
{
|
|
373
373
|
label: "Assert",
|
|
374
|
-
txid:
|
|
375
|
-
vout:
|
|
376
|
-
sequence:
|
|
374
|
+
txid: t.assertTxid,
|
|
375
|
+
vout: ue,
|
|
376
|
+
sequence: ae
|
|
377
377
|
},
|
|
378
378
|
{
|
|
379
379
|
label: "ChallengeAssertX",
|
|
380
|
-
txid:
|
|
381
|
-
vout:
|
|
382
|
-
sequence:
|
|
380
|
+
txid: t.challengeAssertXTxid,
|
|
381
|
+
vout: z,
|
|
382
|
+
sequence: e
|
|
383
383
|
},
|
|
384
384
|
{
|
|
385
385
|
label: "ChallengeAssertY",
|
|
386
|
-
txid:
|
|
387
|
-
vout:
|
|
388
|
-
sequence:
|
|
386
|
+
txid: t.challengeAssertYTxid,
|
|
387
|
+
vout: z,
|
|
388
|
+
sequence: e
|
|
389
389
|
}
|
|
390
390
|
].forEach((s, r) => {
|
|
391
391
|
const o = n.ins[r], u = Q(o);
|
|
@@ -398,19 +398,19 @@ function Lt(e) {
|
|
|
398
398
|
`NoPayout input ${r} (${s.label}) sequence must be ${s.sequence}, got ${o.sequence}`
|
|
399
399
|
);
|
|
400
400
|
});
|
|
401
|
-
const a =
|
|
401
|
+
const a = t.prevoutValues.reduce((s, r) => s + r, 0), c = n.outs.reduce((s, r) => s + r.value, 0);
|
|
402
402
|
if (c > a)
|
|
403
403
|
throw new Error(
|
|
404
404
|
`NoPayout output value ${c} exceeds its inputs (${a} sats)`
|
|
405
405
|
);
|
|
406
406
|
}
|
|
407
|
-
async function
|
|
407
|
+
async function Ue(t) {
|
|
408
408
|
const n = b.fromHex(
|
|
409
|
-
g(
|
|
410
|
-
),
|
|
411
|
-
if (
|
|
409
|
+
g(t.challengeAssertTxHex)
|
|
410
|
+
), e = b.fromHex(g(t.assertTxHex)), i = e.getId();
|
|
411
|
+
if (t.connectorParamsPerInput.length !== n.ins.length)
|
|
412
412
|
throw new Error(
|
|
413
|
-
`Expected ${n.ins.length} connector params, got ${
|
|
413
|
+
`Expected ${n.ins.length} connector params, got ${t.connectorParamsPerInput.length}`
|
|
414
414
|
);
|
|
415
415
|
const a = /* @__PURE__ */ new Set();
|
|
416
416
|
for (let r = 0; r < n.ins.length; r++) {
|
|
@@ -419,7 +419,7 @@ async function Ut(e) {
|
|
|
419
419
|
throw new Error(
|
|
420
420
|
`ChallengeAssert input ${r} must spend an Assert output. Expected txid ${i}, got ${u}`
|
|
421
421
|
);
|
|
422
|
-
if (!
|
|
422
|
+
if (!e.outs[o.index])
|
|
423
423
|
throw new Error(
|
|
424
424
|
`Assert output ${o.index} not found for ChallengeAssert input ${r} (txid: ${i})`
|
|
425
425
|
);
|
|
@@ -430,11 +430,11 @@ async function Ut(e) {
|
|
|
430
430
|
a.add(o.index);
|
|
431
431
|
}
|
|
432
432
|
const c = await Promise.all(
|
|
433
|
-
|
|
434
|
-
), s = new
|
|
433
|
+
t.connectorParamsPerInput.map((r) => ee(r))
|
|
434
|
+
), s = new H();
|
|
435
435
|
s.setVersion(n.version), s.setLocktime(n.locktime);
|
|
436
436
|
for (let r = 0; r < n.ins.length; r++) {
|
|
437
|
-
const o = n.ins[r], u =
|
|
437
|
+
const o = n.ins[r], u = e.outs[o.index], { script: p, controlBlock: l } = c[r], d = m(p), E = m(l);
|
|
438
438
|
s.addInput({
|
|
439
439
|
hash: o.hash,
|
|
440
440
|
index: o.index,
|
|
@@ -447,10 +447,10 @@ async function Ut(e) {
|
|
|
447
447
|
{
|
|
448
448
|
leafVersion: A,
|
|
449
449
|
script: f.from(d),
|
|
450
|
-
controlBlock: f.from(
|
|
450
|
+
controlBlock: f.from(E)
|
|
451
451
|
}
|
|
452
452
|
],
|
|
453
|
-
tapInternalKey: f.from(
|
|
453
|
+
tapInternalKey: f.from(k)
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
456
|
for (const r of n.outs)
|
|
@@ -460,50 +460,50 @@ async function Ut(e) {
|
|
|
460
460
|
});
|
|
461
461
|
return s.toHex();
|
|
462
462
|
}
|
|
463
|
-
function
|
|
464
|
-
const n =
|
|
465
|
-
if (
|
|
463
|
+
function Ke(t) {
|
|
464
|
+
const n = Pe(t).getId(), e = t.challengeAssertTx.getId();
|
|
465
|
+
if (e !== n)
|
|
466
466
|
throw new Error(
|
|
467
|
-
`ChallengeAssert${
|
|
467
|
+
`ChallengeAssert${t.half} (challenger ${t.challengerPubkey}) is not the canonical transaction for this Assert: expected txid ${n}, got ${e}`
|
|
468
468
|
);
|
|
469
469
|
}
|
|
470
|
-
function
|
|
471
|
-
const { assertTx: n, half:
|
|
470
|
+
function Pe(t) {
|
|
471
|
+
const { assertTx: n, half: e, challengerIndex: i, challengerCount: a } = t;
|
|
472
472
|
if (!Number.isInteger(i) || i < 0 || i >= a)
|
|
473
473
|
throw new Error(
|
|
474
|
-
`ChallengeAssert${
|
|
474
|
+
`ChallengeAssert${e} challenger index ${i} is outside 0..${a - 1}`
|
|
475
475
|
);
|
|
476
|
-
const c =
|
|
476
|
+
const c = pe + (e === "Y" ? a : 0) + i, s = n.outs[c];
|
|
477
477
|
if (!s)
|
|
478
478
|
throw new Error(
|
|
479
|
-
`Assert has no output ${c} for the ChallengeAssert${
|
|
479
|
+
`Assert has no output ${c} for the ChallengeAssert${e} of challenger index ${i}`
|
|
480
480
|
);
|
|
481
|
-
const r = s.value -
|
|
481
|
+
const r = s.value - _;
|
|
482
482
|
if (r < 0)
|
|
483
483
|
throw new Error(
|
|
484
|
-
`Assert output ${c} (${s.value} sats) cannot fund the ${
|
|
484
|
+
`Assert output ${c} (${s.value} sats) cannot fund the ${_}-sat ChallengeAssert${e} anchor`
|
|
485
485
|
);
|
|
486
486
|
const o = new b();
|
|
487
|
-
return o.version =
|
|
488
|
-
f.from(m(
|
|
487
|
+
return o.version = ce, o.locktime = le, o.addInput(n.getHash(), c, he), o.addOutput(
|
|
488
|
+
f.from(m(t.outputConnectorScriptPubKey)),
|
|
489
489
|
r
|
|
490
490
|
), o.addOutput(
|
|
491
491
|
f.from(
|
|
492
|
-
m(
|
|
492
|
+
m(N(t.challengerPubkey))
|
|
493
493
|
),
|
|
494
|
-
|
|
494
|
+
_
|
|
495
495
|
), o;
|
|
496
496
|
}
|
|
497
497
|
export {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
498
|
+
_e as a,
|
|
499
|
+
Re as b,
|
|
500
|
+
Ne as c,
|
|
501
|
+
Ue as d,
|
|
502
|
+
He as e,
|
|
503
|
+
ke as f,
|
|
504
|
+
Le as g,
|
|
505
|
+
Ke as h,
|
|
506
|
+
Oe as i,
|
|
507
|
+
Ee as r
|
|
508
508
|
};
|
|
509
|
-
//# sourceMappingURL=challengeAssert-
|
|
509
|
+
//# sourceMappingURL=challengeAssert-pJP7MKhG.js.map
|