@lifi/sdk-provider-bitcoin 4.0.0-alpha.21 → 4.0.0-alpha.23
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/cjs/BitcoinProvider.d.ts +7 -2
- package/dist/cjs/BitcoinProvider.js +31 -34
- package/dist/cjs/BitcoinProvider.js.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.js +23 -0
- package/dist/cjs/actions/getBitcoinBalance.d.ts +7 -2
- package/dist/cjs/actions/getBitcoinBalance.js +17 -24
- package/dist/cjs/actions/getBitcoinBalance.js.map +1 -1
- package/dist/cjs/actions/resolveBitcoinAddress.d.ts +5 -1
- package/dist/cjs/actions/resolveBitcoinAddress.js +6 -4
- package/dist/cjs/actions/resolveBitcoinAddress.js.map +1 -1
- package/dist/cjs/client/publicClient.d.ts +15 -4
- package/dist/cjs/client/publicClient.js +39 -42
- package/dist/cjs/client/publicClient.js.map +1 -1
- package/dist/cjs/core/BitcoinStepExecutor.d.ts +16 -12
- package/dist/cjs/core/BitcoinStepExecutor.js +46 -51
- package/dist/cjs/core/BitcoinStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.d.ts +9 -4
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js +73 -99
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.d.ts +9 -4
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js +37 -43
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/errors/parseBitcoinErrors.d.ts +7 -2
- package/dist/cjs/errors/parseBitcoinErrors.js +18 -26
- package/dist/cjs/errors/parseBitcoinErrors.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +5 -8
- package/dist/cjs/types.d.ts +17 -12
- package/dist/cjs/types.js +8 -5
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/generateRedeemScript.d.ts +10 -1
- package/dist/cjs/utils/generateRedeemScript.js +12 -5
- package/dist/cjs/utils/generateRedeemScript.js.map +1 -1
- package/dist/cjs/utils/isPsbtFinalized.d.ts +7 -2
- package/dist/cjs/utils/isPsbtFinalized.js +11 -10
- package/dist/cjs/utils/isPsbtFinalized.js.map +1 -1
- package/dist/cjs/utils/toBigmiChainId.d.ts +8 -3
- package/dist/cjs/utils/toBigmiChainId.js +11 -11
- package/dist/cjs/utils/toBigmiChainId.js.map +1 -1
- package/dist/cjs/utils/toXOnly.d.ts +5 -1
- package/dist/cjs/utils/toXOnly.js +4 -3
- package/dist/cjs/utils/toXOnly.js.map +1 -1
- package/dist/cjs/version.d.ts +6 -2
- package/dist/cjs/version.js +8 -5
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/BitcoinProvider.d.ts +7 -2
- package/dist/esm/BitcoinProvider.d.ts.map +1 -0
- package/dist/esm/BitcoinProvider.js +30 -32
- package/dist/esm/BitcoinProvider.js.map +1 -1
- package/dist/esm/actions/getBitcoinBalance.d.ts +7 -2
- package/dist/esm/actions/getBitcoinBalance.d.ts.map +1 -0
- package/dist/esm/actions/getBitcoinBalance.js +17 -22
- package/dist/esm/actions/getBitcoinBalance.js.map +1 -1
- package/dist/esm/actions/resolveBitcoinAddress.d.ts +5 -1
- package/dist/esm/actions/resolveBitcoinAddress.d.ts.map +1 -0
- package/dist/esm/actions/resolveBitcoinAddress.js +6 -3
- package/dist/esm/actions/resolveBitcoinAddress.js.map +1 -1
- package/dist/esm/client/publicClient.d.ts +14 -9
- package/dist/esm/client/publicClient.d.ts.map +1 -0
- package/dist/esm/client/publicClient.js +38 -46
- package/dist/esm/client/publicClient.js.map +1 -1
- package/dist/esm/core/BitcoinStepExecutor.d.ts +16 -12
- package/dist/esm/core/BitcoinStepExecutor.d.ts.map +1 -0
- package/dist/esm/core/BitcoinStepExecutor.js +45 -50
- package/dist/esm/core/BitcoinStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts +9 -4
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js +71 -105
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts +9 -4
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js +36 -40
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -1
- package/dist/esm/errors/parseBitcoinErrors.d.ts +7 -2
- package/dist/esm/errors/parseBitcoinErrors.d.ts.map +1 -0
- package/dist/esm/errors/parseBitcoinErrors.js +17 -24
- package/dist/esm/errors/parseBitcoinErrors.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +3 -4
- package/dist/esm/package.json +1 -1
- package/dist/esm/types.d.ts +17 -12
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +7 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/generateRedeemScript.d.ts +9 -5
- package/dist/esm/utils/generateRedeemScript.d.ts.map +1 -0
- package/dist/esm/utils/generateRedeemScript.js +10 -8
- package/dist/esm/utils/generateRedeemScript.js.map +1 -1
- package/dist/esm/utils/isPsbtFinalized.d.ts +7 -2
- package/dist/esm/utils/isPsbtFinalized.d.ts.map +1 -0
- package/dist/esm/utils/isPsbtFinalized.js +11 -8
- package/dist/esm/utils/isPsbtFinalized.js.map +1 -1
- package/dist/esm/utils/toBigmiChainId.d.ts +8 -3
- package/dist/esm/utils/toBigmiChainId.d.ts.map +1 -0
- package/dist/esm/utils/toBigmiChainId.js +11 -9
- package/dist/esm/utils/toBigmiChainId.js.map +1 -1
- package/dist/esm/utils/toXOnly.d.ts +5 -1
- package/dist/esm/utils/toXOnly.d.ts.map +1 -0
- package/dist/esm/utils/toXOnly.js +5 -2
- package/dist/esm/utils/toXOnly.js.map +1 -1
- package/dist/esm/version.d.ts +6 -2
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +6 -2
- package/dist/esm/version.js.map +1 -1
- package/package.json +6 -6
- package/src/core/BitcoinStepExecutor.ts +4 -2
- package/src/utils/generateRedeemScript.ts +3 -1
- package/src/utils/toXOnly.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/types/BitcoinProvider.d.ts +0 -3
- package/dist/types/BitcoinProvider.d.ts.map +0 -1
- package/dist/types/actions/getBitcoinBalance.d.ts +0 -3
- package/dist/types/actions/getBitcoinBalance.d.ts.map +0 -1
- package/dist/types/actions/resolveBitcoinAddress.d.ts +0 -2
- package/dist/types/actions/resolveBitcoinAddress.d.ts.map +0 -1
- package/dist/types/client/publicClient.d.ts +0 -11
- package/dist/types/client/publicClient.d.ts.map +0 -1
- package/dist/types/core/BitcoinStepExecutor.d.ts +0 -16
- package/dist/types/core/BitcoinStepExecutor.d.ts.map +0 -1
- package/dist/types/core/tasks/BitcoinSignAndExecuteTask.d.ts +0 -6
- package/dist/types/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +0 -1
- package/dist/types/core/tasks/BitcoinWaitForTransactionTask.d.ts +0 -6
- package/dist/types/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +0 -1
- package/dist/types/errors/parseBitcoinErrors.d.ts +0 -3
- package/dist/types/errors/parseBitcoinErrors.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -16
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils/generateRedeemScript.d.ts +0 -7
- package/dist/types/utils/generateRedeemScript.d.ts.map +0 -1
- package/dist/types/utils/isPsbtFinalized.d.ts +0 -3
- package/dist/types/utils/isPsbtFinalized.d.ts.map +0 -1
- package/dist/types/utils/toBigmiChainId.d.ts +0 -4
- package/dist/types/utils/toBigmiChainId.d.ts.map +0 -1
- package/dist/types/utils/toXOnly.d.ts +0 -2
- package/dist/types/utils/toXOnly.d.ts.map +0 -1
- package/dist/types/version.d.ts +0 -3
- package/dist/types/version.d.ts.map +0 -1
|
@@ -1,101 +1,75 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const signedPsbtHex = await (0, core_1.withTimeout)(() => (0, core_1.signPsbt)(walletClient, {
|
|
74
|
-
psbt: psbt.toHex(),
|
|
75
|
-
inputsToSign: inputsToSign,
|
|
76
|
-
finalize: false,
|
|
77
|
-
}), {
|
|
78
|
-
timeout: 600_000,
|
|
79
|
-
errorInstance: new sdk_1.TransactionError(sdk_1.LiFiErrorCode.TransactionExpired, 'Transaction has expired.'),
|
|
80
|
-
});
|
|
81
|
-
const signedPsbt = bitcoinjs_lib_1.Psbt.fromHex(signedPsbtHex);
|
|
82
|
-
if (!(0, isPsbtFinalized_js_1.isPsbtFinalized)(signedPsbt)) {
|
|
83
|
-
signedPsbt.finalizeAllInputs();
|
|
84
|
-
}
|
|
85
|
-
const txHex = signedPsbt.extractTransaction().toHex();
|
|
86
|
-
const txHash = await publicClient.sendUTXOTransaction({
|
|
87
|
-
hex: txHex,
|
|
88
|
-
});
|
|
89
|
-
statusManager.updateAction(step, action.type, 'PENDING', {
|
|
90
|
-
txHash: txHash,
|
|
91
|
-
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
|
|
92
|
-
txHex,
|
|
93
|
-
signedAt: Date.now(),
|
|
94
|
-
});
|
|
95
|
-
return {
|
|
96
|
-
status: 'COMPLETED',
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
+
const require_utils_generateRedeemScript = require("../../utils/generateRedeemScript.js");
|
|
4
|
+
const require_utils_isPsbtFinalized = require("../../utils/isPsbtFinalized.js");
|
|
5
|
+
const require_utils_toXOnly = require("../../utils/toXOnly.js");
|
|
6
|
+
let _bigmi_core = require("@bigmi/core");
|
|
7
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
8
|
+
let _bitcoinerlab_secp256k1 = require("@bitcoinerlab/secp256k1");
|
|
9
|
+
_bitcoinerlab_secp256k1 = require_runtime.__toESM(_bitcoinerlab_secp256k1);
|
|
10
|
+
let bitcoinjs_lib = require("bitcoinjs-lib");
|
|
11
|
+
//#region src/core/tasks/BitcoinSignAndExecuteTask.ts
|
|
12
|
+
var BitcoinSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
13
|
+
async run(context) {
|
|
14
|
+
const { step, walletClient, statusManager, executionOptions, fromChain, publicClient, checkClient, isBridgeExecution } = context;
|
|
15
|
+
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
16
|
+
if (!action) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
17
|
+
const transactionRequestData = await (0, _lifi_sdk.getTransactionRequestData)(step, executionOptions);
|
|
18
|
+
checkClient(step);
|
|
19
|
+
const psbtHex = transactionRequestData;
|
|
20
|
+
(0, bitcoinjs_lib.initEccLib)(_bitcoinerlab_secp256k1);
|
|
21
|
+
const psbt = bitcoinjs_lib.Psbt.fromHex(psbtHex, { network: bitcoinjs_lib.networks.bitcoin });
|
|
22
|
+
psbt.data.inputs.forEach((input, index) => {
|
|
23
|
+
const addressInfo = (0, _bigmi_core.getAddressInfo)(input.witnessUtxo ? bitcoinjs_lib.address.fromOutputScript(input.witnessUtxo.script, bitcoinjs_lib.networks.bitcoin) : walletClient.account?.address);
|
|
24
|
+
if (addressInfo.type === _bigmi_core.AddressType.p2tr) {
|
|
25
|
+
if (!input.tapInternalKey) {
|
|
26
|
+
const pubKey = walletClient.account?.publicKey;
|
|
27
|
+
if (pubKey) {
|
|
28
|
+
const tapInternalKey = require_utils_toXOnly.toXOnly((0, _bigmi_core.hexToUnit8Array)(pubKey));
|
|
29
|
+
psbt.updateInput(index, { tapInternalKey });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (!input.sighashType) psbt.updateInput(index, { sighashType: 1 });
|
|
33
|
+
}
|
|
34
|
+
if (addressInfo.type === _bigmi_core.AddressType.p2sh) {
|
|
35
|
+
if (!input.redeemScript) {
|
|
36
|
+
const pubKey = walletClient.account?.publicKey;
|
|
37
|
+
if (pubKey) psbt.updateInput(index, { redeemScript: require_utils_generateRedeemScript.generateRedeemScript((0, _bigmi_core.hexToUnit8Array)(pubKey)) });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const inputsToSign = Array.from(psbt.data.inputs.reduce((map, input, index) => {
|
|
42
|
+
const accountAddress = input.witnessUtxo ? bitcoinjs_lib.address.fromOutputScript(input.witnessUtxo.script, bitcoinjs_lib.networks.bitcoin) : walletClient.account?.address;
|
|
43
|
+
if (map.has(accountAddress)) map.get(accountAddress).signingIndexes.push(index);
|
|
44
|
+
else map.set(accountAddress, {
|
|
45
|
+
address: accountAddress,
|
|
46
|
+
sigHash: 1,
|
|
47
|
+
signingIndexes: [index]
|
|
48
|
+
});
|
|
49
|
+
return map;
|
|
50
|
+
}, /* @__PURE__ */ new Map()).values());
|
|
51
|
+
const signedPsbtHex = await (0, _bigmi_core.withTimeout)(() => (0, _bigmi_core.signPsbt)(walletClient, {
|
|
52
|
+
psbt: psbt.toHex(),
|
|
53
|
+
inputsToSign,
|
|
54
|
+
finalize: false
|
|
55
|
+
}), {
|
|
56
|
+
timeout: 6e5,
|
|
57
|
+
errorInstance: new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionExpired, "Transaction has expired.")
|
|
58
|
+
});
|
|
59
|
+
const signedPsbt = bitcoinjs_lib.Psbt.fromHex(signedPsbtHex);
|
|
60
|
+
if (!require_utils_isPsbtFinalized.isPsbtFinalized(signedPsbt)) signedPsbt.finalizeAllInputs();
|
|
61
|
+
const txHex = signedPsbt.extractTransaction().toHex();
|
|
62
|
+
const txHash = await publicClient.sendUTXOTransaction({ hex: txHex });
|
|
63
|
+
statusManager.updateAction(step, action.type, "PENDING", {
|
|
64
|
+
txHash,
|
|
65
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
|
|
66
|
+
txHex,
|
|
67
|
+
signedAt: Date.now()
|
|
68
|
+
});
|
|
69
|
+
return { status: "COMPLETED" };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
100
73
|
exports.BitcoinSignAndExecuteTask = BitcoinSignAndExecuteTask;
|
|
74
|
+
|
|
101
75
|
//# sourceMappingURL=BitcoinSignAndExecuteTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinSignAndExecuteTask.js","
|
|
1
|
+
{"version":3,"file":"BitcoinSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","ecc","Psbt","networks","address","AddressType","toXOnly","generateRedeemScript","isPsbtFinalized"],"sources":["../../../../src/core/tasks/BitcoinSignAndExecuteTask.ts"],"sourcesContent":["import {\n AddressType,\n getAddressInfo,\n hexToUnit8Array,\n signPsbt,\n withTimeout,\n} from '@bigmi/core'\nimport * as ecc from '@bitcoinerlab/secp256k1'\nimport {\n BaseStepExecutionTask,\n getTransactionRequestData,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport { address, initEccLib, networks, Psbt } from 'bitcoinjs-lib'\nimport type { BitcoinStepExecutorContext } from '../../types.js'\nimport { generateRedeemScript } from '../../utils/generateRedeemScript.js'\nimport { isPsbtFinalized } from '../../utils/isPsbtFinalized.js'\nimport { toXOnly } from '../../utils/toXOnly.js'\n\nexport class BitcoinSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: BitcoinStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n walletClient,\n statusManager,\n executionOptions,\n fromChain,\n publicClient,\n checkClient,\n isBridgeExecution,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n const transactionRequestData = await getTransactionRequestData(\n step,\n executionOptions\n )\n\n checkClient(step)\n\n const psbtHex = transactionRequestData\n\n // Initialize ECC library required for Taproot operations\n // https://github.com/bitcoinjs/bitcoinjs-lib?tab=readme-ov-file#using-taproot\n initEccLib(ecc)\n\n const psbt = Psbt.fromHex(psbtHex, { network: networks.bitcoin })\n\n psbt.data.inputs.forEach((input, index) => {\n const accountAddress = input.witnessUtxo\n ? address.fromOutputScript(input.witnessUtxo.script, networks.bitcoin)\n : (walletClient.account?.address as string)\n const addressInfo = getAddressInfo(accountAddress)\n if (addressInfo.type === AddressType.p2tr) {\n // Taproot (P2TR) addresses require specific PSBT fields for proper signing\n\n // tapInternalKey: Required for Taproot key-path spending\n // Most wallets / libraries usually handle this already\n if (!input.tapInternalKey) {\n const pubKey = walletClient.account?.publicKey\n if (pubKey) {\n const tapInternalKey = toXOnly(hexToUnit8Array(pubKey))\n psbt.updateInput(index, {\n tapInternalKey,\n })\n }\n }\n // sighashType: Required by bitcoinjs-lib even though the bitcoin protocol allows defaults\n // check if sighashType is default (0) or not set (undefined)\n if (!input.sighashType) {\n psbt.updateInput(index, {\n sighashType: 1, // Default to Transaction.SIGHASH_ALL - 1\n })\n }\n }\n // redeemScript: Required by Pay-to-Script-Hash (P2SH) addresses for proper spending\n if (addressInfo.type === AddressType.p2sh) {\n if (!input.redeemScript) {\n const pubKey = walletClient.account?.publicKey\n if (pubKey) {\n psbt.updateInput(index, {\n redeemScript: generateRedeemScript(hexToUnit8Array(pubKey)),\n })\n }\n }\n }\n })\n\n const inputsToSign = Array.from(\n psbt.data.inputs\n .reduce((map, input, index) => {\n const accountAddress = input.witnessUtxo\n ? address.fromOutputScript(\n input.witnessUtxo.script,\n networks.bitcoin\n )\n : (walletClient.account?.address as string)\n if (map.has(accountAddress)) {\n map.get(accountAddress)!.signingIndexes.push(index)\n } else {\n map.set(accountAddress, {\n address: accountAddress,\n sigHash: 1, // Default to Transaction.SIGHASH_ALL - 1\n signingIndexes: [index],\n })\n }\n return map\n }, new Map<\n string,\n { address: string; sigHash: number; signingIndexes: number[] }\n >())\n .values()\n )\n\n // We give users 10 minutes to sign the transaction or it should be considered expired\n const signedPsbtHex = await withTimeout(\n () =>\n signPsbt(walletClient, {\n psbt: psbt.toHex(),\n inputsToSign: inputsToSign,\n finalize: false,\n }),\n {\n timeout: 600_000,\n errorInstance: new TransactionError(\n LiFiErrorCode.TransactionExpired,\n 'Transaction has expired.'\n ),\n }\n )\n\n const signedPsbt = Psbt.fromHex(signedPsbtHex)\n\n if (!isPsbtFinalized(signedPsbt)) {\n signedPsbt.finalizeAllInputs()\n }\n\n const txHex = signedPsbt.extractTransaction().toHex()\n\n const txHash = await publicClient.sendUTXOTransaction({\n hex: txHex,\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: txHash,\n txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,\n txHex,\n signedAt: Date.now(),\n })\n\n return {\n status: 'COMPLETED',\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAqBA,IAAa,4BAAb,cAA+CA,UAAAA,sBAAsB;CACnE,MAAM,IAAI,SAA0D;EAClE,MAAM,EACJ,MACA,cACA,eACA,kBACA,WACA,cACA,aACA,sBACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,OACrC;AAED,MAAI,CAAC,OACH,OAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,mDACD;EAGH,MAAM,yBAAyB,OAAA,GAAA,UAAA,2BAC7B,MACA,iBACD;AAED,cAAY,KAAK;EAEjB,MAAM,UAAU;AAIhB,GAAA,GAAA,cAAA,YAAWC,wBAAI;EAEf,MAAM,OAAOC,cAAAA,KAAK,QAAQ,SAAS,EAAE,SAASC,cAAAA,SAAS,SAAS,CAAC;AAEjE,OAAK,KAAK,OAAO,SAAS,OAAO,UAAU;GAIzC,MAAM,eAAA,GAAA,YAAA,gBAHiB,MAAM,cACzBC,cAAAA,QAAQ,iBAAiB,MAAM,YAAY,QAAQD,cAAAA,SAAS,QAAQ,GACnE,aAAa,SAAS,QACuB;AAClD,OAAI,YAAY,SAASE,YAAAA,YAAY,MAAM;AAKzC,QAAI,CAAC,MAAM,gBAAgB;KACzB,MAAM,SAAS,aAAa,SAAS;AACrC,SAAI,QAAQ;MACV,MAAM,iBAAiBC,sBAAAA,SAAAA,GAAAA,YAAAA,iBAAwB,OAAO,CAAC;AACvD,WAAK,YAAY,OAAO,EACtB,gBACD,CAAC;;;AAKN,QAAI,CAAC,MAAM,YACT,MAAK,YAAY,OAAO,EACtB,aAAa,GACd,CAAC;;AAIN,OAAI,YAAY,SAASD,YAAAA,YAAY;QAC/B,CAAC,MAAM,cAAc;KACvB,MAAM,SAAS,aAAa,SAAS;AACrC,SAAI,OACF,MAAK,YAAY,OAAO,EACtB,cAAcE,mCAAAA,sBAAAA,GAAAA,YAAAA,iBAAqC,OAAO,CAAC,EAC5D,CAAC;;;IAIR;EAEF,MAAM,eAAe,MAAM,KACzB,KAAK,KAAK,OACP,QAAQ,KAAK,OAAO,UAAU;GAC7B,MAAM,iBAAiB,MAAM,cACzBH,cAAAA,QAAQ,iBACN,MAAM,YAAY,QAClBD,cAAAA,SAAS,QACV,GACA,aAAa,SAAS;AAC3B,OAAI,IAAI,IAAI,eAAe,CACzB,KAAI,IAAI,eAAe,CAAE,eAAe,KAAK,MAAM;OAEnD,KAAI,IAAI,gBAAgB;IACtB,SAAS;IACT,SAAS;IACT,gBAAgB,CAAC,MAAM;IACxB,CAAC;AAEJ,UAAO;qBACN,IAAI,KAGJ,CAAC,CACH,QAAQ,CACZ;EAGD,MAAM,gBAAgB,OAAA,GAAA,YAAA,oBAAA,GAAA,YAAA,UAET,cAAc;GACrB,MAAM,KAAK,OAAO;GACJ;GACd,UAAU;GACX,CAAC,EACJ;GACE,SAAS;GACT,eAAe,IAAIJ,UAAAA,iBACjBC,UAAAA,cAAc,oBACd,2BACD;GACF,CACF;EAED,MAAM,aAAaE,cAAAA,KAAK,QAAQ,cAAc;AAE9C,MAAI,CAACM,8BAAAA,gBAAgB,WAAW,CAC9B,YAAW,mBAAmB;EAGhC,MAAM,QAAQ,WAAW,oBAAoB,CAAC,OAAO;EAErD,MAAM,SAAS,MAAM,aAAa,oBAAoB,EACpD,KAAK,OACN,CAAC;AAEF,gBAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GAC/C;GACR,QAAQ,GAAG,UAAU,SAAS,kBAAkB,GAAG,KAAK;GACxD;GACA,UAAU,KAAK,KAAK;GACrB,CAAC;AAEF,SAAO,EACL,QAAQ,aACT"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { BitcoinStepExecutorContext } from "../../types.js";
|
|
2
|
+
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
|
+
|
|
4
|
+
//#region src/core/tasks/BitcoinWaitForTransactionTask.d.ts
|
|
5
|
+
declare class BitcoinWaitForTransactionTask extends BaseStepExecutionTask {
|
|
6
|
+
run(context: BitcoinStepExecutorContext): Promise<TaskResult>;
|
|
5
7
|
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { BitcoinWaitForTransactionTask };
|
|
10
|
+
//# sourceMappingURL=BitcoinWaitForTransactionTask.d.ts.map
|
|
@@ -1,45 +1,39 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
if (isBridgeExecution) {
|
|
39
|
-
statusManager.updateAction(step, action.type, 'DONE');
|
|
40
|
-
}
|
|
41
|
-
return { status: 'COMPLETED' };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
+
let _bigmi_core = require("@bigmi/core");
|
|
4
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
5
|
+
//#region src/core/tasks/BitcoinWaitForTransactionTask.ts
|
|
6
|
+
var BitcoinWaitForTransactionTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
7
|
+
async run(context) {
|
|
8
|
+
const { step, statusManager, fromChain, isBridgeExecution, walletClient, publicClient, checkClient } = context;
|
|
9
|
+
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
10
|
+
const txHex = action?.txHex;
|
|
11
|
+
const txHash = action?.txHash;
|
|
12
|
+
if (!txHash || !txHex) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Transaction hash or hex is not set.");
|
|
13
|
+
checkClient(step);
|
|
14
|
+
let replacementReason;
|
|
15
|
+
const transaction = await (0, _bigmi_core.waitForTransaction)(publicClient, {
|
|
16
|
+
txId: txHash,
|
|
17
|
+
txHex,
|
|
18
|
+
senderAddress: walletClient.account?.address,
|
|
19
|
+
onReplaced: (response) => {
|
|
20
|
+
replacementReason = response.reason;
|
|
21
|
+
statusManager.updateAction(step, action.type, "PENDING", {
|
|
22
|
+
txHash: response.transaction.txid,
|
|
23
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.txid}`
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (replacementReason === "cancelled") throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionCanceled, "User canceled transaction.");
|
|
28
|
+
if (transaction.txid !== txHash) statusManager.updateAction(step, action.type, "PENDING", {
|
|
29
|
+
txHash: transaction.txid,
|
|
30
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transaction.txid}`
|
|
31
|
+
});
|
|
32
|
+
if (isBridgeExecution) statusManager.updateAction(step, action.type, "DONE");
|
|
33
|
+
return { status: "COMPLETED" };
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
44
37
|
exports.BitcoinWaitForTransactionTask = BitcoinWaitForTransactionTask;
|
|
38
|
+
|
|
45
39
|
//# sourceMappingURL=BitcoinWaitForTransactionTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinWaitForTransactionTask.js","
|
|
1
|
+
{"version":3,"file":"BitcoinWaitForTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode"],"sources":["../../../../src/core/tasks/BitcoinWaitForTransactionTask.ts"],"sourcesContent":["import type { ReplacementReason } from '@bigmi/core'\nimport { waitForTransaction } from '@bigmi/core'\nimport {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { BitcoinStepExecutorContext } from '../../types.js'\n\nexport class BitcoinWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: BitcoinStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n statusManager,\n fromChain,\n isBridgeExecution,\n walletClient,\n publicClient,\n checkClient,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n const txHex = action?.txHex\n const txHash = action?.txHash\n\n if (!txHash || !txHex) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction hash or hex is not set.'\n )\n }\n\n checkClient(step)\n\n let replacementReason: ReplacementReason | undefined\n const transaction = await waitForTransaction(publicClient, {\n txId: txHash,\n txHex,\n senderAddress: walletClient.account?.address,\n onReplaced: (response) => {\n replacementReason = response.reason\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: response.transaction.txid,\n txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.txid}`,\n })\n },\n })\n\n if (replacementReason === 'cancelled') {\n throw new TransactionError(\n LiFiErrorCode.TransactionCanceled,\n 'User canceled transaction.'\n )\n }\n\n if (transaction.txid !== txHash) {\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: transaction.txid,\n txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transaction.txid}`,\n })\n }\n\n if (isBridgeExecution) {\n statusManager.updateAction(step, action.type, 'DONE')\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;;;;AAUA,IAAa,gCAAb,cAAmDA,UAAAA,sBAAsB;CACvE,MAAM,IAAI,SAA0D;EAClE,MAAM,EACJ,MACA,eACA,WACA,mBACA,cACA,cACA,gBACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,OACrC;EAED,MAAM,QAAQ,QAAQ;EACtB,MAAM,SAAS,QAAQ;AAEvB,MAAI,CAAC,UAAU,CAAC,MACd,OAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,qEACD;AAGH,cAAY,KAAK;EAEjB,IAAI;EACJ,MAAM,cAAc,OAAA,GAAA,YAAA,oBAAyB,cAAc;GACzD,MAAM;GACN;GACA,eAAe,aAAa,SAAS;GACrC,aAAa,aAAa;AACxB,wBAAoB,SAAS;AAC7B,kBAAc,aAAa,MAAM,OAAO,MAAM,WAAW;KACvD,QAAQ,SAAS,YAAY;KAC7B,QAAQ,GAAG,UAAU,SAAS,kBAAkB,GAAG,KAAK,SAAS,YAAY;KAC9E,CAAC;;GAEL,CAAC;AAEF,MAAI,sBAAsB,YACxB,OAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,qBACd,6BACD;AAGH,MAAI,YAAY,SAAS,OACvB,eAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GACvD,QAAQ,YAAY;GACpB,QAAQ,GAAG,UAAU,SAAS,kBAAkB,GAAG,KAAK,YAAY;GACrE,CAAC;AAGJ,MAAI,kBACF,eAAc,aAAa,MAAM,OAAO,MAAM,OAAO;AAGvD,SAAO,EAAE,QAAQ,aAAa"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ExecutionAction, LiFiStep, SDKError } from "@lifi/sdk";
|
|
2
|
+
|
|
3
|
+
//#region src/errors/parseBitcoinErrors.d.ts
|
|
4
|
+
declare const parseBitcoinErrors: (e: Error, step?: LiFiStep, action?: ExecutionAction) => Promise<SDKError>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { parseBitcoinErrors };
|
|
7
|
+
//# sourceMappingURL=parseBitcoinErrors.d.ts.map
|
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../_virtual/_rolldown/runtime.js");
|
|
3
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
4
|
+
//#region src/errors/parseBitcoinErrors.ts
|
|
5
5
|
const parseBitcoinErrors = async (e, step, action) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return new sdk_1.SDKError(baseError, step, action);
|
|
6
|
+
if (e instanceof _lifi_sdk.SDKError) {
|
|
7
|
+
e.step = e.step ?? step;
|
|
8
|
+
e.action = e.action ?? action;
|
|
9
|
+
return e;
|
|
10
|
+
}
|
|
11
|
+
return new _lifi_sdk.SDKError(handleSpecificErrors(e), step, action);
|
|
13
12
|
};
|
|
14
|
-
exports.parseBitcoinErrors = parseBitcoinErrors;
|
|
15
13
|
const handleSpecificErrors = (e) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return new sdk_1.TransactionError(sdk_1.LiFiErrorCode.SignatureRejected, e.message, e);
|
|
22
|
-
}
|
|
23
|
-
if (e.code === -5 || e.code === -32700 || e.code === -32064) {
|
|
24
|
-
return new sdk_1.TransactionError(sdk_1.LiFiErrorCode.NotFound, e.message, e);
|
|
25
|
-
}
|
|
26
|
-
if (e instanceof sdk_1.BaseError) {
|
|
27
|
-
return e;
|
|
28
|
-
}
|
|
29
|
-
return new sdk_1.UnknownError(e.message || sdk_1.ErrorMessage.UnknownError, e);
|
|
14
|
+
if (e.details?.includes?.("conflict") || e.cause?.message?.includes?.("conflict")) return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionConflict, "Your transaction conflicts with another transaction already in the mempool. One or more inputs have been spent by another transaction.", e);
|
|
15
|
+
if (e.code === 4001 || e.code === -32e3 || e.cause?.includes?.("rejected")) return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.SignatureRejected, e.message, e);
|
|
16
|
+
if (e.code === -5 || e.code === -32700 || e.code === -32064) return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.NotFound, e.message, e);
|
|
17
|
+
if (e instanceof _lifi_sdk.BaseError) return e;
|
|
18
|
+
return new _lifi_sdk.UnknownError(e.message || _lifi_sdk.ErrorMessage.UnknownError, e);
|
|
30
19
|
};
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.parseBitcoinErrors = parseBitcoinErrors;
|
|
22
|
+
|
|
31
23
|
//# sourceMappingURL=parseBitcoinErrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBitcoinErrors.js","
|
|
1
|
+
{"version":3,"file":"parseBitcoinErrors.js","names":["SDKError","TransactionError","LiFiErrorCode","BaseError","UnknownError","ErrorMessage"],"sources":["../../../src/errors/parseBitcoinErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseBitcoinErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = (e: any) => {\n // txn-mempool-conflict\n if (\n e.details?.includes?.('conflict') ||\n e.cause?.message?.includes?.('conflict')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionConflict,\n 'Your transaction conflicts with another transaction already in the mempool. One or more inputs have been spent by another transaction.',\n e\n )\n }\n if (e.code === 4001 || e.code === -32000 || e.cause?.includes?.('rejected')) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n if (e.code === -5 || e.code === -32700 || e.code === -32064) {\n return new TransactionError(LiFiErrorCode.NotFound, e.message, e)\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;;;AAWA,MAAa,qBAAqB,OAChC,GACA,MACA,WACsB;AACtB,KAAI,aAAaA,UAAAA,UAAU;AACzB,IAAE,OAAO,EAAE,QAAQ;AACnB,IAAE,SAAS,EAAE,UAAU;AACvB,SAAO;;AAKT,QAAO,IAAIA,UAAAA,SAFO,qBAAqB,EAAE,EAEV,MAAM,OAAO;;AAG9C,MAAM,wBAAwB,MAAW;AAEvC,KACE,EAAE,SAAS,WAAW,WAAW,IACjC,EAAE,OAAO,SAAS,WAAW,WAAW,CAExC,QAAO,IAAIC,UAAAA,iBACTC,UAAAA,cAAc,qBACd,0IACA,EACD;AAEH,KAAI,EAAE,SAAS,QAAQ,EAAE,SAAS,SAAU,EAAE,OAAO,WAAW,WAAW,CACzE,QAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,mBAAmB,EAAE,SAAS,EAAE;AAE5E,KAAI,EAAE,SAAS,MAAM,EAAE,SAAS,UAAU,EAAE,SAAS,OACnD,QAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,UAAU,EAAE,SAAS,EAAE;AAGnE,KAAI,aAAaC,UAAAA,UACf,QAAO;AAGT,QAAO,IAAIC,UAAAA,aAAa,EAAE,WAAWC,UAAAA,aAAa,cAAc,EAAE"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { isBitcoinProvider }
|
|
1
|
+
import { BitcoinProviderOptions, BitcoinSDKProvider, isBitcoinProvider } from "./types.js";
|
|
2
|
+
import { BitcoinProvider } from "./BitcoinProvider.js";
|
|
3
|
+
export { BitcoinProvider, type BitcoinProviderOptions, type BitcoinSDKProvider, isBitcoinProvider };
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var types_js_1 = require("./types.js");
|
|
7
|
-
Object.defineProperty(exports, "isBitcoinProvider", { enumerable: true, get: function () { return types_js_1.isBitcoinProvider; } });
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_BitcoinProvider = require("./BitcoinProvider.js");
|
|
3
|
+
const require_types = require("./types.js");
|
|
4
|
+
exports.BitcoinProvider = require_BitcoinProvider.BitcoinProvider;
|
|
5
|
+
exports.isBitcoinProvider = require_types.isBitcoinProvider;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { PublicClient } from "./client/publicClient.js";
|
|
2
|
+
import { Client } from "@bigmi/core";
|
|
3
|
+
import { LiFiStepExtended, SDKProvider, StepExecutorContext } from "@lifi/sdk";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
interface BitcoinProviderOptions {
|
|
7
|
+
getWalletClient?: () => Promise<Client>;
|
|
6
8
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
interface BitcoinStepExecutorContext extends StepExecutorContext {
|
|
10
|
+
walletClient: Client;
|
|
11
|
+
publicClient: PublicClient;
|
|
12
|
+
checkClient: (step: LiFiStepExtended) => void;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
interface BitcoinSDKProvider extends SDKProvider {
|
|
15
|
+
setOptions(options: BitcoinProviderOptions): void;
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
declare function isBitcoinProvider(provider: SDKProvider): provider is BitcoinSDKProvider;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BitcoinProviderOptions, BitcoinSDKProvider, BitcoinStepExecutorContext, isBitcoinProvider };
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/cjs/types.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./_virtual/_rolldown/runtime.js");
|
|
3
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
4
|
+
//#region src/types.ts
|
|
5
5
|
function isBitcoinProvider(provider) {
|
|
6
|
-
|
|
6
|
+
return provider.type === _lifi_sdk.ChainType.UTXO;
|
|
7
7
|
}
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.isBitcoinProvider = isBitcoinProvider;
|
|
10
|
+
|
|
8
11
|
//# sourceMappingURL=types.js.map
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","
|
|
1
|
+
{"version":3,"file":"types.js","names":["ChainType"],"sources":["../../src/types.ts"],"sourcesContent":["import type { Client } from '@bigmi/core'\nimport {\n ChainType,\n type LiFiStepExtended,\n type SDKProvider,\n type StepExecutorContext,\n} from '@lifi/sdk'\nimport type { PublicClient } from './client/publicClient.js'\n\nexport interface BitcoinProviderOptions {\n getWalletClient?: () => Promise<Client>\n}\n\nexport interface BitcoinStepExecutorContext extends StepExecutorContext {\n walletClient: Client\n publicClient: PublicClient\n checkClient: (step: LiFiStepExtended) => void\n}\n\nexport interface BitcoinSDKProvider extends SDKProvider {\n setOptions(options: BitcoinProviderOptions): void\n}\n\nexport function isBitcoinProvider(\n provider: SDKProvider\n): provider is BitcoinSDKProvider {\n return provider.type === ChainType.UTXO\n}\n"],"mappings":";;;;AAuBA,SAAgB,kBACd,UACgC;AAChC,QAAO,SAAS,SAASA,UAAAA,UAAU"}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/utils/generateRedeemScript.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generate redeem script for P2SH addresses
|
|
4
|
+
* @param publicKey
|
|
5
|
+
* @returns redeem script
|
|
6
|
+
*/
|
|
7
|
+
declare const generateRedeemScript: (publicKey: Uint8Array) => Uint8Array | undefined;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { generateRedeemScript };
|
|
10
|
+
//# sourceMappingURL=generateRedeemScript.d.ts.map
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../_virtual/_rolldown/runtime.js");
|
|
3
|
+
let bitcoinjs_lib = require("bitcoinjs-lib");
|
|
4
|
+
//#region src/utils/generateRedeemScript.ts
|
|
5
|
+
/**
|
|
6
|
+
* Generate redeem script for P2SH addresses
|
|
7
|
+
* @param publicKey
|
|
8
|
+
* @returns redeem script
|
|
9
|
+
*/
|
|
10
|
+
const generateRedeemScript = (publicKey) => bitcoinjs_lib.payments.p2wpkh({ pubkey: publicKey }).output;
|
|
11
|
+
//#endregion
|
|
6
12
|
exports.generateRedeemScript = generateRedeemScript;
|
|
13
|
+
|
|
7
14
|
//# sourceMappingURL=generateRedeemScript.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRedeemScript.js","
|
|
1
|
+
{"version":3,"file":"generateRedeemScript.js","names":["payments"],"sources":["../../../src/utils/generateRedeemScript.ts"],"sourcesContent":["import { payments } from 'bitcoinjs-lib'\n\n/**\n * Generate redeem script for P2SH addresses\n * @param publicKey\n * @returns redeem script\n */\nexport const generateRedeemScript = (\n publicKey: Uint8Array\n): Uint8Array | undefined =>\n // P2SH addresses are created by hashing the public key and using the result as the script\n payments.p2wpkh({ pubkey: publicKey }).output\n"],"mappings":";;;;;;;;;AAOA,MAAa,wBACX,cAGAA,cAAAA,SAAS,OAAO,EAAE,QAAQ,WAAW,CAAC,CAAC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Psbt } from "bitcoinjs-lib";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/isPsbtFinalized.d.ts
|
|
4
|
+
declare function isPsbtFinalized(psbt: Psbt): boolean;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { isPsbtFinalized };
|
|
7
|
+
//# sourceMappingURL=isPsbtFinalized.d.ts.map
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
exports.isPsbtFinalized = isPsbtFinalized;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/utils/isPsbtFinalized.ts
|
|
4
3
|
function isPsbtFinalized(psbt) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
4
|
+
try {
|
|
5
|
+
psbt.extractTransaction();
|
|
6
|
+
return true;
|
|
7
|
+
} catch (_) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
12
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.isPsbtFinalized = isPsbtFinalized;
|
|
13
|
+
|
|
13
14
|
//# sourceMappingURL=isPsbtFinalized.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPsbtFinalized.js","
|
|
1
|
+
{"version":3,"file":"isPsbtFinalized.js","names":[],"sources":["../../../src/utils/isPsbtFinalized.ts"],"sourcesContent":["import type { Psbt } from 'bitcoinjs-lib'\n\nexport function isPsbtFinalized(psbt: Psbt): boolean {\n try {\n psbt.extractTransaction()\n return true\n } catch (_) {\n return false\n }\n}\n"],"mappings":";;AAEA,SAAgB,gBAAgB,MAAqB;AACnD,KAAI;AACF,OAAK,oBAAoB;AACzB,SAAO;UACA,GAAG;AACV,SAAO"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import { ChainId
|
|
2
|
-
import { ChainId } from
|
|
3
|
-
|
|
1
|
+
import { ChainId } from "@bigmi/core";
|
|
2
|
+
import { ChainId as ChainId$1 } from "@lifi/sdk";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/toBigmiChainId.d.ts
|
|
5
|
+
declare const toBigmiChainId: (chainId: ChainId$1) => ChainId;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { toBigmiChainId };
|
|
8
|
+
//# sourceMappingURL=toBigmiChainId.d.ts.map
|