@babylonlabs-io/ts-sdk 0.16.1 → 0.17.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/README.md +17 -3
- package/dist/challengeAssert-D_k_ADgP.cjs +2 -0
- package/dist/challengeAssert-D_k_ADgP.cjs.map +1 -0
- package/dist/challengeAssert-k5_LWUtO.js +362 -0
- package/dist/challengeAssert-k5_LWUtO.js.map +1 -0
- package/dist/constants-EiyZkXce.cjs +2 -0
- package/dist/constants-EiyZkXce.cjs.map +1 -0
- package/dist/constants-Q7v2O7Ps.js +155 -0
- package/dist/constants-Q7v2O7Ps.js.map +1 -0
- package/dist/errors-DKLboMnq.cjs +2 -0
- package/dist/errors-DKLboMnq.cjs.map +1 -0
- package/dist/errors-KY63mgWT.js +1510 -0
- package/dist/errors-KY63mgWT.js.map +1 -0
- package/dist/fundPeginTransaction-DpwnDslW.js +50 -0
- package/dist/fundPeginTransaction-DpwnDslW.js.map +1 -0
- package/dist/fundPeginTransaction-EbrZzlrh.cjs +2 -0
- package/dist/fundPeginTransaction-EbrZzlrh.cjs.map +1 -0
- package/dist/index-D3z3SZAj.cjs +2 -0
- package/dist/index-D3z3SZAj.cjs.map +1 -0
- package/dist/index-Dw7FAwne.js +913 -0
- package/dist/index-Dw7FAwne.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +98 -74
- package/dist/index.js.map +1 -1
- package/dist/payout-Ce9vSs9e.js +164 -0
- package/dist/payout-Ce9vSs9e.js.map +1 -0
- package/dist/payout-CfsDnjKI.cjs +2 -0
- package/dist/payout-CfsDnjKI.cjs.map +1 -0
- package/dist/psbtInputFields-C0nKn_GD.cjs +2 -0
- package/dist/psbtInputFields-C0nKn_GD.cjs.map +1 -0
- package/dist/psbtInputFields-DO0ELwiv.js +116 -0
- package/dist/psbtInputFields-DO0ELwiv.js.map +1 -0
- package/dist/signAndSubmitPayouts-CAOEAQp9.js +490 -0
- package/dist/signAndSubmitPayouts-CAOEAQp9.js.map +1 -0
- package/dist/signAndSubmitPayouts-CSJmcPQN.cjs +2 -0
- package/dist/signAndSubmitPayouts-CSJmcPQN.cjs.map +1 -0
- package/dist/signing-Deg5lCoC.cjs +2 -0
- package/dist/signing-Deg5lCoC.cjs.map +1 -0
- package/dist/signing-Drwr3bXB.js +16 -0
- package/dist/signing-Drwr3bXB.js.map +1 -0
- package/dist/tbv/core/clients/eth/__tests__/vault-registry-reader.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/vault-registry-reader.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/index.d.ts +3 -0
- package/dist/tbv/core/clients/eth/index.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/types.d.ts +37 -0
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +20 -0
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -0
- package/dist/tbv/core/clients/index.cjs +2 -0
- package/dist/tbv/core/clients/index.cjs.map +1 -0
- package/dist/tbv/core/clients/index.d.ts +2 -0
- package/dist/tbv/core/clients/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.js +26 -0
- package/dist/tbv/core/clients/index.js.map +1 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/json-rpc-client.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/json-rpc-client.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/validators.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/validators.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/api.d.ts +53 -0
- package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/index.d.ts +7 -0
- package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +90 -0
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/types.d.ts +256 -0
- package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/validators.d.ts +30 -0
- package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +29 -74
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +1 -0
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +97 -73
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +8 -0
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +26 -24
- package/dist/tbv/core/primitives/index.js.map +1 -1
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +0 -11
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/__tests__/submitWotsPublicKey.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/submitWotsPublicKey.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/__tests__/waitForPeginStatus.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/waitForPeginStatus.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/index.d.ts +10 -0
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/interfaces.d.ts +21 -0
- package/dist/tbv/core/services/deposit/interfaces.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/signAndSubmitPayouts.d.ts +55 -0
- package/dist/tbv/core/services/deposit/signAndSubmitPayouts.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +21 -0
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/submitWotsPublicKey.d.ts +25 -0
- package/dist/tbv/core/services/deposit/submitWotsPublicKey.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts +24 -0
- package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts.map +1 -0
- package/dist/tbv/core/services/index.cjs +2 -0
- package/dist/tbv/core/services/index.cjs.map +1 -0
- package/dist/tbv/core/services/index.d.ts +10 -0
- package/dist/tbv/core/services/index.d.ts.map +1 -0
- package/dist/tbv/core/services/index.js +8 -0
- package/dist/tbv/core/services/index.js.map +1 -0
- package/dist/tbv/core/utils/index.cjs +2 -0
- package/dist/tbv/core/utils/index.cjs.map +1 -0
- package/dist/tbv/core/utils/index.js +30 -0
- package/dist/tbv/core/utils/index.js.map +1 -0
- package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +97 -73
- package/dist/tbv/index.js.map +1 -1
- package/dist/tbv/integrations/aave/clients/abis/AaveSpoke.abi.json.d.ts +28 -18
- package/dist/tbv/integrations/aave/clients/spoke.d.ts +2 -2
- package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/constants.d.ts +7 -0
- package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.d.ts +2 -2
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.js +124 -120
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/dist/tbv/integrations/aave/types.d.ts +4 -6
- package/dist/tbv/integrations/aave/types.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/utils/aaveConversions.d.ts +10 -1
- package/dist/tbv/integrations/aave/utils/aaveConversions.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/utils/debtUtils.d.ts +0 -1
- package/dist/tbv/integrations/aave/utils/debtUtils.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/utils/index.d.ts +1 -1
- package/dist/tbv/integrations/aave/utils/index.d.ts.map +1 -1
- package/dist/types-D1rYwwCu.js +235 -0
- package/dist/types-D1rYwwCu.js.map +1 -0
- package/dist/types-DEWiqXYp.cjs +2 -0
- package/dist/types-DEWiqXYp.cjs.map +1 -0
- package/package.json +13 -3
- package/dist/challengeAssert-C5DQSUnp.js +0 -708
- package/dist/challengeAssert-C5DQSUnp.js.map +0 -1
- package/dist/challengeAssert-D7SqsNpQ.cjs +0 -2
- package/dist/challengeAssert-D7SqsNpQ.cjs.map +0 -1
- package/dist/errors-Bk7eb5h3.cjs +0 -2
- package/dist/errors-Bk7eb5h3.cjs.map +0 -1
- package/dist/errors-Ld-2tiK3.js +0 -2268
- package/dist/errors-Ld-2tiK3.js.map +0 -1
|
@@ -1,708 +0,0 @@
|
|
|
1
|
-
import { createPrePeginTransaction as W, buildPeginTxFromPrePegin as F, getPrePeginHtlcConnectorInfo as _, tapInternalPubkey as m, initWasm as N, WasmPrePeginTx as q, createPayoutConnector as z, getPeginPayoutScriptInfo as M, getAssertNoPayoutScriptInfo as D, getChallengeAssertScriptInfo as X } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
2
|
-
import * as B from "bitcoinjs-lib";
|
|
3
|
-
import { payments as R, networks as I, initEccLib as G, Transaction as y, Psbt as w } from "bitcoinjs-lib";
|
|
4
|
-
import { Buffer as l } from "buffer";
|
|
5
|
-
import * as Q from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
6
|
-
const E = 192;
|
|
7
|
-
function g(t) {
|
|
8
|
-
return t.startsWith("0x") ? t.slice(2) : t;
|
|
9
|
-
}
|
|
10
|
-
function lt(t) {
|
|
11
|
-
return t.startsWith("0x") ? t : `0x${t}`;
|
|
12
|
-
}
|
|
13
|
-
function d(t) {
|
|
14
|
-
const e = g(t);
|
|
15
|
-
if (!A(e))
|
|
16
|
-
throw new Error(`Invalid hex string: ${t}`);
|
|
17
|
-
const n = new Uint8Array(e.length / 2);
|
|
18
|
-
for (let r = 0; r < e.length; r += 2)
|
|
19
|
-
n[r / 2] = parseInt(e.slice(r, r + 2), 16);
|
|
20
|
-
return n;
|
|
21
|
-
}
|
|
22
|
-
function v(t) {
|
|
23
|
-
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
24
|
-
}
|
|
25
|
-
function Y(t) {
|
|
26
|
-
return t.length === 32 ? t : t.slice(1, 33);
|
|
27
|
-
}
|
|
28
|
-
function A(t) {
|
|
29
|
-
return /^[0-9a-fA-F]*$/.test(t) && t.length % 2 === 0;
|
|
30
|
-
}
|
|
31
|
-
function C(t) {
|
|
32
|
-
const e = g(t);
|
|
33
|
-
if (!A(e))
|
|
34
|
-
throw new Error(`Invalid hex characters in public key: ${t}`);
|
|
35
|
-
if (e.length === 64)
|
|
36
|
-
return e;
|
|
37
|
-
if (e.length !== 66 && e.length !== 130)
|
|
38
|
-
throw new Error(
|
|
39
|
-
`Invalid public key length: ${e.length} (expected 64, 66, or 130 hex chars)`
|
|
40
|
-
);
|
|
41
|
-
const n = d(e);
|
|
42
|
-
return v(Y(n));
|
|
43
|
-
}
|
|
44
|
-
function pt(t) {
|
|
45
|
-
const e = g(t);
|
|
46
|
-
return A(e);
|
|
47
|
-
}
|
|
48
|
-
function ft(t, e) {
|
|
49
|
-
const n = C(t), r = e ?? n;
|
|
50
|
-
if (n.toLowerCase() !== r.toLowerCase())
|
|
51
|
-
throw new Error(
|
|
52
|
-
`Wallet public key does not match vault depositor. Expected: ${r}, Got: ${n}. Please connect the wallet that was used to create this vault.`
|
|
53
|
-
);
|
|
54
|
-
return { walletPubkeyRaw: t, walletPubkeyXOnly: n, depositorPubkey: r };
|
|
55
|
-
}
|
|
56
|
-
let L = !1;
|
|
57
|
-
function O() {
|
|
58
|
-
L || (G(Q), L = !0);
|
|
59
|
-
}
|
|
60
|
-
function V(t) {
|
|
61
|
-
switch (t) {
|
|
62
|
-
case "bitcoin":
|
|
63
|
-
return I.bitcoin;
|
|
64
|
-
case "testnet":
|
|
65
|
-
case "signet":
|
|
66
|
-
return I.testnet;
|
|
67
|
-
case "regtest":
|
|
68
|
-
return I.regtest;
|
|
69
|
-
default:
|
|
70
|
-
throw new Error(`Unknown network: ${t}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function Z(t, e) {
|
|
74
|
-
O();
|
|
75
|
-
const n = d(C(t)), { address: r } = R.p2tr({
|
|
76
|
-
internalPubkey: l.from(n),
|
|
77
|
-
network: V(e)
|
|
78
|
-
});
|
|
79
|
-
if (!r)
|
|
80
|
-
throw new Error("Failed to derive taproot address from public key");
|
|
81
|
-
return r;
|
|
82
|
-
}
|
|
83
|
-
function j(t, e) {
|
|
84
|
-
const n = g(t);
|
|
85
|
-
if (n.length !== 66)
|
|
86
|
-
throw new Error(
|
|
87
|
-
`Native SegWit requires a compressed public key (66 hex chars), got ${n.length}`
|
|
88
|
-
);
|
|
89
|
-
const { address: r } = R.p2wpkh({
|
|
90
|
-
pubkey: l.from(d(n)),
|
|
91
|
-
network: V(e)
|
|
92
|
-
});
|
|
93
|
-
if (!r)
|
|
94
|
-
throw new Error(
|
|
95
|
-
"Failed to derive native segwit address from public key"
|
|
96
|
-
);
|
|
97
|
-
return r;
|
|
98
|
-
}
|
|
99
|
-
function dt(t, e, n) {
|
|
100
|
-
const r = g(e);
|
|
101
|
-
try {
|
|
102
|
-
if (t === Z(r, n))
|
|
103
|
-
return !0;
|
|
104
|
-
} catch {
|
|
105
|
-
}
|
|
106
|
-
const o = [];
|
|
107
|
-
r.length === 66 ? o.push(r) : r.length === 64 && o.push(`02${r}`, `03${r}`);
|
|
108
|
-
for (const s of o)
|
|
109
|
-
try {
|
|
110
|
-
if (t === j(s, n))
|
|
111
|
-
return !0;
|
|
112
|
-
} catch {
|
|
113
|
-
}
|
|
114
|
-
return !1;
|
|
115
|
-
}
|
|
116
|
-
function H(t) {
|
|
117
|
-
return C(t).toLowerCase();
|
|
118
|
-
}
|
|
119
|
-
function ht(t, e, n) {
|
|
120
|
-
const r = /* @__PURE__ */ new Set();
|
|
121
|
-
r.add(H(t));
|
|
122
|
-
for (const o of e)
|
|
123
|
-
r.add(H(o));
|
|
124
|
-
return r.delete(H(n)), r.size;
|
|
125
|
-
}
|
|
126
|
-
const gt = 58, Pt = 43, xt = 11, J = 546, tt = BigInt(J), et = 30, nt = 2, yt = 1.1;
|
|
127
|
-
function kt(t) {
|
|
128
|
-
return t <= nt ? et : 0;
|
|
129
|
-
}
|
|
130
|
-
const rt = 1;
|
|
131
|
-
function vt(t) {
|
|
132
|
-
return t + rt;
|
|
133
|
-
}
|
|
134
|
-
const wt = 5;
|
|
135
|
-
function K(t) {
|
|
136
|
-
const n = t.substring(8, 12) === "0001" ? 12 : 8, r = parseInt(
|
|
137
|
-
t.substring(n, n + 2),
|
|
138
|
-
16
|
|
139
|
-
), o = parseInt(
|
|
140
|
-
t.substring(n + 2, n + 4),
|
|
141
|
-
16
|
|
142
|
-
);
|
|
143
|
-
if (r !== 0)
|
|
144
|
-
throw new Error(`Expected 0 inputs from WASM, got ${r}`);
|
|
145
|
-
if (o === 0)
|
|
146
|
-
throw new Error("Expected at least 1 output from WASM, got 0");
|
|
147
|
-
const s = l.from(t.substring(0, 8), "hex").readUInt32LE(0), c = l.from(
|
|
148
|
-
t.substring(t.length - 8),
|
|
149
|
-
"hex"
|
|
150
|
-
).readUInt32LE(0), u = [];
|
|
151
|
-
let i = n + 4;
|
|
152
|
-
for (let p = 0; p < o; p++) {
|
|
153
|
-
const a = t.substring(i, i + 16), f = Number(l.from(a, "hex").readBigUInt64LE(0));
|
|
154
|
-
i += 16;
|
|
155
|
-
const h = parseInt(t.substring(i, i + 2), 16);
|
|
156
|
-
i += 2;
|
|
157
|
-
const P = t.substring(i, i + h * 2), x = l.from(P, "hex");
|
|
158
|
-
i += h * 2, u.push({ value: f, script: x });
|
|
159
|
-
}
|
|
160
|
-
return { version: s, locktime: c, outputs: u };
|
|
161
|
-
}
|
|
162
|
-
function bt(t) {
|
|
163
|
-
O();
|
|
164
|
-
const { unfundedTxHex: e, selectedUTXOs: n, changeAddress: r, changeAmount: o, network: s } = t, { version: c, locktime: u, outputs: i } = K(e), p = new B.Transaction();
|
|
165
|
-
p.version = c, p.locktime = u;
|
|
166
|
-
for (const a of n) {
|
|
167
|
-
const f = l.from(a.txid, "hex").reverse();
|
|
168
|
-
p.addInput(f, a.vout);
|
|
169
|
-
}
|
|
170
|
-
for (const a of i)
|
|
171
|
-
p.addOutput(a.script, a.value);
|
|
172
|
-
if (o > tt) {
|
|
173
|
-
const a = B.address.toOutputScript(r, s);
|
|
174
|
-
p.addOutput(a, Number(o));
|
|
175
|
-
}
|
|
176
|
-
return p.toHex();
|
|
177
|
-
}
|
|
178
|
-
async function St(t) {
|
|
179
|
-
const e = await W({
|
|
180
|
-
depositorPubkey: t.depositorPubkey,
|
|
181
|
-
vaultProviderPubkey: t.vaultProviderPubkey,
|
|
182
|
-
vaultKeeperPubkeys: t.vaultKeeperPubkeys,
|
|
183
|
-
universalChallengerPubkeys: t.universalChallengerPubkeys,
|
|
184
|
-
hashlocks: [...t.hashlocks],
|
|
185
|
-
timelockRefund: t.timelockRefund,
|
|
186
|
-
pegInAmounts: [...t.pegInAmounts],
|
|
187
|
-
feeRate: t.feeRate,
|
|
188
|
-
numLocalChallengers: t.numLocalChallengers,
|
|
189
|
-
councilQuorum: t.councilQuorum,
|
|
190
|
-
councilSize: t.councilSize,
|
|
191
|
-
network: t.network
|
|
192
|
-
}), r = K(e.txHex).outputs.reduce(
|
|
193
|
-
(o, s) => o + BigInt(s.value),
|
|
194
|
-
0n
|
|
195
|
-
);
|
|
196
|
-
return {
|
|
197
|
-
psbtHex: e.txHex,
|
|
198
|
-
totalOutputValue: r,
|
|
199
|
-
htlcValues: e.htlcValues,
|
|
200
|
-
htlcScriptPubKeys: e.htlcScriptPubKeys,
|
|
201
|
-
htlcAddresses: e.htlcAddresses,
|
|
202
|
-
peginAmounts: e.peginAmounts,
|
|
203
|
-
depositorClaimValue: e.depositorClaimValue
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
async function mt(t) {
|
|
207
|
-
const e = await F(
|
|
208
|
-
{
|
|
209
|
-
depositorPubkey: t.prePeginParams.depositorPubkey,
|
|
210
|
-
vaultProviderPubkey: t.prePeginParams.vaultProviderPubkey,
|
|
211
|
-
vaultKeeperPubkeys: t.prePeginParams.vaultKeeperPubkeys,
|
|
212
|
-
universalChallengerPubkeys: t.prePeginParams.universalChallengerPubkeys,
|
|
213
|
-
hashlocks: [...t.prePeginParams.hashlocks],
|
|
214
|
-
timelockRefund: t.prePeginParams.timelockRefund,
|
|
215
|
-
pegInAmounts: [...t.prePeginParams.pegInAmounts],
|
|
216
|
-
feeRate: t.prePeginParams.feeRate,
|
|
217
|
-
numLocalChallengers: t.prePeginParams.numLocalChallengers,
|
|
218
|
-
councilQuorum: t.prePeginParams.councilQuorum,
|
|
219
|
-
councilSize: t.prePeginParams.councilSize,
|
|
220
|
-
network: t.prePeginParams.network
|
|
221
|
-
},
|
|
222
|
-
t.timelockPegin,
|
|
223
|
-
t.fundedPrePeginTxHex,
|
|
224
|
-
t.htlcVout
|
|
225
|
-
);
|
|
226
|
-
return {
|
|
227
|
-
txHex: e.txHex,
|
|
228
|
-
txid: e.txid,
|
|
229
|
-
vaultScriptPubKey: e.vaultScriptPubKey,
|
|
230
|
-
vaultValue: e.vaultValue
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
async function Et(t) {
|
|
234
|
-
const e = g(t.peginTxHex), n = g(t.fundedPrePeginTxHex), r = await _({
|
|
235
|
-
depositorPubkey: t.depositorPubkey,
|
|
236
|
-
vaultProviderPubkey: t.vaultProviderPubkey,
|
|
237
|
-
vaultKeeperPubkeys: t.vaultKeeperPubkeys,
|
|
238
|
-
universalChallengerPubkeys: t.universalChallengerPubkeys,
|
|
239
|
-
hashlock: t.hashlock,
|
|
240
|
-
timelockRefund: t.timelockRefund,
|
|
241
|
-
network: t.network
|
|
242
|
-
}), o = y.fromHex(e), s = y.fromHex(n);
|
|
243
|
-
if (o.ins.length !== 1)
|
|
244
|
-
throw new Error(
|
|
245
|
-
`PegIn transaction must have exactly 1 input, got ${o.ins.length}`
|
|
246
|
-
);
|
|
247
|
-
const c = o.ins[0], u = s.getId(), i = v(
|
|
248
|
-
new Uint8Array(c.hash).slice().reverse()
|
|
249
|
-
);
|
|
250
|
-
if (i !== u)
|
|
251
|
-
throw new Error(
|
|
252
|
-
`PegIn input does not reference the Pre-PegIn transaction. Expected ${u}, got ${i}`
|
|
253
|
-
);
|
|
254
|
-
const p = s.outs[c.index];
|
|
255
|
-
if (!p)
|
|
256
|
-
throw new Error(
|
|
257
|
-
`Pre-PegIn output ${c.index} not found (Pre-PegIn has ${s.outs.length} outputs)`
|
|
258
|
-
);
|
|
259
|
-
const a = d(r.hashlockScript), f = d(r.hashlockControlBlock), h = new w();
|
|
260
|
-
h.setVersion(o.version), h.setLocktime(o.locktime), h.addInput({
|
|
261
|
-
hash: c.hash,
|
|
262
|
-
index: c.index,
|
|
263
|
-
sequence: c.sequence,
|
|
264
|
-
witnessUtxo: {
|
|
265
|
-
script: p.script,
|
|
266
|
-
value: p.value
|
|
267
|
-
},
|
|
268
|
-
tapLeafScript: [
|
|
269
|
-
{
|
|
270
|
-
leafVersion: E,
|
|
271
|
-
script: l.from(a),
|
|
272
|
-
controlBlock: l.from(f)
|
|
273
|
-
}
|
|
274
|
-
],
|
|
275
|
-
tapInternalKey: l.from(m)
|
|
276
|
-
// sighashType omitted — defaults to SIGHASH_DEFAULT (0x00) for Taproot
|
|
277
|
-
});
|
|
278
|
-
for (const P of o.outs)
|
|
279
|
-
h.addOutput({
|
|
280
|
-
script: P.script,
|
|
281
|
-
value: P.value
|
|
282
|
-
});
|
|
283
|
-
return { psbtHex: h.toHex() };
|
|
284
|
-
}
|
|
285
|
-
function Tt(t, e) {
|
|
286
|
-
const r = w.fromHex(t).data.inputs[0];
|
|
287
|
-
if (!r)
|
|
288
|
-
throw new Error("PegIn PSBT has no inputs");
|
|
289
|
-
if (r.tapScriptSig && r.tapScriptSig.length > 0) {
|
|
290
|
-
const o = l.from(
|
|
291
|
-
d(e)
|
|
292
|
-
);
|
|
293
|
-
for (const s of r.tapScriptSig)
|
|
294
|
-
if (s.pubkey.equals(o))
|
|
295
|
-
return ot(s.signature);
|
|
296
|
-
throw new Error(
|
|
297
|
-
`No PegIn input signature found for depositor pubkey: ${e}`
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
throw r.finalScriptWitness && r.finalScriptWitness.length > 0 ? new Error(
|
|
301
|
-
"PegIn input PSBT is already finalized. Cannot reliably extract the depositor signature from the witness stack. Ensure the wallet returns a non-finalized PSBT with tapScriptSig entries."
|
|
302
|
-
) : new Error(
|
|
303
|
-
"No tapScriptSig or finalScriptWitness found in signed PegIn input PSBT"
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
function It(t) {
|
|
307
|
-
const e = w.fromHex(t);
|
|
308
|
-
try {
|
|
309
|
-
e.finalizeAllInputs();
|
|
310
|
-
} catch (n) {
|
|
311
|
-
if (!e.data.inputs.every(
|
|
312
|
-
(o) => o.finalScriptWitness || o.finalScriptSig
|
|
313
|
-
))
|
|
314
|
-
throw new Error(
|
|
315
|
-
`PSBT finalization failed and wallet did not auto-finalize: ${n}`
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
return e.extractTransaction().toHex();
|
|
319
|
-
}
|
|
320
|
-
function ot(t) {
|
|
321
|
-
if (t.length === 64)
|
|
322
|
-
return v(new Uint8Array(t));
|
|
323
|
-
if (t.length === 65)
|
|
324
|
-
return v(new Uint8Array(t.subarray(0, 64)));
|
|
325
|
-
throw new Error(`Unexpected PegIn input signature length: ${t.length}`);
|
|
326
|
-
}
|
|
327
|
-
async function Ht(t) {
|
|
328
|
-
await N();
|
|
329
|
-
const { prePeginParams: e, fundedPrePeginTxHex: n, htlcVout: r, refundFee: o, hashlock: s } = t, c = new q(
|
|
330
|
-
e.depositorPubkey,
|
|
331
|
-
e.vaultProviderPubkey,
|
|
332
|
-
e.vaultKeeperPubkeys,
|
|
333
|
-
e.universalChallengerPubkeys,
|
|
334
|
-
[...e.hashlocks],
|
|
335
|
-
new BigUint64Array(e.pegInAmounts),
|
|
336
|
-
e.timelockRefund,
|
|
337
|
-
e.feeRate,
|
|
338
|
-
e.numLocalChallengers,
|
|
339
|
-
e.councilQuorum,
|
|
340
|
-
e.councilSize,
|
|
341
|
-
e.network
|
|
342
|
-
);
|
|
343
|
-
let u = null;
|
|
344
|
-
try {
|
|
345
|
-
u = c.fromFundedTransaction(n);
|
|
346
|
-
const i = u.buildRefundTx(o, r), p = await _({
|
|
347
|
-
depositorPubkey: e.depositorPubkey,
|
|
348
|
-
vaultProviderPubkey: e.vaultProviderPubkey,
|
|
349
|
-
vaultKeeperPubkeys: e.vaultKeeperPubkeys,
|
|
350
|
-
universalChallengerPubkeys: e.universalChallengerPubkeys,
|
|
351
|
-
hashlock: s,
|
|
352
|
-
timelockRefund: e.timelockRefund,
|
|
353
|
-
network: e.network
|
|
354
|
-
}), a = n.startsWith("0x") ? n.slice(2) : n, f = y.fromHex(a), h = f.outs[r];
|
|
355
|
-
if (!h)
|
|
356
|
-
throw new Error(
|
|
357
|
-
`HTLC output at vout ${r} not found in funded Pre-PegIn tx (tx has ${f.outs.length} outputs)`
|
|
358
|
-
);
|
|
359
|
-
const P = y.fromHex(i);
|
|
360
|
-
if (P.ins.length !== 1)
|
|
361
|
-
throw new Error(
|
|
362
|
-
`Refund transaction must have exactly 1 input, got ${P.ins.length}`
|
|
363
|
-
);
|
|
364
|
-
const x = P.ins[0], b = f.getId(), T = v(
|
|
365
|
-
new Uint8Array(x.hash).slice().reverse()
|
|
366
|
-
);
|
|
367
|
-
if (T !== b)
|
|
368
|
-
throw new Error(
|
|
369
|
-
`Refund input does not reference the Pre-PegIn transaction. Expected ${b}, got ${T}`
|
|
370
|
-
);
|
|
371
|
-
if (x.index !== r)
|
|
372
|
-
throw new Error(
|
|
373
|
-
`Refund input index ${x.index} does not match expected htlcVout ${r}`
|
|
374
|
-
);
|
|
375
|
-
const k = new w();
|
|
376
|
-
k.setVersion(P.version), k.setLocktime(P.locktime), k.addInput({
|
|
377
|
-
hash: x.hash,
|
|
378
|
-
index: x.index,
|
|
379
|
-
sequence: x.sequence,
|
|
380
|
-
witnessUtxo: {
|
|
381
|
-
script: h.script,
|
|
382
|
-
value: h.value
|
|
383
|
-
},
|
|
384
|
-
tapLeafScript: [
|
|
385
|
-
{
|
|
386
|
-
leafVersion: E,
|
|
387
|
-
script: l.from(d(p.refundScript)),
|
|
388
|
-
controlBlock: l.from(
|
|
389
|
-
d(p.refundControlBlock)
|
|
390
|
-
)
|
|
391
|
-
}
|
|
392
|
-
],
|
|
393
|
-
tapInternalKey: l.from(m)
|
|
394
|
-
});
|
|
395
|
-
for (const S of P.outs)
|
|
396
|
-
k.addOutput({
|
|
397
|
-
script: S.script,
|
|
398
|
-
value: S.value
|
|
399
|
-
});
|
|
400
|
-
return { psbtHex: k.toHex() };
|
|
401
|
-
} finally {
|
|
402
|
-
u == null || u.free(), c.free();
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
async function st(t) {
|
|
406
|
-
const e = await z(
|
|
407
|
-
{
|
|
408
|
-
depositor: t.depositor,
|
|
409
|
-
vaultProvider: t.vaultProvider,
|
|
410
|
-
vaultKeepers: t.vaultKeepers,
|
|
411
|
-
universalChallengers: t.universalChallengers,
|
|
412
|
-
timelockPegin: t.timelockPegin
|
|
413
|
-
},
|
|
414
|
-
t.network
|
|
415
|
-
);
|
|
416
|
-
return {
|
|
417
|
-
payoutScript: e.payoutScript,
|
|
418
|
-
taprootScriptHash: e.taprootScriptHash,
|
|
419
|
-
scriptPubKey: e.scriptPubKey,
|
|
420
|
-
address: e.address,
|
|
421
|
-
payoutControlBlock: e.payoutControlBlock
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
async function At(t) {
|
|
425
|
-
const e = g(t.payoutTxHex), n = g(t.peginTxHex), r = g(t.assertTxHex), o = await st({
|
|
426
|
-
depositor: t.depositorBtcPubkey,
|
|
427
|
-
vaultProvider: t.vaultProviderBtcPubkey,
|
|
428
|
-
vaultKeepers: t.vaultKeeperBtcPubkeys,
|
|
429
|
-
universalChallengers: t.universalChallengerBtcPubkeys,
|
|
430
|
-
timelockPegin: t.timelockPegin,
|
|
431
|
-
network: t.network
|
|
432
|
-
}), s = d(o.payoutScript), c = d(o.payoutControlBlock), u = y.fromHex(e), i = y.fromHex(n), p = y.fromHex(r), a = new w();
|
|
433
|
-
if (a.setVersion(u.version), a.setLocktime(u.locktime), u.ins.length !== 2)
|
|
434
|
-
throw new Error(
|
|
435
|
-
`Payout transaction must have exactly 2 inputs, got ${u.ins.length}`
|
|
436
|
-
);
|
|
437
|
-
const f = u.ins[0], h = u.ins[1], P = v(
|
|
438
|
-
new Uint8Array(f.hash).slice().reverse()
|
|
439
|
-
), x = i.getId();
|
|
440
|
-
if (P !== x)
|
|
441
|
-
throw new Error(
|
|
442
|
-
`Input 0 does not reference pegin transaction. Expected ${x}, got ${P}`
|
|
443
|
-
);
|
|
444
|
-
const b = v(
|
|
445
|
-
new Uint8Array(h.hash).slice().reverse()
|
|
446
|
-
), T = p.getId();
|
|
447
|
-
if (b !== T)
|
|
448
|
-
throw new Error(
|
|
449
|
-
`Input 1 does not reference assert transaction. Expected ${T}, got ${b}`
|
|
450
|
-
);
|
|
451
|
-
const k = i.outs[f.index];
|
|
452
|
-
if (!k)
|
|
453
|
-
throw new Error(
|
|
454
|
-
`Previous output not found for input 0 (txid: ${P}, index: ${f.index})`
|
|
455
|
-
);
|
|
456
|
-
const S = p.outs[h.index];
|
|
457
|
-
if (!S)
|
|
458
|
-
throw new Error(
|
|
459
|
-
`Previous output not found for input 1 (txid: ${b}, index: ${h.index})`
|
|
460
|
-
);
|
|
461
|
-
a.addInput({
|
|
462
|
-
hash: f.hash,
|
|
463
|
-
index: f.index,
|
|
464
|
-
sequence: f.sequence,
|
|
465
|
-
witnessUtxo: {
|
|
466
|
-
script: k.script,
|
|
467
|
-
value: k.value
|
|
468
|
-
},
|
|
469
|
-
tapLeafScript: [
|
|
470
|
-
{
|
|
471
|
-
leafVersion: E,
|
|
472
|
-
script: l.from(s),
|
|
473
|
-
controlBlock: l.from(c)
|
|
474
|
-
}
|
|
475
|
-
],
|
|
476
|
-
tapInternalKey: l.from(m)
|
|
477
|
-
// sighashType omitted - defaults to SIGHASH_DEFAULT (0x00) for Taproot
|
|
478
|
-
}), a.addInput({
|
|
479
|
-
hash: h.hash,
|
|
480
|
-
index: h.index,
|
|
481
|
-
sequence: h.sequence,
|
|
482
|
-
witnessUtxo: {
|
|
483
|
-
script: S.script,
|
|
484
|
-
value: S.value
|
|
485
|
-
}
|
|
486
|
-
// No tapLeafScript - depositor doesn't sign this input
|
|
487
|
-
});
|
|
488
|
-
for (const $ of u.outs)
|
|
489
|
-
a.addOutput({
|
|
490
|
-
script: $.script,
|
|
491
|
-
value: $.value
|
|
492
|
-
});
|
|
493
|
-
return {
|
|
494
|
-
psbtHex: a.toHex()
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
function Ct(t, e, n = 0) {
|
|
498
|
-
const r = w.fromHex(t);
|
|
499
|
-
if (n >= r.data.inputs.length)
|
|
500
|
-
throw new Error(
|
|
501
|
-
`Input index ${n} out of range (${r.data.inputs.length} inputs)`
|
|
502
|
-
);
|
|
503
|
-
const o = r.data.inputs[n];
|
|
504
|
-
if (o.tapScriptSig && o.tapScriptSig.length > 0) {
|
|
505
|
-
const s = d(e);
|
|
506
|
-
for (const c of o.tapScriptSig)
|
|
507
|
-
if (c.pubkey.equals(l.from(s)))
|
|
508
|
-
return U(c.signature, n);
|
|
509
|
-
throw new Error(
|
|
510
|
-
`No signature found for depositor pubkey: ${e} at input ${n}`
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
if (o.finalScriptWitness && o.finalScriptWitness.length > 0) {
|
|
514
|
-
const s = it(o.finalScriptWitness);
|
|
515
|
-
if (s.length >= 1)
|
|
516
|
-
return U(s[0], n);
|
|
517
|
-
}
|
|
518
|
-
throw new Error(
|
|
519
|
-
`No tapScriptSig or finalScriptWitness found in signed PSBT at input ${n}`
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
|
-
function U(t, e) {
|
|
523
|
-
if (t.length === 64)
|
|
524
|
-
return v(new Uint8Array(t));
|
|
525
|
-
if (t.length === 65) {
|
|
526
|
-
const n = t[64];
|
|
527
|
-
if (n !== y.SIGHASH_ALL)
|
|
528
|
-
throw new Error(
|
|
529
|
-
`Unexpected sighash type 0x${n.toString(16).padStart(2, "0")} at input ${e}. Expected SIGHASH_ALL (0x01).`
|
|
530
|
-
);
|
|
531
|
-
return v(new Uint8Array(t.subarray(0, 64)));
|
|
532
|
-
}
|
|
533
|
-
throw new Error(
|
|
534
|
-
`Unexpected signature length at input ${e}: ${t.length}`
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
function it(t) {
|
|
538
|
-
const e = [];
|
|
539
|
-
let n = 0;
|
|
540
|
-
const r = () => {
|
|
541
|
-
const s = t[n++];
|
|
542
|
-
if (s < 253) return s;
|
|
543
|
-
if (s === 253) {
|
|
544
|
-
const c = t[n] | t[n + 1] << 8;
|
|
545
|
-
return n += 2, c;
|
|
546
|
-
}
|
|
547
|
-
if (s === 254) {
|
|
548
|
-
const c = t[n] | t[n + 1] << 8 | t[n + 2] << 16 | t[n + 3] << 24;
|
|
549
|
-
return n += 4, c;
|
|
550
|
-
}
|
|
551
|
-
return n += 8, 0;
|
|
552
|
-
}, o = r();
|
|
553
|
-
for (let s = 0; s < o; s++) {
|
|
554
|
-
const c = r();
|
|
555
|
-
e.push(t.subarray(n, n + c)), n += c;
|
|
556
|
-
}
|
|
557
|
-
return e;
|
|
558
|
-
}
|
|
559
|
-
async function $t(t) {
|
|
560
|
-
const e = g(t.payoutTxHex), n = y.fromHex(e), { payoutScript: r, payoutControlBlock: o } = await M(
|
|
561
|
-
t.connectorParams
|
|
562
|
-
), s = d(r), c = d(o), u = new w();
|
|
563
|
-
u.setVersion(n.version), u.setLocktime(n.locktime);
|
|
564
|
-
for (let i = 0; i < n.ins.length; i++) {
|
|
565
|
-
const p = n.ins[i], a = t.prevouts[i];
|
|
566
|
-
if (!a)
|
|
567
|
-
throw new Error(`Missing prevout data for input ${i}`);
|
|
568
|
-
const f = {
|
|
569
|
-
hash: p.hash,
|
|
570
|
-
index: p.index,
|
|
571
|
-
sequence: p.sequence,
|
|
572
|
-
witnessUtxo: {
|
|
573
|
-
script: l.from(d(g(a.script_pubkey))),
|
|
574
|
-
value: a.value
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
i === 0 && (f.tapLeafScript = [
|
|
578
|
-
{
|
|
579
|
-
leafVersion: E,
|
|
580
|
-
script: l.from(s),
|
|
581
|
-
controlBlock: l.from(c)
|
|
582
|
-
}
|
|
583
|
-
], f.tapInternalKey = l.from(m)), u.addInput(f);
|
|
584
|
-
}
|
|
585
|
-
for (const i of n.outs)
|
|
586
|
-
u.addOutput({
|
|
587
|
-
script: i.script,
|
|
588
|
-
value: i.value
|
|
589
|
-
});
|
|
590
|
-
return u.toHex();
|
|
591
|
-
}
|
|
592
|
-
async function Bt(t) {
|
|
593
|
-
const e = g(t.noPayoutTxHex), n = y.fromHex(e), { noPayoutScript: r, noPayoutControlBlock: o } = await D(
|
|
594
|
-
t.connectorParams,
|
|
595
|
-
t.challengerPubkey
|
|
596
|
-
), s = d(r), c = d(o), u = new w();
|
|
597
|
-
u.setVersion(n.version), u.setLocktime(n.locktime);
|
|
598
|
-
for (let i = 0; i < n.ins.length; i++) {
|
|
599
|
-
const p = n.ins[i], a = t.prevouts[i];
|
|
600
|
-
if (!a)
|
|
601
|
-
throw new Error(`Missing prevout data for input ${i}`);
|
|
602
|
-
const f = {
|
|
603
|
-
hash: p.hash,
|
|
604
|
-
index: p.index,
|
|
605
|
-
sequence: p.sequence,
|
|
606
|
-
witnessUtxo: {
|
|
607
|
-
script: l.from(d(g(a.script_pubkey))),
|
|
608
|
-
value: a.value
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
i === 0 && (f.tapLeafScript = [
|
|
612
|
-
{
|
|
613
|
-
leafVersion: E,
|
|
614
|
-
script: l.from(s),
|
|
615
|
-
controlBlock: l.from(c)
|
|
616
|
-
}
|
|
617
|
-
], f.tapInternalKey = l.from(m)), u.addInput(f);
|
|
618
|
-
}
|
|
619
|
-
for (const i of n.outs)
|
|
620
|
-
u.addOutput({
|
|
621
|
-
script: i.script,
|
|
622
|
-
value: i.value
|
|
623
|
-
});
|
|
624
|
-
return u.toHex();
|
|
625
|
-
}
|
|
626
|
-
async function Lt(t) {
|
|
627
|
-
const e = g(t.challengeAssertTxHex), n = y.fromHex(e);
|
|
628
|
-
if (t.connectorParamsPerInput.length !== n.ins.length)
|
|
629
|
-
throw new Error(
|
|
630
|
-
`Expected ${n.ins.length} connector params, got ${t.connectorParamsPerInput.length}`
|
|
631
|
-
);
|
|
632
|
-
const r = await Promise.all(
|
|
633
|
-
t.connectorParamsPerInput.map((s) => X(s))
|
|
634
|
-
), o = new w();
|
|
635
|
-
o.setVersion(n.version), o.setLocktime(n.locktime);
|
|
636
|
-
for (let s = 0; s < n.ins.length; s++) {
|
|
637
|
-
const c = n.ins[s], u = t.prevouts[s];
|
|
638
|
-
if (!u)
|
|
639
|
-
throw new Error(`Missing prevout data for input ${s}`);
|
|
640
|
-
const { script: i, controlBlock: p } = r[s], a = d(i), f = d(p);
|
|
641
|
-
o.addInput({
|
|
642
|
-
hash: c.hash,
|
|
643
|
-
index: c.index,
|
|
644
|
-
sequence: c.sequence,
|
|
645
|
-
witnessUtxo: {
|
|
646
|
-
script: l.from(d(g(u.script_pubkey))),
|
|
647
|
-
value: u.value
|
|
648
|
-
},
|
|
649
|
-
tapLeafScript: [
|
|
650
|
-
{
|
|
651
|
-
leafVersion: E,
|
|
652
|
-
script: l.from(a),
|
|
653
|
-
controlBlock: l.from(f)
|
|
654
|
-
}
|
|
655
|
-
],
|
|
656
|
-
tapInternalKey: l.from(m)
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
for (const s of n.outs)
|
|
660
|
-
o.addOutput({
|
|
661
|
-
script: s.script,
|
|
662
|
-
value: s.value
|
|
663
|
-
});
|
|
664
|
-
return o.toHex();
|
|
665
|
-
}
|
|
666
|
-
export {
|
|
667
|
-
vt as A,
|
|
668
|
-
J as B,
|
|
669
|
-
K as C,
|
|
670
|
-
tt as D,
|
|
671
|
-
bt as E,
|
|
672
|
-
yt as F,
|
|
673
|
-
V as G,
|
|
674
|
-
O as H,
|
|
675
|
-
et as L,
|
|
676
|
-
Pt as M,
|
|
677
|
-
gt as P,
|
|
678
|
-
wt as S,
|
|
679
|
-
xt as T,
|
|
680
|
-
nt as W,
|
|
681
|
-
mt as a,
|
|
682
|
-
St as b,
|
|
683
|
-
ht as c,
|
|
684
|
-
Et as d,
|
|
685
|
-
Tt as e,
|
|
686
|
-
It as f,
|
|
687
|
-
Ht as g,
|
|
688
|
-
At as h,
|
|
689
|
-
Ct as i,
|
|
690
|
-
$t as j,
|
|
691
|
-
Bt as k,
|
|
692
|
-
Lt as l,
|
|
693
|
-
st as m,
|
|
694
|
-
j as n,
|
|
695
|
-
Z as o,
|
|
696
|
-
d as p,
|
|
697
|
-
dt as q,
|
|
698
|
-
pt as r,
|
|
699
|
-
lt as s,
|
|
700
|
-
C as t,
|
|
701
|
-
g as u,
|
|
702
|
-
Y as v,
|
|
703
|
-
v as w,
|
|
704
|
-
ft as x,
|
|
705
|
-
kt as y,
|
|
706
|
-
rt as z
|
|
707
|
-
};
|
|
708
|
-
//# sourceMappingURL=challengeAssert-C5DQSUnp.js.map
|