@lendasat/lendaswap-sdk-pure 0.2.21-1 → 0.2.21
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/api/client.d.ts.map +1 -1
- package/dist/api/client.js +4 -1
- package/dist/api/client.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js.map +1 -1
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +4 -1
- package/dist/price-feed.d.ts +0 -124
- package/dist/price-feed.d.ts.map +0 -1
- package/dist/price-feed.js +0 -178
- package/dist/price-feed.js.map +0 -1
- package/dist/src/api/client.d.ts +0 -31
- package/dist/src/api/client.d.ts.map +0 -1
- package/dist/src/api/client.js +0 -12
- package/dist/src/api/client.js.map +0 -1
- package/dist/src/arkade.d.ts +0 -36
- package/dist/src/arkade.d.ts.map +0 -1
- package/dist/src/arkade.js +0 -68
- package/dist/src/arkade.js.map +0 -1
- package/dist/src/client.d.ts +0 -760
- package/dist/src/client.d.ts.map +0 -1
- package/dist/src/client.js +0 -2169
- package/dist/src/client.js.map +0 -1
- package/dist/src/create/arkade.d.ts +0 -34
- package/dist/src/create/arkade.d.ts.map +0 -1
- package/dist/src/create/arkade.js +0 -76
- package/dist/src/create/arkade.js.map +0 -1
- package/dist/src/create/bitcoin-to-arkade.d.ts +0 -36
- package/dist/src/create/bitcoin-to-arkade.d.ts.map +0 -1
- package/dist/src/create/bitcoin-to-arkade.js +0 -69
- package/dist/src/create/bitcoin-to-arkade.js.map +0 -1
- package/dist/src/create/bitcoin.d.ts +0 -31
- package/dist/src/create/bitcoin.d.ts.map +0 -1
- package/dist/src/create/bitcoin.js +0 -67
- package/dist/src/create/bitcoin.js.map +0 -1
- package/dist/src/create/evm-to-arkade.d.ts +0 -34
- package/dist/src/create/evm-to-arkade.d.ts.map +0 -1
- package/dist/src/create/evm-to-arkade.js +0 -69
- package/dist/src/create/evm-to-arkade.js.map +0 -1
- package/dist/src/create/evm-to-bitcoin.d.ts +0 -35
- package/dist/src/create/evm-to-bitcoin.d.ts.map +0 -1
- package/dist/src/create/evm-to-bitcoin.js +0 -71
- package/dist/src/create/evm-to-bitcoin.js.map +0 -1
- package/dist/src/create/evm-to-lightning.d.ts +0 -34
- package/dist/src/create/evm-to-lightning.d.ts.map +0 -1
- package/dist/src/create/evm-to-lightning.js +0 -66
- package/dist/src/create/evm-to-lightning.js.map +0 -1
- package/dist/src/create/index.d.ts +0 -19
- package/dist/src/create/index.d.ts.map +0 -1
- package/dist/src/create/index.js +0 -18
- package/dist/src/create/index.js.map +0 -1
- package/dist/src/create/lightning.d.ts +0 -31
- package/dist/src/create/lightning.d.ts.map +0 -1
- package/dist/src/create/lightning.js +0 -72
- package/dist/src/create/lightning.js.map +0 -1
- package/dist/src/create/types.d.ts +0 -247
- package/dist/src/create/types.d.ts.map +0 -1
- package/dist/src/create/types.js +0 -5
- package/dist/src/create/types.js.map +0 -1
- package/dist/src/delegate.d.ts +0 -62
- package/dist/src/delegate.d.ts.map +0 -1
- package/dist/src/delegate.js +0 -284
- package/dist/src/delegate.js.map +0 -1
- package/dist/src/esplora.d.ts +0 -41
- package/dist/src/esplora.d.ts.map +0 -1
- package/dist/src/esplora.js +0 -47
- package/dist/src/esplora.js.map +0 -1
- package/dist/src/evm/coordinator.d.ts +0 -247
- package/dist/src/evm/coordinator.d.ts.map +0 -1
- package/dist/src/evm/coordinator.js +0 -414
- package/dist/src/evm/coordinator.js.map +0 -1
- package/dist/src/evm/htlc.d.ts +0 -238
- package/dist/src/evm/htlc.d.ts.map +0 -1
- package/dist/src/evm/htlc.js +0 -278
- package/dist/src/evm/htlc.js.map +0 -1
- package/dist/src/evm/index.d.ts +0 -9
- package/dist/src/evm/index.d.ts.map +0 -1
- package/dist/src/evm/index.js +0 -9
- package/dist/src/evm/index.js.map +0 -1
- package/dist/src/evm/signing.d.ts +0 -30
- package/dist/src/evm/signing.d.ts.map +0 -1
- package/dist/src/evm/signing.js +0 -91
- package/dist/src/evm/signing.js.map +0 -1
- package/dist/src/generated/api.d.ts +0 -2736
- package/dist/src/generated/api.d.ts.map +0 -1
- package/dist/src/generated/api.js +0 -6
- package/dist/src/generated/api.js.map +0 -1
- package/dist/src/index.d.ts +0 -18
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -24
- package/dist/src/index.js.map +0 -1
- package/dist/src/node.d.ts +0 -19
- package/dist/src/node.d.ts.map +0 -1
- package/dist/src/node.js +0 -19
- package/dist/src/node.js.map +0 -1
- package/dist/src/price-calculations.d.ts +0 -109
- package/dist/src/price-calculations.d.ts.map +0 -1
- package/dist/src/price-calculations.js +0 -135
- package/dist/src/price-calculations.js.map +0 -1
- package/dist/src/redeem/arkade.d.ts +0 -65
- package/dist/src/redeem/arkade.d.ts.map +0 -1
- package/dist/src/redeem/arkade.js +0 -217
- package/dist/src/redeem/arkade.js.map +0 -1
- package/dist/src/redeem/ethereum.d.ts +0 -52
- package/dist/src/redeem/ethereum.d.ts.map +0 -1
- package/dist/src/redeem/ethereum.js +0 -206
- package/dist/src/redeem/ethereum.js.map +0 -1
- package/dist/src/redeem/gasless.d.ts +0 -41
- package/dist/src/redeem/gasless.d.ts.map +0 -1
- package/dist/src/redeem/gasless.js +0 -71
- package/dist/src/redeem/gasless.js.map +0 -1
- package/dist/src/redeem/index.d.ts +0 -49
- package/dist/src/redeem/index.d.ts.map +0 -1
- package/dist/src/redeem/index.js +0 -189
- package/dist/src/redeem/index.js.map +0 -1
- package/dist/src/redeem/types.d.ts +0 -126
- package/dist/src/redeem/types.d.ts.map +0 -1
- package/dist/src/redeem/types.js +0 -36
- package/dist/src/redeem/types.js.map +0 -1
- package/dist/src/refund/arkade.d.ts +0 -62
- package/dist/src/refund/arkade.d.ts.map +0 -1
- package/dist/src/refund/arkade.js +0 -212
- package/dist/src/refund/arkade.js.map +0 -1
- package/dist/src/refund/index.d.ts +0 -10
- package/dist/src/refund/index.d.ts.map +0 -1
- package/dist/src/refund/index.js +0 -10
- package/dist/src/refund/index.js.map +0 -1
- package/dist/src/refund/onchain.d.ts +0 -137
- package/dist/src/refund/onchain.d.ts.map +0 -1
- package/dist/src/refund/onchain.js +0 -366
- package/dist/src/refund/onchain.js.map +0 -1
- package/dist/src/signer/index.d.ts +0 -106
- package/dist/src/signer/index.d.ts.map +0 -1
- package/dist/src/signer/index.js +0 -179
- package/dist/src/signer/index.js.map +0 -1
- package/dist/src/storage/idb.d.ts +0 -70
- package/dist/src/storage/idb.d.ts.map +0 -1
- package/dist/src/storage/idb.js +0 -236
- package/dist/src/storage/idb.js.map +0 -1
- package/dist/src/storage/index.d.ts +0 -152
- package/dist/src/storage/index.d.ts.map +0 -1
- package/dist/src/storage/index.js +0 -98
- package/dist/src/storage/index.js.map +0 -1
- package/dist/src/storage/sqlite.d.ts +0 -95
- package/dist/src/storage/sqlite.d.ts.map +0 -1
- package/dist/src/storage/sqlite.js +0 -206
- package/dist/src/storage/sqlite.js.map +0 -1
- package/dist/src/storage/types.d.ts +0 -57
- package/dist/src/storage/types.d.ts.map +0 -1
- package/dist/src/storage/types.js +0 -9
- package/dist/src/storage/types.js.map +0 -1
- package/dist/src/tokens.d.ts +0 -29
- package/dist/src/tokens.d.ts.map +0 -1
- package/dist/src/tokens.js +0 -89
- package/dist/src/tokens.js.map +0 -1
- package/dist/src/usd-price.d.ts +0 -34
- package/dist/src/usd-price.d.ts.map +0 -1
- package/dist/src/usd-price.js +0 -83
- package/dist/src/usd-price.js.map +0 -1
- package/dist/tests/api-client.test.d.ts +0 -2
- package/dist/tests/api-client.test.d.ts.map +0 -1
- package/dist/tests/api-client.test.js +0 -86
- package/dist/tests/api-client.test.js.map +0 -1
- package/dist/tests/client.test.d.ts +0 -2
- package/dist/tests/client.test.d.ts.map +0 -1
- package/dist/tests/client.test.js +0 -150
- package/dist/tests/client.test.js.map +0 -1
- package/dist/tests/index.test.d.ts +0 -2
- package/dist/tests/index.test.d.ts.map +0 -1
- package/dist/tests/index.test.js +0 -8
- package/dist/tests/index.test.js.map +0 -1
- package/dist/tests/onchain-refund.test.d.ts +0 -2
- package/dist/tests/onchain-refund.test.d.ts.map +0 -1
- package/dist/tests/onchain-refund.test.js +0 -279
- package/dist/tests/onchain-refund.test.js.map +0 -1
- package/dist/tests/signer.test.d.ts +0 -2
- package/dist/tests/signer.test.d.ts.map +0 -1
- package/dist/tests/signer.test.js +0 -92
- package/dist/tests/signer.test.js.map +0 -1
- package/dist/tests/sqlite-storage.test.d.ts +0 -2
- package/dist/tests/sqlite-storage.test.d.ts.map +0 -1
- package/dist/tests/sqlite-storage.test.js +0 -160
- package/dist/tests/sqlite-storage.test.js.map +0 -1
- package/dist/tests/storage.test.d.ts +0 -2
- package/dist/tests/storage.test.d.ts.map +0 -1
- package/dist/tests/storage.test.js +0 -184
- package/dist/tests/storage.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/usdt0-bridge/bridge.d.ts +0 -82
- package/dist/usdt0-bridge/bridge.d.ts.map +0 -1
- package/dist/usdt0-bridge/bridge.js +0 -56
- package/dist/usdt0-bridge/bridge.js.map +0 -1
- package/dist/usdt0-bridge/chains.d.ts +0 -41
- package/dist/usdt0-bridge/chains.d.ts.map +0 -1
- package/dist/usdt0-bridge/chains.js +0 -117
- package/dist/usdt0-bridge/chains.js.map +0 -1
- package/dist/usdt0-bridge/layerzero-tracker.d.ts +0 -34
- package/dist/usdt0-bridge/layerzero-tracker.d.ts.map +0 -1
- package/dist/usdt0-bridge/layerzero-tracker.js +0 -86
- package/dist/usdt0-bridge/layerzero-tracker.js.map +0 -1
- package/dist/usdt0-bridge/oft-abi.d.ts +0 -145
- package/dist/usdt0-bridge/oft-abi.d.ts.map +0 -1
- package/dist/usdt0-bridge/oft-abi.js +0 -117
- package/dist/usdt0-bridge/oft-abi.js.map +0 -1
|
@@ -1,212 +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, networks, RestArkProvider, RestIndexerProvider, SingleKey, Transaction, VHTLC, } from "@arkade-os/sdk";
|
|
11
|
-
import { ripemd160 } from "@noble/hashes/ripemd160";
|
|
12
|
-
import { base64, hex } from "@scure/base";
|
|
13
|
-
/** Default Arkade server URL by network */
|
|
14
|
-
const DEFAULT_ARKADE_URLS = {
|
|
15
|
-
bitcoin: "https://arkade.computer",
|
|
16
|
-
mainnet: "https://arkade.computer",
|
|
17
|
-
signet: "https://mutinynet.arkade.sh",
|
|
18
|
-
mutinynet: "https://mutinynet.arkade.sh",
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Maps network strings from the API to Arkade NetworkName.
|
|
22
|
-
*/
|
|
23
|
-
function getNetworkName(network) {
|
|
24
|
-
switch (network.toLowerCase()) {
|
|
25
|
-
case "mainnet":
|
|
26
|
-
case "bitcoin":
|
|
27
|
-
return "bitcoin";
|
|
28
|
-
case "testnet":
|
|
29
|
-
return "testnet";
|
|
30
|
-
case "signet":
|
|
31
|
-
return "signet";
|
|
32
|
-
case "mutinynet":
|
|
33
|
-
return "mutinynet";
|
|
34
|
-
case "regtest":
|
|
35
|
-
return "regtest";
|
|
36
|
-
default:
|
|
37
|
-
throw new Error(`Unknown network: ${network}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Get network HRP prefix for Ark addresses.
|
|
42
|
-
*/
|
|
43
|
-
function getNetworkHrp(networkName) {
|
|
44
|
-
const network = networks[networkName];
|
|
45
|
-
return network.hrp;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Convert seconds to RelativeTimelock format.
|
|
49
|
-
*/
|
|
50
|
-
function secondsToTimelock(seconds) {
|
|
51
|
-
// Arkade SDK expects blocks or seconds for timelocks.
|
|
52
|
-
// The sequence encoding for seconds requires 512-second granularity.
|
|
53
|
-
return {
|
|
54
|
-
type: "seconds",
|
|
55
|
-
value: BigInt(seconds),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Parse public key, handling both compressed (33-byte) and x-only (32-byte) formats.
|
|
60
|
-
* Returns x-only (32-byte) format.
|
|
61
|
-
*/
|
|
62
|
-
function parseXOnlyPubKey(pubKeyHex) {
|
|
63
|
-
const bytes = hex.decode(pubKeyHex);
|
|
64
|
-
if (bytes.length === 33) {
|
|
65
|
-
// Compressed pubkey, strip the prefix byte
|
|
66
|
-
return bytes.slice(1);
|
|
67
|
-
}
|
|
68
|
-
if (bytes.length === 32) {
|
|
69
|
-
// Already x-only
|
|
70
|
-
return bytes;
|
|
71
|
-
}
|
|
72
|
-
throw new Error(`Invalid public key length: expected 32 or 33, got ${bytes.length}`);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Refund a VHTLC swap after the locktime expires.
|
|
76
|
-
*
|
|
77
|
-
* This function:
|
|
78
|
-
* 1. Constructs the VHTLC with the same parameters as the original swap
|
|
79
|
-
* 2. Connects to the Arkade server
|
|
80
|
-
* 3. Fetches spendable VTXOs at the VHTLC address
|
|
81
|
-
* 4. Builds an offchain transaction using the refundWithoutReceiver script path
|
|
82
|
-
* 5. Signs and submits the transaction
|
|
83
|
-
* 6. Finalizes the transaction
|
|
84
|
-
*
|
|
85
|
-
* @param params - The refund parameters
|
|
86
|
-
* @returns The refund result with transaction ID and amount
|
|
87
|
-
* @throws Error if the refund fails
|
|
88
|
-
*/
|
|
89
|
-
export async function buildArkadeRefund(params) {
|
|
90
|
-
const { userSecretKey, userPubKey, lendaswapPubKey, arkadeServerPubKey, hashLock, vhtlcAddress, refundLocktime, unilateralClaimDelay, unilateralRefundDelay, unilateralRefundWithoutReceiverDelay, destinationAddress, network, arkadeServerUrl, } = params;
|
|
91
|
-
console.log(`Params ${JSON.stringify(params, null, 2)}`);
|
|
92
|
-
// Parse keys
|
|
93
|
-
const userPkBytes = parseXOnlyPubKey(userPubKey);
|
|
94
|
-
const lendaswapPkBytes = parseXOnlyPubKey(lendaswapPubKey);
|
|
95
|
-
const serverPkBytes = parseXOnlyPubKey(arkadeServerPubKey);
|
|
96
|
-
// Compute preimage hash for VHTLC
|
|
97
|
-
// The API sends us the SHA256 hash (32 bytes) or HASH160 (20 bytes)
|
|
98
|
-
const hashLockBytes = hex.decode(hashLock);
|
|
99
|
-
let preimageHashBytes;
|
|
100
|
-
if (hashLockBytes.length === 32) {
|
|
101
|
-
// the preimage is a SHA256 hash, we need to compute RIPEMD160 of it
|
|
102
|
-
preimageHashBytes = ripemd160(hashLockBytes);
|
|
103
|
-
}
|
|
104
|
-
else if (hashLockBytes.length === 20) {
|
|
105
|
-
// Already HASH160
|
|
106
|
-
preimageHashBytes = hashLockBytes;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
throw new Error(`Invalid hash lock length: expected 20 or 32, got ${hashLockBytes.length}`);
|
|
110
|
-
}
|
|
111
|
-
// Determine Arkade server URL
|
|
112
|
-
const networkName = getNetworkName(network);
|
|
113
|
-
const serverUrl = arkadeServerUrl ?? DEFAULT_ARKADE_URLS[networkName];
|
|
114
|
-
if (!serverUrl) {
|
|
115
|
-
throw new Error(`No Arkade server URL configured for network: ${networkName}`);
|
|
116
|
-
}
|
|
117
|
-
// Create Arkade providers
|
|
118
|
-
const arkProvider = new RestArkProvider(serverUrl);
|
|
119
|
-
const indexerProvider = new RestIndexerProvider(serverUrl);
|
|
120
|
-
// Get server info
|
|
121
|
-
const serverInfo = await arkProvider.getInfo();
|
|
122
|
-
// Construct VHTLC with the same parameters as the original swap
|
|
123
|
-
// For refund: user is the SENDER (refunding), lendaswap is the RECEIVER
|
|
124
|
-
const vhtlc = new VHTLC.Script({
|
|
125
|
-
sender: userPkBytes,
|
|
126
|
-
receiver: lendaswapPkBytes,
|
|
127
|
-
server: serverPkBytes,
|
|
128
|
-
preimageHash: preimageHashBytes,
|
|
129
|
-
refundLocktime: BigInt(refundLocktime),
|
|
130
|
-
unilateralClaimDelay: secondsToTimelock(unilateralClaimDelay),
|
|
131
|
-
unilateralRefundDelay: secondsToTimelock(unilateralRefundDelay),
|
|
132
|
-
unilateralRefundWithoutReceiverDelay: secondsToTimelock(unilateralRefundWithoutReceiverDelay),
|
|
133
|
-
});
|
|
134
|
-
// Get network HRP and verify computed VHTLC address
|
|
135
|
-
const hrp = getNetworkHrp(networkName);
|
|
136
|
-
const computedAddress = vhtlc.address(hrp, serverPkBytes);
|
|
137
|
-
const computedAddressStr = computedAddress.encode();
|
|
138
|
-
// Verify address matches expected
|
|
139
|
-
if (computedAddressStr !== vhtlcAddress) {
|
|
140
|
-
throw new Error(`Computed VHTLC address (${computedAddressStr}) does not match expected (${vhtlcAddress})`);
|
|
141
|
-
}
|
|
142
|
-
// Fetch VTXOs at the VHTLC address
|
|
143
|
-
// We need the pk script to query the indexer
|
|
144
|
-
const vhtlcPkScript = hex.encode(vhtlc.pkScript);
|
|
145
|
-
const { vtxos } = await indexerProvider.getVtxos({
|
|
146
|
-
scripts: [vhtlcPkScript],
|
|
147
|
-
spendableOnly: true,
|
|
148
|
-
});
|
|
149
|
-
if (vtxos.length === 0) {
|
|
150
|
-
const { vtxos: updated } = await indexerProvider.getVtxos({
|
|
151
|
-
scripts: [vhtlcPkScript],
|
|
152
|
-
});
|
|
153
|
-
console.log(`Updated ${JSON.stringify(updated, null, 2)}`);
|
|
154
|
-
throw new Error("No spendable VTXOs found at the VHTLC address");
|
|
155
|
-
}
|
|
156
|
-
// Calculate total amount (vtxos have value as number)
|
|
157
|
-
const totalAmount = vtxos.reduce((acc, v) => acc + BigInt(v.value), 0n);
|
|
158
|
-
if (totalAmount === 0n) {
|
|
159
|
-
throw new Error("Total VTXO amount is zero");
|
|
160
|
-
}
|
|
161
|
-
// Get the refundWithoutReceiver TapLeafScript
|
|
162
|
-
const refundLeafScript = vhtlc.refundWithoutReceiver();
|
|
163
|
-
// Encode the VHTLC tap tree
|
|
164
|
-
const tapTree = vhtlc.encode();
|
|
165
|
-
// Decode the server's checkpoint tapscript from the server info
|
|
166
|
-
const checkpointTapscript = CSVMultisigTapscript.decode(hex.decode(serverInfo.checkpointTapscript));
|
|
167
|
-
// Build inputs for offchain transaction
|
|
168
|
-
const inputs = vtxos.map((v) => ({
|
|
169
|
-
txid: v.txid,
|
|
170
|
-
vout: v.vout,
|
|
171
|
-
value: v.value,
|
|
172
|
-
tapTree: tapTree,
|
|
173
|
-
tapLeafScript: refundLeafScript,
|
|
174
|
-
}));
|
|
175
|
-
// Parse destination address to get the output script
|
|
176
|
-
// The destination should be an Arkade address that we can decode
|
|
177
|
-
const { ArkAddress } = await import("@arkade-os/sdk");
|
|
178
|
-
const destAddr = ArkAddress.decode(destinationAddress);
|
|
179
|
-
const destPkScript = destAddr.pkScript;
|
|
180
|
-
// Build outputs
|
|
181
|
-
const outputs = [
|
|
182
|
-
{
|
|
183
|
-
script: destPkScript,
|
|
184
|
-
amount: totalAmount,
|
|
185
|
-
},
|
|
186
|
-
];
|
|
187
|
-
const destinationAddressPPkScript = hex.encode(destPkScript);
|
|
188
|
-
console.log(`Refunding ${totalAmount} to ${destinationAddress} with script ${destinationAddressPPkScript}`);
|
|
189
|
-
// Build the offchain transaction
|
|
190
|
-
const { arkTx, checkpoints } = buildOffchainTx(inputs, outputs, checkpointTapscript);
|
|
191
|
-
// Create signer from user's secret key
|
|
192
|
-
const signer = SingleKey.fromHex(userSecretKey);
|
|
193
|
-
// Sign the ark transaction
|
|
194
|
-
const signedArkTx = await signer.sign(arkTx);
|
|
195
|
-
// Submit the transaction to the Arkade server
|
|
196
|
-
const signedArkTxBase64 = base64.encode(signedArkTx.toPSBT());
|
|
197
|
-
const { arkTxid, signedCheckpointTxs } = await arkProvider.submitTx(signedArkTxBase64, checkpoints.map((cp) => base64.encode(cp.toPSBT())));
|
|
198
|
-
const finalCheckpoints = await Promise.all(signedCheckpointTxs.map(async (c) => {
|
|
199
|
-
const tx = Transaction.fromPSBT(base64.decode(c));
|
|
200
|
-
const signedCheckpoint = await signer.sign(tx);
|
|
201
|
-
return base64.encode(signedCheckpoint.toPSBT());
|
|
202
|
-
}));
|
|
203
|
-
console.log(`Finalized tx done`);
|
|
204
|
-
// Finalize the transaction
|
|
205
|
-
await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
|
|
206
|
-
console.log(`Finalized tx submitted`, arkTxid);
|
|
207
|
-
return {
|
|
208
|
-
txId: arkTxid,
|
|
209
|
-
refundAmount: totalAmount,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
//# sourceMappingURL=arkade.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arkade.js","sourceRoot":"","sources":["../../../src/refund/arkade.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAGL,eAAe,EACf,oBAAoB,EAGpB,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,KAAK,GACN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAE1C,2CAA2C;AAC3C,MAAM,mBAAmB,GAA2B;IAClD,OAAO,EAAE,yBAAyB;IAClC,OAAO,EAAE,yBAAyB;IAClC,MAAM,EAAE,6BAA6B;IACrC,SAAS,EAAE,6BAA6B;CACzC,CAAC;AAwCF;;GAEG;AACH,SAAS,cAAc,CAAC,OAAe;IACrC,QAAQ,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QAC9B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CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CACH,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAEjC,2BAA2B;IAC3B,MAAM,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IAE/C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,YAAY,EAAE,WAAW;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Refund module for Lendaswap swaps.
|
|
3
|
-
*
|
|
4
|
-
* Provides refund transaction building for different swap types:
|
|
5
|
-
* - On-chain Bitcoin HTLC refunds (BTC → EVM swaps)
|
|
6
|
-
* - Arkade off-chain VHTLC refunds (Arkade → EVM swaps)
|
|
7
|
-
*/
|
|
8
|
-
export { type ArkadeRefundParams, type ArkadeRefundResult, buildArkadeRefund, } from "./arkade.js";
|
|
9
|
-
export { type BitcoinNetwork, buildOnchainClaimTransaction, buildOnchainRefundTransaction, computeHash160, type OnchainClaimParams, type OnchainClaimResult, type OnchainRefundParams, type OnchainRefundResult, verifyHtlcAddress, } from "./onchain.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/refund/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,cAAc,EACnB,4BAA4B,EAC5B,6BAA6B,EAC7B,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,iBAAiB,GAClB,MAAM,cAAc,CAAC"}
|
package/dist/src/refund/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Refund module for Lendaswap swaps.
|
|
3
|
-
*
|
|
4
|
-
* Provides refund transaction building for different swap types:
|
|
5
|
-
* - On-chain Bitcoin HTLC refunds (BTC → EVM swaps)
|
|
6
|
-
* - Arkade off-chain VHTLC refunds (Arkade → EVM swaps)
|
|
7
|
-
*/
|
|
8
|
-
export { buildArkadeRefund, } from "./arkade.js";
|
|
9
|
-
export { buildOnchainClaimTransaction, buildOnchainRefundTransaction, computeHash160, verifyHtlcAddress, } from "./onchain.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/refund/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAGL,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,4BAA4B,EAC5B,6BAA6B,EAC7B,cAAc,EAKd,iBAAiB,GAClB,MAAM,cAAc,CAAC"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* On-chain Bitcoin HTLC refund implementation.
|
|
3
|
-
*
|
|
4
|
-
* This module provides Taproot HTLC refund transaction building for BTC → EVM swaps
|
|
5
|
-
* where users lock on-chain Bitcoin. If the swap times out, users can reclaim
|
|
6
|
-
* their funds using this refund logic.
|
|
7
|
-
*
|
|
8
|
-
* The HTLC uses a Taproot output with:
|
|
9
|
-
* - Unspendable key spend (NUMS internal key)
|
|
10
|
-
* - Hashlock script path: server claims with preimage
|
|
11
|
-
* - Timelock script path: user refunds after locktime
|
|
12
|
-
*/
|
|
13
|
-
/** Bitcoin network type */
|
|
14
|
-
export type BitcoinNetwork = "mainnet" | "testnet" | "signet" | "regtest";
|
|
15
|
-
/** Parameters needed to build a claim transaction for an on-chain Taproot HTLC */
|
|
16
|
-
export interface OnchainClaimParams {
|
|
17
|
-
/** The funding transaction ID (hex, no 0x prefix) */
|
|
18
|
-
fundingTxId: string;
|
|
19
|
-
/** The output index in the funding transaction */
|
|
20
|
-
fundingVout: number;
|
|
21
|
-
/** Amount locked in the HTLC in satoshis */
|
|
22
|
-
htlcAmount: bigint;
|
|
23
|
-
/** Hash lock (20-byte hex, RIPEMD160(SHA256(secret))) */
|
|
24
|
-
hashLock: string;
|
|
25
|
-
/** User's x-only public key (32-byte hex) — the claimer */
|
|
26
|
-
userClaimPubKey: string;
|
|
27
|
-
/** Server's x-only public key (32-byte hex) — the refunder */
|
|
28
|
-
serverRefundPubKey: string;
|
|
29
|
-
/** User's secret key (32-byte hex) for signing */
|
|
30
|
-
userSecretKey: string;
|
|
31
|
-
/** The preimage (32-byte hex) that hashes to the hash lock */
|
|
32
|
-
preimage: string;
|
|
33
|
-
/** Refund locktime (unix timestamp) — needed to reconstruct the HTLC */
|
|
34
|
-
refundLocktime: number;
|
|
35
|
-
/** Destination address to receive claimed funds */
|
|
36
|
-
destinationAddress: string;
|
|
37
|
-
/** Fee rate in satoshis per virtual byte */
|
|
38
|
-
feeRateSatPerVb: number;
|
|
39
|
-
/** Bitcoin network */
|
|
40
|
-
network: BitcoinNetwork;
|
|
41
|
-
}
|
|
42
|
-
/** Result of building a claim transaction */
|
|
43
|
-
export interface OnchainClaimResult {
|
|
44
|
-
/** The signed transaction hex (ready to broadcast) */
|
|
45
|
-
txHex: string;
|
|
46
|
-
/** Transaction ID (hash) */
|
|
47
|
-
txId: string;
|
|
48
|
-
/** Amount being claimed (after fees) */
|
|
49
|
-
claimAmount: bigint;
|
|
50
|
-
/** Fee paid in satoshis */
|
|
51
|
-
fee: bigint;
|
|
52
|
-
/** The HTLC address that funds are being claimed from */
|
|
53
|
-
htlcAddress: string;
|
|
54
|
-
}
|
|
55
|
-
/** Parameters needed to build a refund transaction */
|
|
56
|
-
export interface OnchainRefundParams {
|
|
57
|
-
/** The funding transaction ID (hex, no 0x prefix) */
|
|
58
|
-
fundingTxId: string;
|
|
59
|
-
/** The output index in the funding transaction (usually 0) */
|
|
60
|
-
fundingVout: number;
|
|
61
|
-
/** Amount locked in the HTLC in satoshis */
|
|
62
|
-
htlcAmount: bigint;
|
|
63
|
-
/** Hash lock (20-byte hex, RIPEMD160(SHA256(secret))) */
|
|
64
|
-
hashLock: string;
|
|
65
|
-
/** Server's x-only public key (32-byte hex) */
|
|
66
|
-
serverPubKey: string;
|
|
67
|
-
/** User's x-only public key (32-byte hex) */
|
|
68
|
-
userPubKey: string;
|
|
69
|
-
/** User's secret key (32-byte hex) for signing */
|
|
70
|
-
userSecretKey: string;
|
|
71
|
-
/** Refund locktime (unix timestamp) */
|
|
72
|
-
refundLocktime: number;
|
|
73
|
-
/** Destination address to receive refunded funds */
|
|
74
|
-
destinationAddress: string;
|
|
75
|
-
/** Fee rate in satoshis per virtual byte */
|
|
76
|
-
feeRateSatPerVb: number;
|
|
77
|
-
/** Bitcoin network */
|
|
78
|
-
network: BitcoinNetwork;
|
|
79
|
-
}
|
|
80
|
-
/** Result of building a refund transaction */
|
|
81
|
-
export interface OnchainRefundResult {
|
|
82
|
-
/** The signed transaction hex (ready to broadcast) */
|
|
83
|
-
txHex: string;
|
|
84
|
-
/** Transaction ID (hash) */
|
|
85
|
-
txId: string;
|
|
86
|
-
/** Amount being refunded (after fees) */
|
|
87
|
-
refundAmount: bigint;
|
|
88
|
-
/** Fee paid in satoshis */
|
|
89
|
-
fee: bigint;
|
|
90
|
-
/** The HTLC address that funds are being refunded from */
|
|
91
|
-
htlcAddress: string;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Compute HASH160 (RIPEMD160(SHA256(data))).
|
|
95
|
-
*/
|
|
96
|
-
export declare function computeHash160(data: Uint8Array): Uint8Array;
|
|
97
|
-
/**
|
|
98
|
-
* Build and sign a claim transaction for an on-chain Bitcoin Taproot HTLC.
|
|
99
|
-
*
|
|
100
|
-
* This creates a transaction that spends from the HTLC using the hashlock
|
|
101
|
-
* script path by providing the preimage and a valid signature.
|
|
102
|
-
*
|
|
103
|
-
* Used for EVM-to-Bitcoin swaps where the user claims BTC after the server
|
|
104
|
-
* has funded the on-chain HTLC.
|
|
105
|
-
*
|
|
106
|
-
* @param params - The claim parameters
|
|
107
|
-
* @returns The signed transaction and related info
|
|
108
|
-
* @throws Error if the transaction cannot be built
|
|
109
|
-
*/
|
|
110
|
-
export declare function buildOnchainClaimTransaction(params: OnchainClaimParams): OnchainClaimResult;
|
|
111
|
-
/**
|
|
112
|
-
* Build and sign a refund transaction for an on-chain Bitcoin HTLC.
|
|
113
|
-
*
|
|
114
|
-
* This creates a transaction that spends from the HTLC using the timelock
|
|
115
|
-
* script path after the refund locktime has passed.
|
|
116
|
-
*
|
|
117
|
-
* @param params - The refund parameters
|
|
118
|
-
* @returns The signed transaction and related info
|
|
119
|
-
* @throws Error if the transaction cannot be built
|
|
120
|
-
*/
|
|
121
|
-
export declare function buildOnchainRefundTransaction(params: OnchainRefundParams): OnchainRefundResult;
|
|
122
|
-
/**
|
|
123
|
-
* Verify that a Taproot address matches the expected HTLC parameters.
|
|
124
|
-
*
|
|
125
|
-
* This is useful to confirm the HTLC address returned by the server
|
|
126
|
-
* matches what we expect based on the swap parameters.
|
|
127
|
-
*
|
|
128
|
-
* @param expectedAddress - The address to verify
|
|
129
|
-
* @param hashLock - Hash lock (20-byte hex)
|
|
130
|
-
* @param serverPubKey - Server's x-only public key (32-byte hex)
|
|
131
|
-
* @param userPubKey - User's x-only public key (32-byte hex)
|
|
132
|
-
* @param refundLocktime - Refund locktime (unix timestamp)
|
|
133
|
-
* @param network - Bitcoin network
|
|
134
|
-
* @returns true if the address matches, false otherwise
|
|
135
|
-
*/
|
|
136
|
-
export declare function verifyHtlcAddress(expectedAddress: string, hashLock: string, serverPubKey: string, userPubKey: string, refundLocktime: number, network: BitcoinNetwork): boolean;
|
|
137
|
-
//# sourceMappingURL=onchain.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onchain.d.ts","sourceRoot":"","sources":["../../../src/refund/onchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1E,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,eAAe,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,6CAA6C;AAC7C,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,8D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