@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.
Files changed (141) hide show
  1. package/dist/cjs/BitcoinProvider.d.ts +7 -2
  2. package/dist/cjs/BitcoinProvider.js +31 -34
  3. package/dist/cjs/BitcoinProvider.js.map +1 -1
  4. package/dist/cjs/_virtual/_rolldown/runtime.js +23 -0
  5. package/dist/cjs/actions/getBitcoinBalance.d.ts +7 -2
  6. package/dist/cjs/actions/getBitcoinBalance.js +17 -24
  7. package/dist/cjs/actions/getBitcoinBalance.js.map +1 -1
  8. package/dist/cjs/actions/resolveBitcoinAddress.d.ts +5 -1
  9. package/dist/cjs/actions/resolveBitcoinAddress.js +6 -4
  10. package/dist/cjs/actions/resolveBitcoinAddress.js.map +1 -1
  11. package/dist/cjs/client/publicClient.d.ts +15 -4
  12. package/dist/cjs/client/publicClient.js +39 -42
  13. package/dist/cjs/client/publicClient.js.map +1 -1
  14. package/dist/cjs/core/BitcoinStepExecutor.d.ts +16 -12
  15. package/dist/cjs/core/BitcoinStepExecutor.js +46 -51
  16. package/dist/cjs/core/BitcoinStepExecutor.js.map +1 -1
  17. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.d.ts +9 -4
  18. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js +73 -99
  19. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -1
  20. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.d.ts +9 -4
  21. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js +37 -43
  22. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -1
  23. package/dist/cjs/errors/parseBitcoinErrors.d.ts +7 -2
  24. package/dist/cjs/errors/parseBitcoinErrors.js +18 -26
  25. package/dist/cjs/errors/parseBitcoinErrors.js.map +1 -1
  26. package/dist/cjs/index.d.ts +3 -3
  27. package/dist/cjs/index.js +5 -8
  28. package/dist/cjs/types.d.ts +17 -12
  29. package/dist/cjs/types.js +8 -5
  30. package/dist/cjs/types.js.map +1 -1
  31. package/dist/cjs/utils/generateRedeemScript.d.ts +10 -1
  32. package/dist/cjs/utils/generateRedeemScript.js +12 -5
  33. package/dist/cjs/utils/generateRedeemScript.js.map +1 -1
  34. package/dist/cjs/utils/isPsbtFinalized.d.ts +7 -2
  35. package/dist/cjs/utils/isPsbtFinalized.js +11 -10
  36. package/dist/cjs/utils/isPsbtFinalized.js.map +1 -1
  37. package/dist/cjs/utils/toBigmiChainId.d.ts +8 -3
  38. package/dist/cjs/utils/toBigmiChainId.js +11 -11
  39. package/dist/cjs/utils/toBigmiChainId.js.map +1 -1
  40. package/dist/cjs/utils/toXOnly.d.ts +5 -1
  41. package/dist/cjs/utils/toXOnly.js +4 -3
  42. package/dist/cjs/utils/toXOnly.js.map +1 -1
  43. package/dist/cjs/version.d.ts +6 -2
  44. package/dist/cjs/version.js +8 -5
  45. package/dist/cjs/version.js.map +1 -1
  46. package/dist/esm/BitcoinProvider.d.ts +7 -2
  47. package/dist/esm/BitcoinProvider.d.ts.map +1 -0
  48. package/dist/esm/BitcoinProvider.js +30 -32
  49. package/dist/esm/BitcoinProvider.js.map +1 -1
  50. package/dist/esm/actions/getBitcoinBalance.d.ts +7 -2
  51. package/dist/esm/actions/getBitcoinBalance.d.ts.map +1 -0
  52. package/dist/esm/actions/getBitcoinBalance.js +17 -22
  53. package/dist/esm/actions/getBitcoinBalance.js.map +1 -1
  54. package/dist/esm/actions/resolveBitcoinAddress.d.ts +5 -1
  55. package/dist/esm/actions/resolveBitcoinAddress.d.ts.map +1 -0
  56. package/dist/esm/actions/resolveBitcoinAddress.js +6 -3
  57. package/dist/esm/actions/resolveBitcoinAddress.js.map +1 -1
  58. package/dist/esm/client/publicClient.d.ts +14 -9
  59. package/dist/esm/client/publicClient.d.ts.map +1 -0
  60. package/dist/esm/client/publicClient.js +38 -46
  61. package/dist/esm/client/publicClient.js.map +1 -1
  62. package/dist/esm/core/BitcoinStepExecutor.d.ts +16 -12
  63. package/dist/esm/core/BitcoinStepExecutor.d.ts.map +1 -0
  64. package/dist/esm/core/BitcoinStepExecutor.js +45 -50
  65. package/dist/esm/core/BitcoinStepExecutor.js.map +1 -1
  66. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts +9 -4
  67. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +1 -0
  68. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js +71 -105
  69. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -1
  70. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts +9 -4
  71. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +1 -0
  72. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js +36 -40
  73. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -1
  74. package/dist/esm/errors/parseBitcoinErrors.d.ts +7 -2
  75. package/dist/esm/errors/parseBitcoinErrors.d.ts.map +1 -0
  76. package/dist/esm/errors/parseBitcoinErrors.js +17 -24
  77. package/dist/esm/errors/parseBitcoinErrors.js.map +1 -1
  78. package/dist/esm/index.d.ts +3 -3
  79. package/dist/esm/index.js +3 -4
  80. package/dist/esm/package.json +1 -1
  81. package/dist/esm/types.d.ts +17 -12
  82. package/dist/esm/types.d.ts.map +1 -0
  83. package/dist/esm/types.js +7 -3
  84. package/dist/esm/types.js.map +1 -1
  85. package/dist/esm/utils/generateRedeemScript.d.ts +9 -5
  86. package/dist/esm/utils/generateRedeemScript.d.ts.map +1 -0
  87. package/dist/esm/utils/generateRedeemScript.js +10 -8
  88. package/dist/esm/utils/generateRedeemScript.js.map +1 -1
  89. package/dist/esm/utils/isPsbtFinalized.d.ts +7 -2
  90. package/dist/esm/utils/isPsbtFinalized.d.ts.map +1 -0
  91. package/dist/esm/utils/isPsbtFinalized.js +11 -8
  92. package/dist/esm/utils/isPsbtFinalized.js.map +1 -1
  93. package/dist/esm/utils/toBigmiChainId.d.ts +8 -3
  94. package/dist/esm/utils/toBigmiChainId.d.ts.map +1 -0
  95. package/dist/esm/utils/toBigmiChainId.js +11 -9
  96. package/dist/esm/utils/toBigmiChainId.js.map +1 -1
  97. package/dist/esm/utils/toXOnly.d.ts +5 -1
  98. package/dist/esm/utils/toXOnly.d.ts.map +1 -0
  99. package/dist/esm/utils/toXOnly.js +5 -2
  100. package/dist/esm/utils/toXOnly.js.map +1 -1
  101. package/dist/esm/version.d.ts +6 -2
  102. package/dist/esm/version.d.ts.map +1 -0
  103. package/dist/esm/version.js +6 -2
  104. package/dist/esm/version.js.map +1 -1
  105. package/package.json +6 -6
  106. package/src/core/BitcoinStepExecutor.ts +4 -2
  107. package/src/utils/generateRedeemScript.ts +3 -1
  108. package/src/utils/toXOnly.ts +1 -1
  109. package/src/version.ts +1 -1
  110. package/dist/cjs/index.js.map +0 -1
  111. package/dist/esm/index.js.map +0 -1
  112. package/dist/types/BitcoinProvider.d.ts +0 -3
  113. package/dist/types/BitcoinProvider.d.ts.map +0 -1
  114. package/dist/types/actions/getBitcoinBalance.d.ts +0 -3
  115. package/dist/types/actions/getBitcoinBalance.d.ts.map +0 -1
  116. package/dist/types/actions/resolveBitcoinAddress.d.ts +0 -2
  117. package/dist/types/actions/resolveBitcoinAddress.d.ts.map +0 -1
  118. package/dist/types/client/publicClient.d.ts +0 -11
  119. package/dist/types/client/publicClient.d.ts.map +0 -1
  120. package/dist/types/core/BitcoinStepExecutor.d.ts +0 -16
  121. package/dist/types/core/BitcoinStepExecutor.d.ts.map +0 -1
  122. package/dist/types/core/tasks/BitcoinSignAndExecuteTask.d.ts +0 -6
  123. package/dist/types/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +0 -1
  124. package/dist/types/core/tasks/BitcoinWaitForTransactionTask.d.ts +0 -6
  125. package/dist/types/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +0 -1
  126. package/dist/types/errors/parseBitcoinErrors.d.ts +0 -3
  127. package/dist/types/errors/parseBitcoinErrors.d.ts.map +0 -1
  128. package/dist/types/index.d.ts +0 -4
  129. package/dist/types/index.d.ts.map +0 -1
  130. package/dist/types/types.d.ts +0 -16
  131. package/dist/types/types.d.ts.map +0 -1
  132. package/dist/types/utils/generateRedeemScript.d.ts +0 -7
  133. package/dist/types/utils/generateRedeemScript.d.ts.map +0 -1
  134. package/dist/types/utils/isPsbtFinalized.d.ts +0 -3
  135. package/dist/types/utils/isPsbtFinalized.d.ts.map +0 -1
  136. package/dist/types/utils/toBigmiChainId.d.ts +0 -4
  137. package/dist/types/utils/toBigmiChainId.d.ts.map +0 -1
  138. package/dist/types/utils/toXOnly.d.ts +0 -2
  139. package/dist/types/utils/toXOnly.d.ts.map +0 -1
  140. package/dist/types/version.d.ts +0 -3
  141. package/dist/types/version.d.ts.map +0 -1
@@ -1,106 +1,72 @@
1
- import { AddressType, getAddressInfo, hexToUnit8Array, signPsbt, withTimeout, } from '@bigmi/core';
2
- import * as ecc from '@bitcoinerlab/secp256k1';
3
- import { BaseStepExecutionTask, getTransactionRequestData, LiFiErrorCode, TransactionError, } from '@lifi/sdk';
4
- import { address, initEccLib, networks, Psbt } from 'bitcoinjs-lib';
5
- import { generateRedeemScript } from '../../utils/generateRedeemScript.js';
6
- import { isPsbtFinalized } from '../../utils/isPsbtFinalized.js';
7
- import { toXOnly } from '../../utils/toXOnly.js';
8
- export class BitcoinSignAndExecuteTask extends BaseStepExecutionTask {
9
- async run(context) {
10
- const { step, walletClient, statusManager, executionOptions, fromChain, publicClient, checkClient, isBridgeExecution, } = context;
11
- const action = statusManager.findAction(step, isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP');
12
- if (!action) {
13
- throw new TransactionError(LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction. Action not found.');
14
- }
15
- const transactionRequestData = await getTransactionRequestData(step, executionOptions);
16
- checkClient(step);
17
- const psbtHex = transactionRequestData;
18
- // Initialize ECC library required for Taproot operations
19
- // https://github.com/bitcoinjs/bitcoinjs-lib?tab=readme-ov-file#using-taproot
20
- initEccLib(ecc);
21
- const psbt = Psbt.fromHex(psbtHex, { network: networks.bitcoin });
22
- psbt.data.inputs.forEach((input, index) => {
23
- const accountAddress = input.witnessUtxo
24
- ? address.fromOutputScript(input.witnessUtxo.script, networks.bitcoin)
25
- : walletClient.account?.address;
26
- const addressInfo = getAddressInfo(accountAddress);
27
- if (addressInfo.type === AddressType.p2tr) {
28
- // Taproot (P2TR) addresses require specific PSBT fields for proper signing
29
- // tapInternalKey: Required for Taproot key-path spending
30
- // Most wallets / libraries usually handle this already
31
- if (!input.tapInternalKey) {
32
- const pubKey = walletClient.account?.publicKey;
33
- if (pubKey) {
34
- const tapInternalKey = toXOnly(hexToUnit8Array(pubKey));
35
- psbt.updateInput(index, {
36
- tapInternalKey,
37
- });
38
- }
39
- }
40
- // sighashType: Required by bitcoinjs-lib even though the bitcoin protocol allows defaults
41
- // check if sighashType is default (0) or not set (undefined)
42
- if (!input.sighashType) {
43
- psbt.updateInput(index, {
44
- sighashType: 1, // Default to Transaction.SIGHASH_ALL - 1
45
- });
46
- }
47
- }
48
- // redeemScript: Required by Pay-to-Script-Hash (P2SH) addresses for proper spending
49
- if (addressInfo.type === AddressType.p2sh) {
50
- if (!input.redeemScript) {
51
- const pubKey = walletClient.account?.publicKey;
52
- if (pubKey) {
53
- psbt.updateInput(index, {
54
- redeemScript: generateRedeemScript(hexToUnit8Array(pubKey)),
55
- });
56
- }
57
- }
58
- }
59
- });
60
- const inputsToSign = Array.from(psbt.data.inputs
61
- .reduce((map, input, index) => {
62
- const accountAddress = input.witnessUtxo
63
- ? address.fromOutputScript(input.witnessUtxo.script, networks.bitcoin)
64
- : walletClient.account?.address;
65
- if (map.has(accountAddress)) {
66
- map.get(accountAddress).signingIndexes.push(index);
67
- }
68
- else {
69
- map.set(accountAddress, {
70
- address: accountAddress,
71
- sigHash: 1, // Default to Transaction.SIGHASH_ALL - 1
72
- signingIndexes: [index],
73
- });
74
- }
75
- return map;
76
- }, new Map())
77
- .values());
78
- // We give users 10 minutes to sign the transaction or it should be considered expired
79
- const signedPsbtHex = await withTimeout(() => signPsbt(walletClient, {
80
- psbt: psbt.toHex(),
81
- inputsToSign: inputsToSign,
82
- finalize: false,
83
- }), {
84
- timeout: 600_000,
85
- errorInstance: new TransactionError(LiFiErrorCode.TransactionExpired, 'Transaction has expired.'),
86
- });
87
- const signedPsbt = Psbt.fromHex(signedPsbtHex);
88
- if (!isPsbtFinalized(signedPsbt)) {
89
- signedPsbt.finalizeAllInputs();
90
- }
91
- const txHex = signedPsbt.extractTransaction().toHex();
92
- const txHash = await publicClient.sendUTXOTransaction({
93
- hex: txHex,
94
- });
95
- statusManager.updateAction(step, action.type, 'PENDING', {
96
- txHash: txHash,
97
- txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
98
- txHex,
99
- signedAt: Date.now(),
100
- });
101
- return {
102
- status: 'COMPLETED',
103
- };
104
- }
105
- }
1
+ import { generateRedeemScript } from "../../utils/generateRedeemScript.js";
2
+ import { isPsbtFinalized } from "../../utils/isPsbtFinalized.js";
3
+ import { toXOnly } from "../../utils/toXOnly.js";
4
+ import { AddressType, getAddressInfo, hexToUnit8Array, signPsbt, withTimeout } from "@bigmi/core";
5
+ import { BaseStepExecutionTask, LiFiErrorCode, TransactionError, getTransactionRequestData } from "@lifi/sdk";
6
+ import * as ecc from "@bitcoinerlab/secp256k1";
7
+ import { Psbt, address, initEccLib, networks } from "bitcoinjs-lib";
8
+ //#region src/core/tasks/BitcoinSignAndExecuteTask.ts
9
+ var BitcoinSignAndExecuteTask = class extends BaseStepExecutionTask {
10
+ async run(context) {
11
+ const { step, walletClient, statusManager, executionOptions, fromChain, publicClient, checkClient, isBridgeExecution } = context;
12
+ const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
13
+ if (!action) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
14
+ const transactionRequestData = await getTransactionRequestData(step, executionOptions);
15
+ checkClient(step);
16
+ const psbtHex = transactionRequestData;
17
+ initEccLib(ecc);
18
+ const psbt = Psbt.fromHex(psbtHex, { network: networks.bitcoin });
19
+ psbt.data.inputs.forEach((input, index) => {
20
+ const addressInfo = getAddressInfo(input.witnessUtxo ? address.fromOutputScript(input.witnessUtxo.script, networks.bitcoin) : walletClient.account?.address);
21
+ if (addressInfo.type === AddressType.p2tr) {
22
+ if (!input.tapInternalKey) {
23
+ const pubKey = walletClient.account?.publicKey;
24
+ if (pubKey) {
25
+ const tapInternalKey = toXOnly(hexToUnit8Array(pubKey));
26
+ psbt.updateInput(index, { tapInternalKey });
27
+ }
28
+ }
29
+ if (!input.sighashType) psbt.updateInput(index, { sighashType: 1 });
30
+ }
31
+ if (addressInfo.type === AddressType.p2sh) {
32
+ if (!input.redeemScript) {
33
+ const pubKey = walletClient.account?.publicKey;
34
+ if (pubKey) psbt.updateInput(index, { redeemScript: generateRedeemScript(hexToUnit8Array(pubKey)) });
35
+ }
36
+ }
37
+ });
38
+ const inputsToSign = Array.from(psbt.data.inputs.reduce((map, input, index) => {
39
+ const accountAddress = input.witnessUtxo ? address.fromOutputScript(input.witnessUtxo.script, networks.bitcoin) : walletClient.account?.address;
40
+ if (map.has(accountAddress)) map.get(accountAddress).signingIndexes.push(index);
41
+ else map.set(accountAddress, {
42
+ address: accountAddress,
43
+ sigHash: 1,
44
+ signingIndexes: [index]
45
+ });
46
+ return map;
47
+ }, /* @__PURE__ */ new Map()).values());
48
+ const signedPsbtHex = await withTimeout(() => signPsbt(walletClient, {
49
+ psbt: psbt.toHex(),
50
+ inputsToSign,
51
+ finalize: false
52
+ }), {
53
+ timeout: 6e5,
54
+ errorInstance: new TransactionError(LiFiErrorCode.TransactionExpired, "Transaction has expired.")
55
+ });
56
+ const signedPsbt = Psbt.fromHex(signedPsbtHex);
57
+ if (!isPsbtFinalized(signedPsbt)) signedPsbt.finalizeAllInputs();
58
+ const txHex = signedPsbt.extractTransaction().toHex();
59
+ const txHash = await publicClient.sendUTXOTransaction({ hex: txHex });
60
+ statusManager.updateAction(step, action.type, "PENDING", {
61
+ txHash,
62
+ txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
63
+ txHex,
64
+ signedAt: Date.now()
65
+ });
66
+ return { status: "COMPLETED" };
67
+ }
68
+ };
69
+ //#endregion
70
+ export { BitcoinSignAndExecuteTask };
71
+
106
72
  //# sourceMappingURL=BitcoinSignAndExecuteTask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BitcoinSignAndExecuteTask.js","sourceRoot":"","sources":["../../../../src/core/tasks/BitcoinSignAndExecuteTask.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,WAAW,GACZ,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAA;AAC9C,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EAEb,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAEhD,MAAM,OAAO,yBAA0B,SAAQ,qBAAqB;IAClE,KAAK,CAAC,GAAG,CAAC,OAAmC;QAC3C,MAAM,EACJ,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,iBAAiB,GAClB,GAAG,OAAO,CAAA;QAEX,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CACrC,IAAI,EACJ,iBAAiB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;SACpB,CAAA;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"BitcoinSignAndExecuteTask.js","names":[],"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+C,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,IAAI,iBACR,cAAc,uBACd,mDACD;EAGH,MAAM,yBAAyB,MAAM,0BACnC,MACA,iBACD;AAED,cAAY,KAAK;EAEjB,MAAM,UAAU;AAIhB,aAAW,IAAI;EAEf,MAAM,OAAO,KAAK,QAAQ,SAAS,EAAE,SAAS,SAAS,SAAS,CAAC;AAEjE,OAAK,KAAK,OAAO,SAAS,OAAO,UAAU;GAIzC,MAAM,cAAc,eAHG,MAAM,cACzB,QAAQ,iBAAiB,MAAM,YAAY,QAAQ,SAAS,QAAQ,GACnE,aAAa,SAAS,QACuB;AAClD,OAAI,YAAY,SAAS,YAAY,MAAM;AAKzC,QAAI,CAAC,MAAM,gBAAgB;KACzB,MAAM,SAAS,aAAa,SAAS;AACrC,SAAI,QAAQ;MACV,MAAM,iBAAiB,QAAQ,gBAAgB,OAAO,CAAC;AACvD,WAAK,YAAY,OAAO,EACtB,gBACD,CAAC;;;AAKN,QAAI,CAAC,MAAM,YACT,MAAK,YAAY,OAAO,EACtB,aAAa,GACd,CAAC;;AAIN,OAAI,YAAY,SAAS,YAAY;QAC/B,CAAC,MAAM,cAAc;KACvB,MAAM,SAAS,aAAa,SAAS;AACrC,SAAI,OACF,MAAK,YAAY,OAAO,EACtB,cAAc,qBAAqB,gBAAgB,OAAO,CAAC,EAC5D,CAAC;;;IAIR;EAEF,MAAM,eAAe,MAAM,KACzB,KAAK,KAAK,OACP,QAAQ,KAAK,OAAO,UAAU;GAC7B,MAAM,iBAAiB,MAAM,cACzB,QAAQ,iBACN,MAAM,YAAY,QAClB,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,MAAM,kBAExB,SAAS,cAAc;GACrB,MAAM,KAAK,OAAO;GACJ;GACd,UAAU;GACX,CAAC,EACJ;GACE,SAAS;GACT,eAAe,IAAI,iBACjB,cAAc,oBACd,2BACD;GACF,CACF;EAED,MAAM,aAAa,KAAK,QAAQ,cAAc;AAE9C,MAAI,CAAC,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 { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk';
2
- import type { BitcoinStepExecutorContext } from '../../types.js';
3
- export declare class BitcoinWaitForTransactionTask extends BaseStepExecutionTask {
4
- run(context: BitcoinStepExecutorContext): Promise<TaskResult>;
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitcoinWaitForTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/BitcoinWaitForTransactionTask.ts"],"mappings":";;;;cAUa,6BAAA,SAAsC,qBAAA;EACjD,GAAA,CAAU,OAAA,EAAS,0BAAA,GAA6B,OAAA,CAAQ,UAAA;AAAA"}
@@ -1,41 +1,37 @@
1
- import { waitForTransaction } from '@bigmi/core';
2
- import { BaseStepExecutionTask, LiFiErrorCode, TransactionError, } from '@lifi/sdk';
3
- export class BitcoinWaitForTransactionTask extends BaseStepExecutionTask {
4
- async run(context) {
5
- const { step, statusManager, fromChain, isBridgeExecution, walletClient, publicClient, checkClient, } = context;
6
- const action = statusManager.findAction(step, isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP');
7
- const txHex = action?.txHex;
8
- const txHash = action?.txHash;
9
- if (!txHash || !txHex) {
10
- throw new TransactionError(LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction. Transaction hash or hex is not set.');
11
- }
12
- checkClient(step);
13
- let replacementReason;
14
- const transaction = await waitForTransaction(publicClient, {
15
- txId: txHash,
16
- txHex,
17
- senderAddress: walletClient.account?.address,
18
- onReplaced: (response) => {
19
- replacementReason = response.reason;
20
- statusManager.updateAction(step, action.type, 'PENDING', {
21
- txHash: response.transaction.txid,
22
- txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.txid}`,
23
- });
24
- },
25
- });
26
- if (replacementReason === 'cancelled') {
27
- throw new TransactionError(LiFiErrorCode.TransactionCanceled, 'User canceled transaction.');
28
- }
29
- if (transaction.txid !== txHash) {
30
- statusManager.updateAction(step, action.type, 'PENDING', {
31
- txHash: transaction.txid,
32
- txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transaction.txid}`,
33
- });
34
- }
35
- if (isBridgeExecution) {
36
- statusManager.updateAction(step, action.type, 'DONE');
37
- }
38
- return { status: 'COMPLETED' };
39
- }
40
- }
1
+ import { waitForTransaction } from "@bigmi/core";
2
+ import { BaseStepExecutionTask, LiFiErrorCode, TransactionError } from "@lifi/sdk";
3
+ //#region src/core/tasks/BitcoinWaitForTransactionTask.ts
4
+ var BitcoinWaitForTransactionTask = class extends BaseStepExecutionTask {
5
+ async run(context) {
6
+ const { step, statusManager, fromChain, isBridgeExecution, walletClient, publicClient, checkClient } = context;
7
+ const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
8
+ const txHex = action?.txHex;
9
+ const txHash = action?.txHash;
10
+ if (!txHash || !txHex) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Transaction hash or hex is not set.");
11
+ checkClient(step);
12
+ let replacementReason;
13
+ const transaction = await waitForTransaction(publicClient, {
14
+ txId: txHash,
15
+ txHex,
16
+ senderAddress: walletClient.account?.address,
17
+ onReplaced: (response) => {
18
+ replacementReason = response.reason;
19
+ statusManager.updateAction(step, action.type, "PENDING", {
20
+ txHash: response.transaction.txid,
21
+ txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.txid}`
22
+ });
23
+ }
24
+ });
25
+ if (replacementReason === "cancelled") throw new TransactionError(LiFiErrorCode.TransactionCanceled, "User canceled transaction.");
26
+ if (transaction.txid !== txHash) statusManager.updateAction(step, action.type, "PENDING", {
27
+ txHash: transaction.txid,
28
+ txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transaction.txid}`
29
+ });
30
+ if (isBridgeExecution) statusManager.updateAction(step, action.type, "DONE");
31
+ return { status: "COMPLETED" };
32
+ }
33
+ };
34
+ //#endregion
35
+ export { BitcoinWaitForTransactionTask };
36
+
41
37
  //# sourceMappingURL=BitcoinWaitForTransactionTask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BitcoinWaitForTransactionTask.js","sourceRoot":"","sources":["../../../../src/core/tasks/BitcoinWaitForTransactionTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EACL,qBAAqB,EACrB,aAAa,EAEb,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAGlB,MAAM,OAAO,6BAA8B,SAAQ,qBAAqB;IACtE,KAAK,CAAC,GAAG,CAAC,OAAmC;QAC3C,MAAM,EACJ,IAAI,EACJ,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,GAAG,OAAO,CAAA;QAEX,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CACrC,IAAI,EACJ,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAC3C,CAAA;QAED,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAA;QAC3B,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,CAAA;QAE7B,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,gBAAgB,CACxB,aAAa,CAAC,qBAAqB,EACnC,oEAAoE,CACrE,CAAA;QACH,CAAC;QAED,WAAW,CAAC,IAAI,CAAC,CAAA;QAEjB,IAAI,iBAAgD,CAAA;QACpD,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,YAAY,EAAE;YACzD,IAAI,EAAE,MAAM;YACZ,KAAK;YACL,aAAa,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO;YAC5C,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACvB,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAA;gBACnC,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE;oBACvD,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI;oBACjC,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE;iBACpF,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;QAEF,IAAI,iBAAiB,KAAK,WAAW,EAAE,CAAC;YACtC,MAAM,IAAI,gBAAgB,CACxB,aAAa,CAAC,mBAAmB,EACjC,4BAA4B,CAC7B,CAAA;QACH,CAAC;QAED,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAChC,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE;gBACvD,MAAM,EAAE,WAAW,CAAC,IAAI;gBACxB,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,IAAI,EAAE;aAC3E,CAAC,CAAA;QACJ,CAAC;QAED,IAAI,iBAAiB,EAAE,CAAC;YACtB,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACvD,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAA;IAChC,CAAC;CACF"}
1
+ {"version":3,"file":"BitcoinWaitForTransactionTask.js","names":[],"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,cAAmD,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,IAAI,iBACR,cAAc,uBACd,qEACD;AAGH,cAAY,KAAK;EAEjB,IAAI;EACJ,MAAM,cAAc,MAAM,mBAAmB,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,IAAI,iBACR,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 { type ExecutionAction, type LiFiStep, SDKError } from '@lifi/sdk';
2
- export declare const parseBitcoinErrors: (e: Error, step?: LiFiStep, action?: ExecutionAction) => Promise<SDKError>;
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBitcoinErrors.d.ts","names":[],"sources":["../../../src/errors/parseBitcoinErrors.ts"],"mappings":";;;cAWa,kBAAA,GACX,CAAA,EAAG,KAAA,EACH,IAAA,GAAO,QAAA,EACP,MAAA,GAAS,eAAA,KACR,OAAA,CAAQ,QAAA"}
@@ -1,28 +1,21 @@
1
- import { BaseError, ErrorMessage, LiFiErrorCode, SDKError, TransactionError, UnknownError, } from '@lifi/sdk';
2
- export const parseBitcoinErrors = async (e, step, action) => {
3
- if (e instanceof SDKError) {
4
- e.step = e.step ?? step;
5
- e.action = e.action ?? action;
6
- return e;
7
- }
8
- const baseError = handleSpecificErrors(e);
9
- return new SDKError(baseError, step, action);
1
+ import { BaseError, ErrorMessage, LiFiErrorCode, SDKError, TransactionError, UnknownError } from "@lifi/sdk";
2
+ //#region src/errors/parseBitcoinErrors.ts
3
+ const parseBitcoinErrors = async (e, step, action) => {
4
+ if (e instanceof SDKError) {
5
+ e.step = e.step ?? step;
6
+ e.action = e.action ?? action;
7
+ return e;
8
+ }
9
+ return new SDKError(handleSpecificErrors(e), step, action);
10
10
  };
11
11
  const handleSpecificErrors = (e) => {
12
- // txn-mempool-conflict
13
- if (e.details?.includes?.('conflict') ||
14
- e.cause?.message?.includes?.('conflict')) {
15
- return new TransactionError(LiFiErrorCode.TransactionConflict, 'Your transaction conflicts with another transaction already in the mempool. One or more inputs have been spent by another transaction.', e);
16
- }
17
- if (e.code === 4001 || e.code === -32000 || e.cause?.includes?.('rejected')) {
18
- return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e);
19
- }
20
- if (e.code === -5 || e.code === -32700 || e.code === -32064) {
21
- return new TransactionError(LiFiErrorCode.NotFound, e.message, e);
22
- }
23
- if (e instanceof BaseError) {
24
- return e;
25
- }
26
- return new UnknownError(e.message || ErrorMessage.UnknownError, e);
12
+ if (e.details?.includes?.("conflict") || e.cause?.message?.includes?.("conflict")) return new TransactionError(LiFiErrorCode.TransactionConflict, "Your transaction conflicts with another transaction already in the mempool. One or more inputs have been spent by another transaction.", e);
13
+ if (e.code === 4001 || e.code === -32e3 || e.cause?.includes?.("rejected")) return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e);
14
+ if (e.code === -5 || e.code === -32700 || e.code === -32064) return new TransactionError(LiFiErrorCode.NotFound, e.message, e);
15
+ if (e instanceof BaseError) return e;
16
+ return new UnknownError(e.message || ErrorMessage.UnknownError, e);
27
17
  };
18
+ //#endregion
19
+ export { parseBitcoinErrors };
20
+
28
21
  //# sourceMappingURL=parseBitcoinErrors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseBitcoin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AC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5D,OAAO,IAAI,gBAAgB,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACnE,CAAC;IAED,IAAI,CAAC,YAAY,SAAS,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAA;IACV,CAAC;IAED,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAA;AACpE,CAAC,CAAA"}
1
+ {"version":3,"file":"parseBitcoinErrors.js","names":[],"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,aAAa,UAAU;AACzB,IAAE,OAAO,EAAE,QAAQ;AACnB,IAAE,SAAS,EAAE,UAAU;AACvB,SAAO;;AAKT,QAAO,IAAI,SAFO,qBAAqB,EAAE,EAEV,MAAM,OAAO;;AAG9C,MAAM,wBAAwB,MAAW;AAEvC,KACE,EAAE,SAAS,WAAW,WAAW,IACjC,EAAE,OAAO,SAAS,WAAW,WAAW,CAExC,QAAO,IAAI,iBACT,cAAc,qBACd,0IACA,EACD;AAEH,KAAI,EAAE,SAAS,QAAQ,EAAE,SAAS,SAAU,EAAE,OAAO,WAAW,WAAW,CACzE,QAAO,IAAI,iBAAiB,cAAc,mBAAmB,EAAE,SAAS,EAAE;AAE5E,KAAI,EAAE,SAAS,MAAM,EAAE,SAAS,UAAU,EAAE,SAAS,OACnD,QAAO,IAAI,iBAAiB,cAAc,UAAU,EAAE,SAAS,EAAE;AAGnE,KAAI,aAAa,UACf,QAAO;AAGT,QAAO,IAAI,aAAa,EAAE,WAAW,aAAa,cAAc,EAAE"}
@@ -1,3 +1,3 @@
1
- export { BitcoinProvider } from './BitcoinProvider.js';
2
- export type { BitcoinProviderOptions, BitcoinSDKProvider } from './types.js';
3
- export { isBitcoinProvider } from './types.js';
1
+ import { BitcoinProviderOptions, BitcoinSDKProvider, isBitcoinProvider } from "./types.js";
2
+ import { BitcoinProvider } from "./BitcoinProvider.js";
3
+ export { BitcoinProvider, type BitcoinProviderOptions, type BitcoinSDKProvider, isBitcoinProvider };
package/dist/esm/index.js CHANGED
@@ -1,4 +1,3 @@
1
- // biome-ignore lint/performance/noBarrelFile: module entrypoint
2
- export { BitcoinProvider } from './BitcoinProvider.js';
3
- export { isBitcoinProvider } from './types.js';
4
- //# sourceMappingURL=index.js.map
1
+ import { BitcoinProvider } from "./BitcoinProvider.js";
2
+ import { isBitcoinProvider } from "./types.js";
3
+ export { BitcoinProvider, isBitcoinProvider };
@@ -1 +1 @@
1
- {"type": "module","sideEffects":false}
1
+ {"type":"module","sideEffects":false}
@@ -1,15 +1,20 @@
1
- import type { Client } from '@bigmi/core';
2
- import { type LiFiStepExtended, type SDKProvider, type StepExecutorContext } from '@lifi/sdk';
3
- import type { PublicClient } from './client/publicClient.js';
4
- export interface BitcoinProviderOptions {
5
- getWalletClient?: () => Promise<Client>;
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
- export interface BitcoinStepExecutorContext extends StepExecutorContext {
8
- walletClient: Client;
9
- publicClient: PublicClient;
10
- checkClient: (step: LiFiStepExtended) => void;
9
+ interface BitcoinStepExecutorContext extends StepExecutorContext {
10
+ walletClient: Client;
11
+ publicClient: PublicClient;
12
+ checkClient: (step: LiFiStepExtended) => void;
11
13
  }
12
- export interface BitcoinSDKProvider extends SDKProvider {
13
- setOptions(options: BitcoinProviderOptions): void;
14
+ interface BitcoinSDKProvider extends SDKProvider {
15
+ setOptions(options: BitcoinProviderOptions): void;
14
16
  }
15
- export declare function isBitcoinProvider(provider: SDKProvider): provider is BitcoinSDKProvider;
17
+ declare function isBitcoinProvider(provider: SDKProvider): provider is BitcoinSDKProvider;
18
+ //#endregion
19
+ export { BitcoinProviderOptions, BitcoinSDKProvider, BitcoinStepExecutorContext, isBitcoinProvider };
20
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;UASiB,sBAAA;EACf,eAAA,SAAwB,OAAA,CAAQ,MAAA;AAAA;AAAA,UAGjB,0BAAA,SAAmC,mBAAA;EAClD,YAAA,EAAc,MAAA;EACd,YAAA,EAAc,YAAA;EACd,WAAA,GAAc,IAAA,EAAM,gBAAA;AAAA;AAAA,UAGL,kBAAA,SAA2B,WAAA;EAC1C,UAAA,CAAW,OAAA,EAAS,sBAAA;AAAA;AAAA,iBAGN,iBAAA,CACd,QAAA,EAAU,WAAA,GACT,QAAA,IAAY,kBAAA"}
package/dist/esm/types.js CHANGED
@@ -1,5 +1,9 @@
1
- import { ChainType, } from '@lifi/sdk';
2
- export function isBitcoinProvider(provider) {
3
- return provider.type === ChainType.UTXO;
1
+ import { ChainType } from "@lifi/sdk";
2
+ //#region src/types.ts
3
+ function isBitcoinProvider(provider) {
4
+ return provider.type === ChainType.UTXO;
4
5
  }
6
+ //#endregion
7
+ export { isBitcoinProvider };
8
+
5
9
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,GAIV,MAAM,WAAW,CAAA;AAiBlB,MAAM,UAAU,iBAAiB,CAC/B,QAAqB;IAErB,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAA;AACzC,CAAC"}
1
+ {"version":3,"file":"types.js","names":[],"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,SAAS,UAAU"}
@@ -1,6 +1,10 @@
1
+ //#region src/utils/generateRedeemScript.d.ts
1
2
  /**
2
- * Generate redeem script for P2SH addresses
3
- * @param publicKey
4
- * @returns redeem script
5
- */
6
- export declare const generateRedeemScript: (publicKey: Uint8Array) => Uint8Array<ArrayBufferLike> | undefined;
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateRedeemScript.d.ts","names":[],"sources":["../../../src/utils/generateRedeemScript.ts"],"mappings":";;AAOA;;;;cAAa,oBAAA,GACX,SAAA,EAAW,UAAA,KACV,UAAA"}
@@ -1,10 +1,12 @@
1
- import { payments } from 'bitcoinjs-lib';
1
+ import { payments } from "bitcoinjs-lib";
2
+ //#region src/utils/generateRedeemScript.ts
2
3
  /**
3
- * Generate redeem script for P2SH addresses
4
- * @param publicKey
5
- * @returns redeem script
6
- */
7
- export const generateRedeemScript = (publicKey) =>
8
- // P2SH addresses are created by hashing the public key and using the result as the script
9
- payments.p2wpkh({ pubkey: publicKey }).output;
4
+ * Generate redeem script for P2SH addresses
5
+ * @param publicKey
6
+ * @returns redeem script
7
+ */
8
+ const generateRedeemScript = (publicKey) => payments.p2wpkh({ pubkey: publicKey }).output;
9
+ //#endregion
10
+ export { generateRedeemScript };
11
+
10
12
  //# sourceMappingURL=generateRedeemScript.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateRedeemScript.js","sourceRoot":"","sources":["../../../src/utils/generateRedeemScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAqB,EAAE,EAAE;AAC5D,0FAA0F;AAC1F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAA"}
1
+ {"version":3,"file":"generateRedeemScript.js","names":[],"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,cAGA,SAAS,OAAO,EAAE,QAAQ,WAAW,CAAC,CAAC"}
@@ -1,2 +1,7 @@
1
- import type { Psbt } from 'bitcoinjs-lib';
2
- export declare function isPsbtFinalized(psbt: Psbt): boolean;
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPsbtFinalized.d.ts","names":[],"sources":["../../../src/utils/isPsbtFinalized.ts"],"mappings":";;;iBAEgB,eAAA,CAAgB,IAAA,EAAM,IAAA"}
@@ -1,10 +1,13 @@
1
- export function isPsbtFinalized(psbt) {
2
- try {
3
- psbt.extractTransaction();
4
- return true;
5
- }
6
- catch (_) {
7
- return false;
8
- }
1
+ //#region src/utils/isPsbtFinalized.ts
2
+ function isPsbtFinalized(psbt) {
3
+ try {
4
+ psbt.extractTransaction();
5
+ return true;
6
+ } catch (_) {
7
+ return false;
8
+ }
9
9
  }
10
+ //#endregion
11
+ export { isPsbtFinalized };
12
+
10
13
  //# sourceMappingURL=isPsbtFinalized.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isPsbtFinalized.js","sourceRoot":"","sources":["../../../src/utils/isPsbtFinalized.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,IAAU;IACxC,IAAI,CAAC;QACH,IAAI,CAAC,kBAAkB,EAAE,CAAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
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"}