@lendasat/lendaswap-sdk-pure 0.2.41 → 0.2.43
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/_esm-6K2AP5GG.js +3663 -0
- package/dist/_esm-6K2AP5GG.js.map +1 -0
- package/dist/_esm-UGRDSVEV.cjs +3662 -0
- package/dist/_esm-UGRDSVEV.cjs.map +1 -0
- package/dist/api/client.d.ts +0 -4
- package/dist/api/client.d.ts.map +1 -1
- package/dist/base-2KYNAFR3.cjs +109 -0
- package/dist/base-2KYNAFR3.cjs.map +1 -0
- package/dist/base-HMHH3XPM.js +9 -0
- package/dist/base-HMHH3XPM.js.map +1 -0
- package/dist/ccip-EBXWV2U3.js +8 -0
- package/dist/ccip-EBXWV2U3.js.map +1 -0
- package/dist/ccip-PD37NJHA.cjs +26 -0
- package/dist/ccip-PD37NJHA.cjs.map +1 -0
- package/dist/cctp-bridge/index.cjs +67 -0
- package/dist/cctp-bridge/index.cjs.map +1 -0
- package/dist/cctp-bridge/index.js +53 -15
- package/dist/cctp-bridge/index.js.map +1 -1
- package/dist/cctp-inbound/client.d.ts +21 -19
- package/dist/cctp-inbound/client.d.ts.map +1 -1
- package/dist/cctp-inbound/smartAccount.d.ts +21 -19
- package/dist/cctp-inbound/smartAccount.d.ts.map +1 -1
- package/dist/chunk-4JXN4UPB.js +554 -0
- package/dist/chunk-4JXN4UPB.js.map +1 -0
- package/dist/chunk-A4GKKURK.cjs +430 -0
- package/dist/chunk-A4GKKURK.cjs.map +1 -0
- package/dist/chunk-BZU3R5DJ.cjs +554 -0
- package/dist/chunk-BZU3R5DJ.cjs.map +1 -0
- package/dist/chunk-DBBCKPZ5.js +421 -0
- package/dist/chunk-DBBCKPZ5.js.map +1 -0
- package/dist/chunk-DNSJDKTP.cjs +96 -0
- package/dist/chunk-DNSJDKTP.cjs.map +1 -0
- package/dist/chunk-EIK6BZWG.js +90 -0
- package/dist/chunk-EIK6BZWG.js.map +1 -0
- package/dist/chunk-GVAPVS4Z.js +6144 -0
- package/dist/chunk-GVAPVS4Z.js.map +1 -0
- package/dist/chunk-I7TGLGN6.js +46 -0
- package/dist/chunk-I7TGLGN6.js.map +1 -0
- package/dist/chunk-JBVKWKD4.cjs +50 -0
- package/dist/chunk-JBVKWKD4.cjs.map +1 -0
- package/dist/chunk-LA3YX2HD.js +47096 -0
- package/dist/chunk-LA3YX2HD.js.map +1 -0
- package/dist/chunk-PKDJZJMV.cjs +2214 -0
- package/dist/chunk-PKDJZJMV.cjs.map +1 -0
- package/dist/chunk-PRN5VZOM.js +370 -0
- package/dist/chunk-PRN5VZOM.js.map +1 -0
- package/dist/chunk-RIOT5VOJ.cjs +47240 -0
- package/dist/chunk-RIOT5VOJ.cjs.map +1 -0
- package/dist/chunk-WVZSHRV7.cjs +431 -0
- package/dist/chunk-WVZSHRV7.cjs.map +1 -0
- package/dist/chunk-YLWPBHMV.cjs +6311 -0
- package/dist/chunk-YLWPBHMV.cjs.map +1 -0
- package/dist/chunk-Z2FCTNRC.js +2210 -0
- package/dist/chunk-Z2FCTNRC.js.map +1 -0
- package/dist/client.d.ts +68 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/compose-quote.d.ts +77 -0
- package/dist/compose-quote.d.ts.map +1 -0
- package/dist/delegate.cjs +23 -0
- package/dist/delegate.cjs.map +1 -0
- package/dist/delegate.js +8 -269
- package/dist/delegate.js.map +1 -1
- package/dist/dist-PWXNFVDF.js +8 -0
- package/dist/dist-PWXNFVDF.js.map +1 -0
- package/dist/dist-VEHYC67F.cjs +550 -0
- package/dist/dist-VEHYC67F.cjs.map +1 -0
- package/dist/esplora.d.ts +14 -0
- package/dist/esplora.d.ts.map +1 -1
- package/dist/generated/api.d.ts +235 -38
- package/dist/generated/api.d.ts.map +1 -1
- package/dist/index.cjs +35461 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35312 -32
- package/dist/index.js.map +1 -1
- package/dist/mine.wasm-LUTPOAD2.js +12 -0
- package/dist/mine.wasm-LUTPOAD2.js.map +1 -0
- package/dist/mine.wasm-Z3ORSBKN.cjs +12 -0
- package/dist/mine.wasm-Z3ORSBKN.cjs.map +1 -0
- package/dist/node.cjs +166 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.js +159 -18
- package/dist/node.js.map +1 -1
- package/dist/secp256k1-B6OW5ZCM.js +8 -0
- package/dist/secp256k1-B6OW5ZCM.js.map +1 -0
- package/dist/secp256k1-PJCSE4N6.cjs +30 -0
- package/dist/secp256k1-PJCSE4N6.cjs.map +1 -0
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/types/chain-config.d.ts +50 -0
- package/dist/types/chain-config.d.ts.map +1 -0
- package/dist/types/chain.d.ts +11 -0
- package/dist/types/chain.d.ts.map +1 -0
- package/dist/types/dex-quote.d.ts +85 -0
- package/dist/types/dex-quote.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/network-fees.d.ts +43 -0
- package/dist/types/network-fees.d.ts.map +1 -0
- package/dist/types/quote.d.ts +87 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/swap-pairs.d.ts +37 -0
- package/dist/types/swap-pairs.d.ts.map +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/wallet-4YGTKWNZ.js +7 -0
- package/dist/wallet-4YGTKWNZ.js.map +1 -0
- package/dist/wallet-SZJDXAY7.cjs +45 -0
- package/dist/wallet-SZJDXAY7.cjs.map +1 -0
- package/package.json +23 -10
- package/dist/api/client.js +0 -13
- package/dist/api/client.js.map +0 -1
- package/dist/arkade-network.js +0 -40
- package/dist/arkade-network.js.map +0 -1
- package/dist/arkade.js +0 -61
- package/dist/arkade.js.map +0 -1
- package/dist/cctp/attestation.js +0 -149
- package/dist/cctp/attestation.js.map +0 -1
- package/dist/cctp/constants.js +0 -92
- package/dist/cctp/constants.js.map +0 -1
- package/dist/cctp/fee.js +0 -70
- package/dist/cctp/fee.js.map +0 -1
- package/dist/cctp/index.js +0 -13
- package/dist/cctp/index.js.map +0 -1
- package/dist/cctp/types.js +0 -5
- package/dist/cctp/types.js.map +0 -1
- package/dist/cctp/utils.js +0 -91
- package/dist/cctp/utils.js.map +0 -1
- package/dist/cctp-bridge/bridge.js +0 -74
- package/dist/cctp-bridge/bridge.js.map +0 -1
- package/dist/cctp-inbound/approveAndBurn.js +0 -95
- package/dist/cctp-inbound/approveAndBurn.js.map +0 -1
- package/dist/cctp-inbound/burn.js +0 -66
- package/dist/cctp-inbound/burn.js.map +0 -1
- package/dist/cctp-inbound/chainMap.js +0 -128
- package/dist/cctp-inbound/chainMap.js.map +0 -1
- package/dist/cctp-inbound/client.js +0 -125
- package/dist/cctp-inbound/client.js.map +0 -1
- package/dist/cctp-inbound/eip2612.js +0 -95
- package/dist/cctp-inbound/eip2612.js.map +0 -1
- package/dist/cctp-inbound/evmSignerAdapter.js +0 -82
- package/dist/cctp-inbound/evmSignerAdapter.js.map +0 -1
- package/dist/cctp-inbound/fundSwap.js +0 -95
- package/dist/cctp-inbound/fundSwap.js.map +0 -1
- package/dist/cctp-inbound/index.js +0 -34
- package/dist/cctp-inbound/index.js.map +0 -1
- package/dist/cctp-inbound/permit2.js +0 -32
- package/dist/cctp-inbound/permit2.js.map +0 -1
- package/dist/cctp-inbound/preflight.js +0 -84
- package/dist/cctp-inbound/preflight.js.map +0 -1
- package/dist/cctp-inbound/recover.js +0 -177
- package/dist/cctp-inbound/recover.js.map +0 -1
- package/dist/cctp-inbound/smartAccount.js +0 -117
- package/dist/cctp-inbound/smartAccount.js.map +0 -1
- package/dist/cctp-inbound/submit.js +0 -136
- package/dist/cctp-inbound/submit.js.map +0 -1
- package/dist/cctp-inbound/types.js +0 -5
- package/dist/cctp-inbound/types.js.map +0 -1
- package/dist/cctp-inbound/userOp.js +0 -151
- package/dist/cctp-inbound/userOp.js.map +0 -1
- package/dist/client.js +0 -4126
- package/dist/client.js.map +0 -1
- package/dist/create/arkade-to-lightning.js +0 -76
- package/dist/create/arkade-to-lightning.js.map +0 -1
- package/dist/create/arkade.js +0 -86
- package/dist/create/arkade.js.map +0 -1
- package/dist/create/bitcoin-to-arkade.js +0 -76
- package/dist/create/bitcoin-to-arkade.js.map +0 -1
- package/dist/create/bitcoin.js +0 -77
- package/dist/create/bitcoin.js.map +0 -1
- package/dist/create/evm-to-arkade.js +0 -80
- package/dist/create/evm-to-arkade.js.map +0 -1
- package/dist/create/evm-to-bitcoin.js +0 -82
- package/dist/create/evm-to-bitcoin.js.map +0 -1
- package/dist/create/evm-to-lightning.js +0 -89
- package/dist/create/evm-to-lightning.js.map +0 -1
- package/dist/create/index.js +0 -21
- package/dist/create/index.js.map +0 -1
- package/dist/create/lightning-to-arkade.js +0 -69
- package/dist/create/lightning-to-arkade.js.map +0 -1
- package/dist/create/lightning.js +0 -61
- package/dist/create/lightning.js.map +0 -1
- package/dist/create/retry.js +0 -71
- package/dist/create/retry.js.map +0 -1
- package/dist/create/types.js +0 -5
- package/dist/create/types.js.map +0 -1
- package/dist/escrow/index.js +0 -115
- package/dist/escrow/index.js.map +0 -1
- package/dist/esplora.js +0 -47
- package/dist/esplora.js.map +0 -1
- package/dist/evm/coordinator.js +0 -714
- package/dist/evm/coordinator.js.map +0 -1
- package/dist/evm/htlc.js +0 -278
- package/dist/evm/htlc.js.map +0 -1
- package/dist/evm/index.js +0 -10
- package/dist/evm/index.js.map +0 -1
- package/dist/evm/signing.js +0 -70
- package/dist/evm/signing.js.map +0 -1
- package/dist/evm/wallet.js +0 -133
- package/dist/evm/wallet.js.map +0 -1
- package/dist/generated/api.js +0 -6
- package/dist/generated/api.js.map +0 -1
- package/dist/logging.js +0 -130
- package/dist/logging.js.map +0 -1
- package/dist/price-calculations.js +0 -135
- package/dist/price-calculations.js.map +0 -1
- package/dist/redeem/arkade.js +0 -416
- package/dist/redeem/arkade.js.map +0 -1
- package/dist/redeem/ethereum.js +0 -206
- package/dist/redeem/ethereum.js.map +0 -1
- package/dist/redeem/gasless.js +0 -73
- package/dist/redeem/gasless.js.map +0 -1
- package/dist/redeem/index.js +0 -189
- package/dist/redeem/index.js.map +0 -1
- package/dist/redeem/types.js +0 -36
- package/dist/redeem/types.js.map +0 -1
- package/dist/refund/arkade.js +0 -200
- package/dist/refund/arkade.js.map +0 -1
- package/dist/refund/collab-arkade-evm.js +0 -307
- package/dist/refund/collab-arkade-evm.js.map +0 -1
- package/dist/refund/collab-arkade-lightning.js +0 -245
- package/dist/refund/collab-arkade-lightning.js.map +0 -1
- package/dist/refund/index.js +0 -12
- package/dist/refund/index.js.map +0 -1
- package/dist/refund/onchain.js +0 -366
- package/dist/refund/onchain.js.map +0 -1
- package/dist/signer/index.js +0 -249
- package/dist/signer/index.js.map +0 -1
- package/dist/storage/idb.js +0 -236
- package/dist/storage/idb.js.map +0 -1
- package/dist/storage/index.js +0 -98
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/sqlite.js +0 -206
- package/dist/storage/sqlite.js.map +0 -1
- package/dist/storage/types.js +0 -9
- package/dist/storage/types.js.map +0 -1
- package/dist/tokens.js +0 -322
- package/dist/tokens.js.map +0 -1
- package/dist/usd-price.js +0 -96
- package/dist/usd-price.js.map +0 -1
- package/dist/usdt0-bridge/constants.js +0 -71
- package/dist/usdt0-bridge/constants.js.map +0 -1
- package/dist/usdt0-bridge/index.js +0 -11
- package/dist/usdt0-bridge/index.js.map +0 -1
- package/dist/usdt0-bridge/tracking.js +0 -123
- package/dist/usdt0-bridge/tracking.js.map +0 -1
- package/dist/usdt0-bridge/utils.js +0 -51
- package/dist/usdt0-bridge/utils.js.map +0 -1
- package/dist/version.js +0 -6
- package/dist/version.js.map +0 -1
- package/dist/ws.js +0 -145
- package/dist/ws.js.map +0 -1
package/dist/redeem/gasless.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gasless claim logic.
|
|
3
|
-
*
|
|
4
|
-
* Claims are submitted via the server's claim-gasless endpoint which
|
|
5
|
-
* uses the HTLCCoordinator contract for gasless execution.
|
|
6
|
-
*/
|
|
7
|
-
import { buildRedeemDigest, signEvmDigest } from "../evm/index.js";
|
|
8
|
-
/**
|
|
9
|
-
* Claims an Arkade-to-EVM swap gaslessly via the server.
|
|
10
|
-
*
|
|
11
|
-
* Builds the EIP-712 digest, signs it with the provided secret key,
|
|
12
|
-
* and sends the signature + secret to the server. The server submits
|
|
13
|
-
* the `coordinator.redeemAndExecute` transaction.
|
|
14
|
-
*
|
|
15
|
-
* @param params - All data needed for the gasless claim.
|
|
16
|
-
* @returns The gasless claim result with transaction hash.
|
|
17
|
-
*/
|
|
18
|
-
export async function claimViaGasless(params) {
|
|
19
|
-
const { baseUrl, preimage, secretKey, swap, destination, dexCalldata, minAmountOut, callsHash, bridgeRecipient, bridgeRecipientWallet, } = params;
|
|
20
|
-
const secretHex = preimage.startsWith("0x") ? preimage : `0x${preimage}`;
|
|
21
|
-
const wbtcAddress = swap.wbtc_address;
|
|
22
|
-
const amount = BigInt(swap.evm_expected_sats);
|
|
23
|
-
// target_token.token_id contains the ERC-20 contract address for the final token
|
|
24
|
-
const targetTokenAddress = String(swap.target_token.token_id);
|
|
25
|
-
// Check if target token differs from WBTC (meaning a DEX swap is needed)
|
|
26
|
-
const needsDexSwap = targetTokenAddress.toLowerCase() !== wbtcAddress.toLowerCase();
|
|
27
|
-
// sweepToken: if there's a DEX swap, sweep the target token; otherwise sweep WBTC
|
|
28
|
-
const sweepToken = needsDexSwap ? targetTokenAddress : wbtcAddress;
|
|
29
|
-
// Build EIP-712 digest
|
|
30
|
-
const digest = buildRedeemDigest({
|
|
31
|
-
htlcAddress: swap.evm_htlc_address,
|
|
32
|
-
chainId: swap.evm_chain_id,
|
|
33
|
-
preimage: secretHex,
|
|
34
|
-
amount,
|
|
35
|
-
token: wbtcAddress,
|
|
36
|
-
sender: swap.server_evm_address,
|
|
37
|
-
timelock: swap.evm_refund_locktime,
|
|
38
|
-
caller: swap.evm_coordinator_address,
|
|
39
|
-
destination,
|
|
40
|
-
sweepToken,
|
|
41
|
-
minAmountOut,
|
|
42
|
-
callsHash,
|
|
43
|
-
});
|
|
44
|
-
// Sign with the swap's internally derived EVM key
|
|
45
|
-
const sig = signEvmDigest(secretKey, digest);
|
|
46
|
-
// Send to server with DEX calldata if applicable
|
|
47
|
-
const response = await fetch(`${baseUrl}/swap/${swap.id}/claim-gasless`, {
|
|
48
|
-
method: "POST",
|
|
49
|
-
headers: { "Content-Type": "application/json" },
|
|
50
|
-
body: JSON.stringify({
|
|
51
|
-
secret: secretHex,
|
|
52
|
-
destination,
|
|
53
|
-
v: sig.v,
|
|
54
|
-
r: sig.r,
|
|
55
|
-
s: sig.s,
|
|
56
|
-
dex_calldata: needsDexSwap ? dexCalldata : undefined,
|
|
57
|
-
bridge_recipient: bridgeRecipient,
|
|
58
|
-
bridge_recipient_wallet: bridgeRecipientWallet,
|
|
59
|
-
}),
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
const errorText = await response.text();
|
|
63
|
-
throw new Error(`Gasless claim failed (${response.status}): ${errorText}`);
|
|
64
|
-
}
|
|
65
|
-
const result = await response.json();
|
|
66
|
-
return {
|
|
67
|
-
id: result.id,
|
|
68
|
-
status: result.status,
|
|
69
|
-
txHash: result.tx_hash,
|
|
70
|
-
message: result.message,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=gasless.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gasless.js","sourceRoot":"","sources":["../../src/redeem/gasless.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA6CnE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAA0B;IAE1B,MAAM,EACJ,OAAO,EACP,QAAQ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vE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,MAAM,EAAE,SAAS;YACjB,WAAW;YACX,CAAC,EAAE,GAAG,CAAC,CAAC;YACR,CAAC,EAAE,GAAG,CAAC,CAAC;YACR,CAAC,EAAE,GAAG,CAAC,CAAC;YACR,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;YACpD,gBAAgB,EAAE,eAAe;YACjC,uBAAuB,EAAE,qBAAqB;SAC/C,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,CAAC,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACrC,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,OAAO;QACtB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC"}
|
package/dist/redeem/index.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redeem module for Lendaswap swaps.
|
|
3
|
-
*
|
|
4
|
-
* Provides redeem/claim logic for completing swaps:
|
|
5
|
-
* - Server-side gasless claims for Arkade/Lightning-to-EVM swaps
|
|
6
|
-
* - Manual claiming with call data for other EVM swaps
|
|
7
|
-
* - Arkade VHTLC claiming for EVM-to-Arkade swaps
|
|
8
|
-
* - Coordinator redeemAndExecute for Arkade-to-EVM swaps
|
|
9
|
-
*/
|
|
10
|
-
import { buildEthereumClaimData } from "./ethereum.js";
|
|
11
|
-
import { getChainFromTokenId, getClaimChainFromChainName, } from "./types.js";
|
|
12
|
-
// Re-export Arkade claim
|
|
13
|
-
export { buildArkadeClaim, continueArkadeClaim, } from "./arkade.js";
|
|
14
|
-
// Re-export utilities from ethereum module
|
|
15
|
-
export { encodeClaimSwapCallData, uuidToBytes32 } from "./ethereum.js";
|
|
16
|
-
// Re-export gasless claim
|
|
17
|
-
export { claimViaGasless } from "./gasless.js";
|
|
18
|
-
export { getChainFromTokenId } from "./types.js";
|
|
19
|
-
/**
|
|
20
|
-
* Claims a swap by revealing the preimage.
|
|
21
|
-
*
|
|
22
|
-
* The claim method depends on the swap direction and target chain:
|
|
23
|
-
* - **Arkade/Lightning-to-EVM**: Server-side gasless claim via coordinator
|
|
24
|
-
* - **Other EVM swaps**: Returns call data for manual claiming
|
|
25
|
-
* - **Arkade**: Returns data needed for `buildArkadeClaim()`
|
|
26
|
-
*
|
|
27
|
-
* @param id - The UUID of the swap.
|
|
28
|
-
* @param secret - The preimage/secret (32-byte hex string, with or without 0x prefix).
|
|
29
|
-
* @param ctx - The context containing the API client and getSwap function.
|
|
30
|
-
* @param destination - (Optional) EVM address for receiving tokens. Required for Arkade-to-EVM
|
|
31
|
-
* swaps to fetch fresh DEX calldata.
|
|
32
|
-
* @returns A ClaimResult with the outcome.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* const result = await claim(swapId, storedSwap.preimage, ctx, "0x1234...");
|
|
37
|
-
* if (result.success) {
|
|
38
|
-
* if (result.coordinatorClaimData) {
|
|
39
|
-
* // Arkade/Lightning-to-EVM: gasless claim via server
|
|
40
|
-
* console.log("TX Hash:", result.txHash);
|
|
41
|
-
* } else if (result.chain === "arkade") {
|
|
42
|
-
* // Arkade claim needs user's keys
|
|
43
|
-
* await buildArkadeClaim({ ...result.arkadeClaimData, ... });
|
|
44
|
-
* } else {
|
|
45
|
-
* // Manual EVM claim
|
|
46
|
-
* console.log("Call data:", result.ethereumClaimData?.callData);
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export async function claim(id, secret, ctx, destination) {
|
|
52
|
-
// Get the swap to determine target chain
|
|
53
|
-
const swap = await ctx.getSwap(id);
|
|
54
|
-
// Check if this is an arkade_to_evm swap (uses coordinator redeemAndExecute)
|
|
55
|
-
if ("direction" in swap && swap.direction === "arkade_to_evm") {
|
|
56
|
-
return buildCoordinatorClaimData(id, swap, ctx, destination);
|
|
57
|
-
}
|
|
58
|
-
// target_token may be a string (TokenId) or object (TokenInfo with chain + token_id)
|
|
59
|
-
const chain = typeof swap.target_token === "object" &&
|
|
60
|
-
swap.target_token !== null &&
|
|
61
|
-
"chain" in swap.target_token
|
|
62
|
-
? getClaimChainFromChainName(swap.target_token.chain)
|
|
63
|
-
: getChainFromTokenId(swap.target_token);
|
|
64
|
-
if (!chain) {
|
|
65
|
-
return {
|
|
66
|
-
success: false,
|
|
67
|
-
message: `Unknown target chain for token: ${JSON.stringify(swap.target_token)}. Cannot determine claim method.`,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// Arkade claims return data for manual execution with user's keys
|
|
71
|
-
if (chain === "arkade") {
|
|
72
|
-
// For EVM-to-Arkade swaps, we need specific fields from the swap
|
|
73
|
-
// @ts-expect-error
|
|
74
|
-
const arkadeSwap = swap;
|
|
75
|
-
return buildArkadeClaimData(arkadeSwap);
|
|
76
|
-
}
|
|
77
|
-
// EVM claims (Ethereum, Polygon, Arbitrum) return data for manual execution
|
|
78
|
-
return buildEthereumClaimData(id, secret, swap, chain);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Builds the claim data for an Arkade-to-EVM swap (coordinator redeemAndExecute).
|
|
82
|
-
*
|
|
83
|
-
* The user must:
|
|
84
|
-
* 1. Build the EIP-712 digest using `buildRedeemDigest()` from `evm/coordinator`
|
|
85
|
-
* 2. Sign the digest with their EVM wallet
|
|
86
|
-
* 3. Build the transaction using `encodeRedeemAndExecute()`
|
|
87
|
-
* 4. Submit the transaction to the coordinator contract
|
|
88
|
-
*
|
|
89
|
-
* @param id - The swap ID
|
|
90
|
-
* @param swap - The swap response
|
|
91
|
-
* @param ctx - The redeem context with API client
|
|
92
|
-
* @param destination - Optional EVM address for receiving tokens. If provided and the swap
|
|
93
|
-
* involves a DEX swap (target != WBTC), fresh calldata is fetched.
|
|
94
|
-
*/
|
|
95
|
-
async function buildCoordinatorClaimData(id, swap, ctx, destination) {
|
|
96
|
-
// WBTC address from server response, fall back to well-known addresses
|
|
97
|
-
const WBTC_BY_CHAIN_ID = {
|
|
98
|
-
137: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6", // Polygon
|
|
99
|
-
1: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", // Ethereum
|
|
100
|
-
42161: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", // Arbitrum
|
|
101
|
-
};
|
|
102
|
-
const wbtcAddress = swap.wbtc_address ?? WBTC_BY_CHAIN_ID[swap.evm_chain_id];
|
|
103
|
-
if (!wbtcAddress) {
|
|
104
|
-
return {
|
|
105
|
-
success: false,
|
|
106
|
-
message: `Cannot determine WBTC address for chain ID ${swap.evm_chain_id}`,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
// target_token.token_id contains the ERC-20 contract address for the final token
|
|
110
|
-
const targetTokenAddress = String(swap.target_token.token_id);
|
|
111
|
-
// Check if this swap involves a DEX swap (target token is different from WBTC)
|
|
112
|
-
const needsDexSwap = targetTokenAddress.toLowerCase() !== wbtcAddress.toLowerCase();
|
|
113
|
-
let dexCallData;
|
|
114
|
-
// Fetch fresh DEX calldata if destination is provided and swap needs DEX
|
|
115
|
-
if (destination && needsDexSwap) {
|
|
116
|
-
const response = await ctx.apiClient.GET("/swap/{id}/redeem-and-swap-calldata", {
|
|
117
|
-
params: {
|
|
118
|
-
path: { id },
|
|
119
|
-
query: { destination },
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
if (response.error) {
|
|
123
|
-
return {
|
|
124
|
-
success: false,
|
|
125
|
-
message: `Failed to fetch DEX calldata: ${response.error.error || "Unknown error"}`,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (response.data.dex_calldata) {
|
|
129
|
-
dexCallData = {
|
|
130
|
-
to: response.data.dex_calldata.to,
|
|
131
|
-
data: response.data.dex_calldata.data,
|
|
132
|
-
value: response.data.dex_calldata.value,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const coordinatorClaimData = {
|
|
137
|
-
htlcAddress: swap.evm_htlc_address,
|
|
138
|
-
coordinatorAddress: swap.evm_coordinator_address,
|
|
139
|
-
chainId: swap.evm_chain_id,
|
|
140
|
-
amount: swap.evm_expected_sats,
|
|
141
|
-
wbtcAddress,
|
|
142
|
-
sender: swap.server_evm_address,
|
|
143
|
-
timelock: swap.evm_refund_locktime,
|
|
144
|
-
dexCallData,
|
|
145
|
-
targetTokenAddress,
|
|
146
|
-
network: swap.network,
|
|
147
|
-
};
|
|
148
|
-
const message = destination
|
|
149
|
-
? "Arkade-to-EVM claims require EIP-712 signing. Use buildRedeemDigest() and encodeRedeemAndExecute() with the provided data."
|
|
150
|
-
: "Arkade-to-EVM claims require EIP-712 signing. Note: No destination provided - call claim() again with your EVM address to fetch fresh DEX calldata.";
|
|
151
|
-
return {
|
|
152
|
-
success: true,
|
|
153
|
-
message,
|
|
154
|
-
coordinatorClaimData,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Builds the claim data for an Arkade swap (EVM-to-Arkade direction).
|
|
159
|
-
*
|
|
160
|
-
* For Arkade claims, the user needs to call `buildArkadeClaim` with their
|
|
161
|
-
* secret key and destination address. This function extracts the necessary
|
|
162
|
-
* parameters from the swap response.
|
|
163
|
-
*/
|
|
164
|
-
function buildArkadeClaimData(swap) {
|
|
165
|
-
if (!swap.htlc_address_arkade) {
|
|
166
|
-
return {
|
|
167
|
-
success: false,
|
|
168
|
-
message: "Swap does not have an Arkade HTLC address.",
|
|
169
|
-
chain: "arkade",
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
const arkadeClaimData = {
|
|
173
|
-
lendaswapPubKey: swap.sender_pk,
|
|
174
|
-
arkadeServerPubKey: swap.server_pk,
|
|
175
|
-
vhtlcAddress: swap.htlc_address_arkade,
|
|
176
|
-
refundLocktime: swap.vhtlc_refund_locktime ?? 0,
|
|
177
|
-
unilateralClaimDelay: swap.unilateral_claim_delay ?? 0,
|
|
178
|
-
unilateralRefundDelay: swap.unilateral_refund_delay ?? 0,
|
|
179
|
-
unilateralRefundWithoutReceiverDelay: swap.unilateral_refund_without_receiver_delay ?? 0,
|
|
180
|
-
network: swap.network,
|
|
181
|
-
};
|
|
182
|
-
return {
|
|
183
|
-
success: true,
|
|
184
|
-
message: "Arkade claims require your secret key. Use buildArkadeClaim() with the provided data.",
|
|
185
|
-
chain: "arkade",
|
|
186
|
-
arkadeClaimData,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
//# sourceMappingURL=index.js.map
|
package/dist/redeem/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/redeem/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAIL,mBAAmB,EACnB,0BAA0B,GAE3B,MAAM,YAAY,CAAC;AAEpB,yBAAyB;AACzB,OAAO,EAGL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,2CAA2C;AAC3C,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACvE,0BAA0B;AAC1B,OAAO,EAAE,eAAe,EAA2B,MAAM,cAAc,CAAC;AAWxE,OAAO,EAAE,mBA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ClC,IAAI,CAAC,wCAAwC,IAAI,CAAC;QACpD,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EACL,uFAAuF;QACzF,KAAK,EAAE,QAAQ;QACf,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
package/dist/redeem/types.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for redeem/claim operations.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Extracts the chain from a token ID.
|
|
6
|
-
*
|
|
7
|
-
* Token IDs follow the pattern: `{token}_{chain}` (e.g., "usdc_pol", "usdt_eth", "usdc_arb")
|
|
8
|
-
*
|
|
9
|
-
* @param tokenId - The token identifier
|
|
10
|
-
* @returns The chain or undefined if not recognized
|
|
11
|
-
*/
|
|
12
|
-
export function getChainFromTokenId(tokenId) {
|
|
13
|
-
if (tokenId.endsWith("_pol"))
|
|
14
|
-
return "polygon";
|
|
15
|
-
if (tokenId.endsWith("_arb"))
|
|
16
|
-
return "arbitrum";
|
|
17
|
-
if (tokenId.endsWith("_eth"))
|
|
18
|
-
return "ethereum";
|
|
19
|
-
if (tokenId === "btc_arkade")
|
|
20
|
-
return "arkade";
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Maps an API Chain name (e.g. "Polygon") to a ClaimChain (e.g. "polygon").
|
|
25
|
-
*/
|
|
26
|
-
export function getClaimChainFromChainName(chain) {
|
|
27
|
-
const lower = chain.toLowerCase();
|
|
28
|
-
if (lower === "polygon" ||
|
|
29
|
-
lower === "arbitrum" ||
|
|
30
|
-
lower === "ethereum" ||
|
|
31
|
-
lower === "arkade") {
|
|
32
|
-
return lower;
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=types.js.map
|
package/dist/redeem/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/redeem/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmHH;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IAChD,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IAChD,IAAI,OAAO,KAAK,YAAY;QAAE,OAAO,QAAQ,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAa;IAEb,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAClC,IACE,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,QAAQ,EAClB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/refund/arkade.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Arkade (off-chain) VHTLC refund implementation.
|
|
3
|
-
*
|
|
4
|
-
* This module provides VHTLC refund functionality for Arkade (btc_arkade) swaps.
|
|
5
|
-
* When a swap times out, users can reclaim their funds using this refund logic.
|
|
6
|
-
*
|
|
7
|
-
* The VHTLC uses a Taproot output with multiple spending paths. For refunds
|
|
8
|
-
* after the locktime, we use the `refundWithoutReceiver` script path.
|
|
9
|
-
*/
|
|
10
|
-
import { buildOffchainTx, CSVMultisigTapscript, RestArkProvider, RestIndexerProvider, SingleKey, Transaction, VHTLC, } from "@arkade-os/sdk";
|
|
11
|
-
import { ripemd160 } from "@noble/hashes/legacy.js";
|
|
12
|
-
import { base64, hex } from "@scure/base";
|
|
13
|
-
import { getNetworkHrp, getNetworkName, resolveArkadeServerUrlByName, } from "../arkade-network.js";
|
|
14
|
-
import { createSdkLogger } from "../logging.js";
|
|
15
|
-
/**
|
|
16
|
-
* Convert seconds to RelativeTimelock format.
|
|
17
|
-
*/
|
|
18
|
-
function secondsToTimelock(seconds) {
|
|
19
|
-
// Arkade SDK expects blocks or seconds for timelocks.
|
|
20
|
-
// The sequence encoding for seconds requires 512-second granularity.
|
|
21
|
-
return {
|
|
22
|
-
type: "seconds",
|
|
23
|
-
value: BigInt(seconds),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Parse public key, handling both compressed (33-byte) and x-only (32-byte) formats.
|
|
28
|
-
* Returns x-only (32-byte) format.
|
|
29
|
-
*/
|
|
30
|
-
function parseXOnlyPubKey(pubKeyHex) {
|
|
31
|
-
const bytes = hex.decode(pubKeyHex);
|
|
32
|
-
if (bytes.length === 33) {
|
|
33
|
-
// Compressed pubkey, strip the prefix byte
|
|
34
|
-
return bytes.slice(1);
|
|
35
|
-
}
|
|
36
|
-
if (bytes.length === 32) {
|
|
37
|
-
// Already x-only
|
|
38
|
-
return bytes;
|
|
39
|
-
}
|
|
40
|
-
throw new Error(`Invalid public key length: expected 32 or 33, got ${bytes.length}`);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Refund a VHTLC swap after the locktime expires.
|
|
44
|
-
*
|
|
45
|
-
* This function:
|
|
46
|
-
* 1. Constructs the VHTLC with the same parameters as the original swap
|
|
47
|
-
* 2. Connects to the Arkade server
|
|
48
|
-
* 3. Fetches spendable VTXOs at the VHTLC address
|
|
49
|
-
* 4. Builds an offchain transaction using the refundWithoutReceiver script path
|
|
50
|
-
* 5. Signs and submits the transaction
|
|
51
|
-
* 6. Finalizes the transaction
|
|
52
|
-
*
|
|
53
|
-
* @param params - The refund parameters
|
|
54
|
-
* @returns The refund result with transaction ID and amount
|
|
55
|
-
* @throws Error if the refund fails
|
|
56
|
-
*/
|
|
57
|
-
export async function buildArkadeRefund(params) {
|
|
58
|
-
const { userSecretKey, userPubKey, lendaswapPubKey, arkadeServerPubKey, hashLock, vhtlcAddress, refundLocktime, unilateralClaimDelay, unilateralRefundDelay, unilateralRefundWithoutReceiverDelay, destinationAddress, network, arkadeServerUrl, } = params;
|
|
59
|
-
const logger = createSdkLogger(params).child({
|
|
60
|
-
module: "refund/arkade",
|
|
61
|
-
operation: "arkade.refund",
|
|
62
|
-
data: { vhtlcAddress, network, destinationAddress },
|
|
63
|
-
});
|
|
64
|
-
logger.info({
|
|
65
|
-
event: "arkade.refund.start",
|
|
66
|
-
message: "Starting Arkade refund",
|
|
67
|
-
});
|
|
68
|
-
// Parse keys
|
|
69
|
-
const userPkBytes = parseXOnlyPubKey(userPubKey);
|
|
70
|
-
const lendaswapPkBytes = parseXOnlyPubKey(lendaswapPubKey);
|
|
71
|
-
const serverPkBytes = parseXOnlyPubKey(arkadeServerPubKey);
|
|
72
|
-
// Compute preimage hash for VHTLC
|
|
73
|
-
// The API sends us the SHA256 hash (32 bytes) or HASH160 (20 bytes)
|
|
74
|
-
const hashLockBytes = hex.decode(hashLock);
|
|
75
|
-
let preimageHashBytes;
|
|
76
|
-
if (hashLockBytes.length === 32) {
|
|
77
|
-
// the preimage is a SHA256 hash, we need to compute RIPEMD160 of it
|
|
78
|
-
preimageHashBytes = ripemd160(hashLockBytes);
|
|
79
|
-
}
|
|
80
|
-
else if (hashLockBytes.length === 20) {
|
|
81
|
-
// Already HASH160
|
|
82
|
-
preimageHashBytes = hashLockBytes;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
throw new Error(`Invalid hash lock length: expected 20 or 32, got ${hashLockBytes.length}`);
|
|
86
|
-
}
|
|
87
|
-
// Determine Arkade server URL
|
|
88
|
-
const networkName = getNetworkName(network);
|
|
89
|
-
const serverUrl = resolveArkadeServerUrlByName(networkName, arkadeServerUrl);
|
|
90
|
-
// Create Arkade providers
|
|
91
|
-
const arkProvider = new RestArkProvider(serverUrl);
|
|
92
|
-
const indexerProvider = new RestIndexerProvider(serverUrl);
|
|
93
|
-
// Get server info
|
|
94
|
-
const serverInfo = await arkProvider.getInfo();
|
|
95
|
-
// Construct VHTLC with the same parameters as the original swap
|
|
96
|
-
// For refund: user is the SENDER (refunding), lendaswap is the RECEIVER
|
|
97
|
-
const vhtlc = new VHTLC.Script({
|
|
98
|
-
sender: userPkBytes,
|
|
99
|
-
receiver: lendaswapPkBytes,
|
|
100
|
-
server: serverPkBytes,
|
|
101
|
-
preimageHash: preimageHashBytes,
|
|
102
|
-
refundLocktime: BigInt(refundLocktime),
|
|
103
|
-
unilateralClaimDelay: secondsToTimelock(unilateralClaimDelay),
|
|
104
|
-
unilateralRefundDelay: secondsToTimelock(unilateralRefundDelay),
|
|
105
|
-
unilateralRefundWithoutReceiverDelay: secondsToTimelock(unilateralRefundWithoutReceiverDelay),
|
|
106
|
-
});
|
|
107
|
-
// Get network HRP and verify computed VHTLC address
|
|
108
|
-
const hrp = getNetworkHrp(networkName);
|
|
109
|
-
const computedAddress = vhtlc.address(hrp, serverPkBytes);
|
|
110
|
-
const computedAddressStr = computedAddress.encode();
|
|
111
|
-
// Verify address matches expected
|
|
112
|
-
if (computedAddressStr !== vhtlcAddress) {
|
|
113
|
-
throw new Error(`Computed VHTLC address (${computedAddressStr}) does not match expected (${vhtlcAddress})`);
|
|
114
|
-
}
|
|
115
|
-
// Fetch VTXOs at the VHTLC address
|
|
116
|
-
// We need the pk script to query the indexer
|
|
117
|
-
const vhtlcPkScript = hex.encode(vhtlc.pkScript);
|
|
118
|
-
const { vtxos } = await indexerProvider.getVtxos({
|
|
119
|
-
scripts: [vhtlcPkScript],
|
|
120
|
-
spendableOnly: true,
|
|
121
|
-
});
|
|
122
|
-
if (vtxos.length === 0) {
|
|
123
|
-
const { vtxos: updated } = await indexerProvider.getVtxos({
|
|
124
|
-
scripts: [vhtlcPkScript],
|
|
125
|
-
});
|
|
126
|
-
logger.debug({
|
|
127
|
-
event: "arkade.refund.no_spendable_vtxos",
|
|
128
|
-
message: "No spendable VTXOs found at VHTLC address",
|
|
129
|
-
data: { vtxos: updated },
|
|
130
|
-
});
|
|
131
|
-
throw new Error("No spendable VTXOs found at the VHTLC address");
|
|
132
|
-
}
|
|
133
|
-
// Calculate total amount (vtxos have value as number)
|
|
134
|
-
const totalAmount = vtxos.reduce((acc, v) => acc + BigInt(v.value), 0n);
|
|
135
|
-
if (totalAmount === 0n) {
|
|
136
|
-
throw new Error("Total VTXO amount is zero");
|
|
137
|
-
}
|
|
138
|
-
// Get the refundWithoutReceiver TapLeafScript
|
|
139
|
-
const refundLeafScript = vhtlc.refundWithoutReceiver();
|
|
140
|
-
// Encode the VHTLC tap tree
|
|
141
|
-
const tapTree = vhtlc.encode();
|
|
142
|
-
// Decode the server's checkpoint tapscript from the server info
|
|
143
|
-
const checkpointTapscript = CSVMultisigTapscript.decode(hex.decode(serverInfo.checkpointTapscript));
|
|
144
|
-
// Build inputs for offchain transaction
|
|
145
|
-
const inputs = vtxos.map((v) => ({
|
|
146
|
-
txid: v.txid,
|
|
147
|
-
vout: v.vout,
|
|
148
|
-
value: v.value,
|
|
149
|
-
tapTree: tapTree,
|
|
150
|
-
tapLeafScript: refundLeafScript,
|
|
151
|
-
}));
|
|
152
|
-
// Parse destination address to get the output script
|
|
153
|
-
// The destination should be an Arkade address that we can decode
|
|
154
|
-
const { ArkAddress } = await import("@arkade-os/sdk");
|
|
155
|
-
const destAddr = ArkAddress.decode(destinationAddress);
|
|
156
|
-
const destPkScript = destAddr.pkScript;
|
|
157
|
-
// Build outputs
|
|
158
|
-
const outputs = [
|
|
159
|
-
{
|
|
160
|
-
script: destPkScript,
|
|
161
|
-
amount: totalAmount,
|
|
162
|
-
},
|
|
163
|
-
];
|
|
164
|
-
const destinationAddressPPkScript = hex.encode(destPkScript);
|
|
165
|
-
logger.info({
|
|
166
|
-
event: "arkade.refund.vtxos_found",
|
|
167
|
-
message: "Found spendable VTXOs for Arkade refund",
|
|
168
|
-
data: { totalAmount, vtxoCount: vtxos.length, destinationAddressPPkScript },
|
|
169
|
-
});
|
|
170
|
-
// Build the offchain transaction
|
|
171
|
-
const { arkTx, checkpoints } = buildOffchainTx(inputs, outputs, checkpointTapscript);
|
|
172
|
-
// Create signer from user's secret key
|
|
173
|
-
const signer = SingleKey.fromHex(userSecretKey);
|
|
174
|
-
// Sign the ark transaction
|
|
175
|
-
const signedArkTx = await signer.sign(arkTx);
|
|
176
|
-
// Submit the transaction to the Arkade server
|
|
177
|
-
const signedArkTxBase64 = base64.encode(signedArkTx.toPSBT());
|
|
178
|
-
const { arkTxid, signedCheckpointTxs } = await arkProvider.submitTx(signedArkTxBase64, checkpoints.map((cp) => base64.encode(cp.toPSBT())));
|
|
179
|
-
const finalCheckpoints = await Promise.all(signedCheckpointTxs.map(async (c) => {
|
|
180
|
-
const tx = Transaction.fromPSBT(base64.decode(c));
|
|
181
|
-
const signedCheckpoint = await signer.sign(tx);
|
|
182
|
-
return base64.encode(signedCheckpoint.toPSBT());
|
|
183
|
-
}));
|
|
184
|
-
logger.debug({
|
|
185
|
-
event: "arkade.refund.checkpoints_signed",
|
|
186
|
-
message: "Final checkpoint transactions signed",
|
|
187
|
-
});
|
|
188
|
-
// Finalize the transaction
|
|
189
|
-
await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
|
|
190
|
-
logger.info({
|
|
191
|
-
event: "arkade.refund.finalized",
|
|
192
|
-
message: "Arkade refund finalized",
|
|
193
|
-
data: { arkTxid },
|
|
194
|
-
});
|
|
195
|
-
return {
|
|
196
|
-
txId: arkTxid,
|
|
197
|
-
refundAmount: totalAmount,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
//# sourceMappingURL=arkade.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arkade.js","sourceRoot":"","sources":["../../src/refund/arkade.ts"],"names":[],"mappings":"AAAA;;;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