@lifi/sdk-provider-bitcoin 4.0.1-alpha.0 → 4.0.1
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/CHANGELOG.md +23 -0
- package/README.md +88 -5
- package/dist/cjs/BitcoinProvider.d.ts +7 -2
- package/dist/cjs/BitcoinProvider.js +30 -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 +21 -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 +14 -4
- package/dist/cjs/client/publicClient.js +38 -42
- package/dist/cjs/client/publicClient.js.map +1 -1
- package/dist/cjs/core/BitcoinStepExecutor.d.ts +19 -0
- package/dist/cjs/core/BitcoinStepExecutor.js +47 -0
- package/dist/cjs/core/BitcoinStepExecutor.js.map +1 -0
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.d.ts +10 -0
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js +75 -0
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -0
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js +38 -0
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/errors/parseBitcoinErrors.d.ts +7 -2
- package/dist/cjs/errors/parseBitcoinErrors.js +17 -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 +18 -7
- package/dist/cjs/types.js +7 -5
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/generateRedeemScript.d.ts +10 -1
- package/dist/cjs/utils/generateRedeemScript.js +11 -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 +10 -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 +22 -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 +13 -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 +19 -0
- package/dist/esm/core/BitcoinStepExecutor.d.ts.map +1 -0
- package/dist/esm/core/BitcoinStepExecutor.js +46 -0
- package/dist/esm/core/BitcoinStepExecutor.js.map +1 -0
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts +10 -0
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js +72 -0
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -0
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js +37 -0
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -0
- 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 +18 -7
- 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 +7 -6
- package/src/BitcoinProvider.ts +1 -1
- package/src/actions/getBitcoinBalance.ts +15 -3
- package/src/client/publicClient.ts +1 -1
- package/src/core/BitcoinStepExecutor.ts +100 -0
- package/src/core/tasks/BitcoinSignAndExecuteTask.ts +168 -0
- package/src/core/tasks/BitcoinWaitForTransactionTask.ts +74 -0
- package/src/types.ts +13 -1
- package/src/utils/generateRedeemScript.ts +3 -1
- package/src/utils/toXOnly.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/cjs/BitcoinStepExecutor.d.ts +0 -12
- package/dist/cjs/BitcoinStepExecutor.js +0 -198
- package/dist/cjs/BitcoinStepExecutor.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/BitcoinStepExecutor.d.ts +0 -12
- package/dist/esm/BitcoinStepExecutor.js +0 -210
- package/dist/esm/BitcoinStepExecutor.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/BitcoinStepExecutor.d.ts +0 -13
- package/dist/types/BitcoinStepExecutor.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 -12
- package/dist/types/client/publicClient.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 -10
- 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
- package/src/BitcoinStepExecutor.ts +0 -333
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ReplacementReason } from '@bigmi/core'
|
|
2
|
+
import { waitForTransaction } from '@bigmi/core'
|
|
3
|
+
import {
|
|
4
|
+
BaseStepExecutionTask,
|
|
5
|
+
LiFiErrorCode,
|
|
6
|
+
type TaskResult,
|
|
7
|
+
TransactionError,
|
|
8
|
+
} from '@lifi/sdk'
|
|
9
|
+
import type { BitcoinStepExecutorContext } from '../../types.js'
|
|
10
|
+
|
|
11
|
+
export class BitcoinWaitForTransactionTask extends BaseStepExecutionTask {
|
|
12
|
+
async run(context: BitcoinStepExecutorContext): Promise<TaskResult> {
|
|
13
|
+
const {
|
|
14
|
+
step,
|
|
15
|
+
statusManager,
|
|
16
|
+
fromChain,
|
|
17
|
+
isBridgeExecution,
|
|
18
|
+
walletClient,
|
|
19
|
+
publicClient,
|
|
20
|
+
checkClient,
|
|
21
|
+
} = context
|
|
22
|
+
|
|
23
|
+
const action = statusManager.findAction(
|
|
24
|
+
step,
|
|
25
|
+
isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const txHex = action?.txHex
|
|
29
|
+
const txHash = action?.txHash
|
|
30
|
+
|
|
31
|
+
if (!txHash || !txHex) {
|
|
32
|
+
throw new TransactionError(
|
|
33
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
34
|
+
'Unable to prepare transaction. Transaction hash or hex is not set.'
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
checkClient(step)
|
|
39
|
+
|
|
40
|
+
let replacementReason: ReplacementReason | undefined
|
|
41
|
+
const transaction = await waitForTransaction(publicClient, {
|
|
42
|
+
txId: txHash,
|
|
43
|
+
txHex,
|
|
44
|
+
senderAddress: walletClient.account?.address,
|
|
45
|
+
onReplaced: (response) => {
|
|
46
|
+
replacementReason = response.reason
|
|
47
|
+
statusManager.updateAction(step, action.type, 'PENDING', {
|
|
48
|
+
txHash: response.transaction.txid,
|
|
49
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.txid}`,
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
if (replacementReason === 'cancelled') {
|
|
55
|
+
throw new TransactionError(
|
|
56
|
+
LiFiErrorCode.TransactionCanceled,
|
|
57
|
+
'User canceled transaction.'
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (transaction.txid !== txHash) {
|
|
62
|
+
statusManager.updateAction(step, action.type, 'PENDING', {
|
|
63
|
+
txHash: transaction.txid,
|
|
64
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transaction.txid}`,
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (isBridgeExecution) {
|
|
69
|
+
statusManager.updateAction(step, action.type, 'DONE')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return { status: 'COMPLETED' }
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import type { Client } from '@bigmi/core'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ChainType,
|
|
4
|
+
type LiFiStepExtended,
|
|
5
|
+
type SDKProvider,
|
|
6
|
+
type StepExecutorContext,
|
|
7
|
+
} from '@lifi/sdk'
|
|
8
|
+
import type { PublicClient } from './client/publicClient.js'
|
|
3
9
|
|
|
4
10
|
export interface BitcoinProviderOptions {
|
|
5
11
|
getWalletClient?: () => Promise<Client>
|
|
6
12
|
}
|
|
7
13
|
|
|
14
|
+
export interface BitcoinStepExecutorContext extends StepExecutorContext {
|
|
15
|
+
walletClient: Client
|
|
16
|
+
publicClient: PublicClient
|
|
17
|
+
checkClient: (step: LiFiStepExtended) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
export interface BitcoinSDKProvider extends SDKProvider {
|
|
9
21
|
setOptions(options: BitcoinProviderOptions): void
|
|
10
22
|
}
|
|
@@ -5,6 +5,8 @@ import { payments } from 'bitcoinjs-lib'
|
|
|
5
5
|
* @param publicKey
|
|
6
6
|
* @returns redeem script
|
|
7
7
|
*/
|
|
8
|
-
export const generateRedeemScript = (
|
|
8
|
+
export const generateRedeemScript = (
|
|
9
|
+
publicKey: Uint8Array
|
|
10
|
+
): Uint8Array | undefined =>
|
|
9
11
|
// P2SH addresses are created by hashing the public key and using the result as the script
|
|
10
12
|
payments.p2wpkh({ pubkey: publicKey }).output
|
package/src/utils/toXOnly.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// helper function to convert full public key (33 bytes) to x-only compressed format (32 bytes) required after taproot update
|
|
2
|
-
export const toXOnly = (pubKey: Uint8Array) =>
|
|
2
|
+
export const toXOnly = (pubKey: Uint8Array): Uint8Array =>
|
|
3
3
|
pubKey.length === 32 ? pubKey : pubKey.subarray(1, 33)
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk-provider-bitcoin'
|
|
2
|
-
export const version = '4.0.1
|
|
2
|
+
export const version = '4.0.1'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Client } from '@bigmi/core';
|
|
2
|
-
import { BaseStepExecutor, type LiFiStepExtended, type SDKClient, type StepExecutorOptions } from '@lifi/sdk';
|
|
3
|
-
interface BitcoinStepExecutorOptions extends StepExecutorOptions {
|
|
4
|
-
client: Client;
|
|
5
|
-
}
|
|
6
|
-
export declare class BitcoinStepExecutor extends BaseStepExecutor {
|
|
7
|
-
private client;
|
|
8
|
-
constructor(options: BitcoinStepExecutorOptions);
|
|
9
|
-
checkClient: (step: LiFiStepExtended) => void;
|
|
10
|
-
executeStep: (client: SDKClient, step: LiFiStepExtended) => Promise<LiFiStepExtended>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitcoinStepExecutor = void 0;
|
|
4
|
-
const core_1 = require("@bigmi/core");
|
|
5
|
-
const ecc = require("@bitcoinerlab/secp256k1");
|
|
6
|
-
const sdk_1 = require("@lifi/sdk");
|
|
7
|
-
const bitcoinjs_lib_1 = require("bitcoinjs-lib");
|
|
8
|
-
const publicClient_js_1 = require("./client/publicClient.js");
|
|
9
|
-
const parseBitcoinErrors_js_1 = require("./errors/parseBitcoinErrors.js");
|
|
10
|
-
const generateRedeemScript_js_1 = require("./utils/generateRedeemScript.js");
|
|
11
|
-
const isPsbtFinalized_js_1 = require("./utils/isPsbtFinalized.js");
|
|
12
|
-
const toXOnly_js_1 = require("./utils/toXOnly.js");
|
|
13
|
-
class BitcoinStepExecutor extends sdk_1.BaseStepExecutor {
|
|
14
|
-
client;
|
|
15
|
-
constructor(options) {
|
|
16
|
-
super(options);
|
|
17
|
-
this.client = options.client;
|
|
18
|
-
}
|
|
19
|
-
checkClient = (step) => {
|
|
20
|
-
if (this.client.account?.address !== step.action.fromAddress) {
|
|
21
|
-
throw new sdk_1.TransactionError(sdk_1.LiFiErrorCode.WalletChangedDuringExecution, 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.');
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
executeStep = async (client, step) => {
|
|
25
|
-
step.execution = this.statusManager.initExecutionObject(step);
|
|
26
|
-
const fromChain = await client.getChainById(step.action.fromChainId);
|
|
27
|
-
const toChain = await client.getChainById(step.action.toChainId);
|
|
28
|
-
const isBridgeExecution = fromChain.id !== toChain.id;
|
|
29
|
-
const currentActionType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP';
|
|
30
|
-
let action = this.statusManager.findOrCreateAction({
|
|
31
|
-
step,
|
|
32
|
-
type: currentActionType,
|
|
33
|
-
chainId: fromChain.id,
|
|
34
|
-
});
|
|
35
|
-
const publicClient = await (0, publicClient_js_1.getBitcoinPublicClient)(client, sdk_1.ChainId.BTC);
|
|
36
|
-
if (action.status !== 'DONE') {
|
|
37
|
-
try {
|
|
38
|
-
let txHash;
|
|
39
|
-
let txHex;
|
|
40
|
-
if (action.txHash) {
|
|
41
|
-
this.checkClient(step);
|
|
42
|
-
txHash = action.txHash;
|
|
43
|
-
txHex = action.txHex;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
action = this.statusManager.updateAction(step, action.type, 'STARTED');
|
|
47
|
-
await (0, sdk_1.checkBalance)(client, this.client.account.address, step);
|
|
48
|
-
if (!step.transactionRequest) {
|
|
49
|
-
const { execution, ...stepBase } = step;
|
|
50
|
-
const updatedStep = await (0, sdk_1.getStepTransaction)(client, stepBase);
|
|
51
|
-
const comparedStep = await (0, sdk_1.stepComparison)(this.statusManager, step, updatedStep, this.allowUserInteraction, this.executionOptions);
|
|
52
|
-
Object.assign(step, {
|
|
53
|
-
...comparedStep,
|
|
54
|
-
execution: step.execution,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
if (!step.transactionRequest?.data) {
|
|
58
|
-
throw new sdk_1.TransactionError(sdk_1.LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
59
|
-
}
|
|
60
|
-
action = this.statusManager.updateAction(step, action.type, 'ACTION_REQUIRED');
|
|
61
|
-
if (!this.allowUserInteraction) {
|
|
62
|
-
return step;
|
|
63
|
-
}
|
|
64
|
-
let transactionRequest = {
|
|
65
|
-
data: step.transactionRequest.data,
|
|
66
|
-
};
|
|
67
|
-
if (this.executionOptions?.updateTransactionRequestHook) {
|
|
68
|
-
const customizedTransactionRequest = await this.executionOptions.updateTransactionRequestHook({
|
|
69
|
-
requestType: 'transaction',
|
|
70
|
-
...transactionRequest,
|
|
71
|
-
});
|
|
72
|
-
transactionRequest = {
|
|
73
|
-
...transactionRequest,
|
|
74
|
-
...customizedTransactionRequest,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (!transactionRequest.data) {
|
|
78
|
-
throw new sdk_1.TransactionError(sdk_1.LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
79
|
-
}
|
|
80
|
-
this.checkClient(step);
|
|
81
|
-
const psbtHex = transactionRequest.data;
|
|
82
|
-
(0, bitcoinjs_lib_1.initEccLib)(ecc);
|
|
83
|
-
const psbt = bitcoinjs_lib_1.Psbt.fromHex(psbtHex, { network: bitcoinjs_lib_1.networks.bitcoin });
|
|
84
|
-
psbt.data.inputs.forEach((input, index) => {
|
|
85
|
-
const accountAddress = input.witnessUtxo
|
|
86
|
-
? bitcoinjs_lib_1.address.fromOutputScript(input.witnessUtxo.script, bitcoinjs_lib_1.networks.bitcoin)
|
|
87
|
-
: this.client.account?.address;
|
|
88
|
-
const addressInfo = (0, core_1.getAddressInfo)(accountAddress);
|
|
89
|
-
if (addressInfo.type === core_1.AddressType.p2tr) {
|
|
90
|
-
if (!input.tapInternalKey) {
|
|
91
|
-
const pubKey = this.client.account?.publicKey;
|
|
92
|
-
if (pubKey) {
|
|
93
|
-
const tapInternalKey = (0, toXOnly_js_1.toXOnly)((0, core_1.hexToUnit8Array)(pubKey));
|
|
94
|
-
psbt.updateInput(index, {
|
|
95
|
-
tapInternalKey,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (!input.sighashType) {
|
|
100
|
-
psbt.updateInput(index, {
|
|
101
|
-
sighashType: 1,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (addressInfo.type === core_1.AddressType.p2sh) {
|
|
106
|
-
if (!input.redeemScript) {
|
|
107
|
-
const pubKey = this.client.account?.publicKey;
|
|
108
|
-
if (pubKey) {
|
|
109
|
-
psbt.updateInput(index, {
|
|
110
|
-
redeemScript: (0, generateRedeemScript_js_1.generateRedeemScript)((0, core_1.hexToUnit8Array)(pubKey)),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
const inputsToSign = Array.from(psbt.data.inputs
|
|
117
|
-
.reduce((map, input, index) => {
|
|
118
|
-
const accountAddress = input.witnessUtxo
|
|
119
|
-
? bitcoinjs_lib_1.address.fromOutputScript(input.witnessUtxo.script, bitcoinjs_lib_1.networks.bitcoin)
|
|
120
|
-
: this.client.account?.address;
|
|
121
|
-
if (map.has(accountAddress)) {
|
|
122
|
-
map.get(accountAddress).signingIndexes.push(index);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
map.set(accountAddress, {
|
|
126
|
-
address: accountAddress,
|
|
127
|
-
sigHash: 1,
|
|
128
|
-
signingIndexes: [index],
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return map;
|
|
132
|
-
}, new Map())
|
|
133
|
-
.values());
|
|
134
|
-
const signedPsbtHex = await (0, core_1.withTimeout)(() => (0, core_1.signPsbt)(this.client, {
|
|
135
|
-
psbt: psbt.toHex(),
|
|
136
|
-
inputsToSign: inputsToSign,
|
|
137
|
-
finalize: false,
|
|
138
|
-
}), {
|
|
139
|
-
timeout: 600_000,
|
|
140
|
-
errorInstance: new sdk_1.TransactionError(sdk_1.LiFiErrorCode.TransactionExpired, 'Transaction has expired.'),
|
|
141
|
-
});
|
|
142
|
-
const signedPsbt = bitcoinjs_lib_1.Psbt.fromHex(signedPsbtHex);
|
|
143
|
-
if (!(0, isPsbtFinalized_js_1.isPsbtFinalized)(signedPsbt)) {
|
|
144
|
-
signedPsbt.finalizeAllInputs();
|
|
145
|
-
}
|
|
146
|
-
txHex = signedPsbt.extractTransaction().toHex();
|
|
147
|
-
txHash = await publicClient.sendUTXOTransaction({
|
|
148
|
-
hex: txHex,
|
|
149
|
-
});
|
|
150
|
-
action = this.statusManager.updateAction(step, action.type, 'PENDING', {
|
|
151
|
-
txHash: txHash,
|
|
152
|
-
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
|
|
153
|
-
txHex,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
let replacementReason;
|
|
157
|
-
const transaction = await (0, core_1.waitForTransaction)(publicClient, {
|
|
158
|
-
txId: txHash,
|
|
159
|
-
txHex,
|
|
160
|
-
senderAddress: this.client.account?.address,
|
|
161
|
-
onReplaced: (response) => {
|
|
162
|
-
replacementReason = response.reason;
|
|
163
|
-
action = this.statusManager.updateAction(step, action.type, 'PENDING', {
|
|
164
|
-
txHash: response.transaction.txid,
|
|
165
|
-
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.txid}`,
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
if (replacementReason === 'cancelled') {
|
|
170
|
-
throw new sdk_1.TransactionError(sdk_1.LiFiErrorCode.TransactionCanceled, 'User canceled transaction.');
|
|
171
|
-
}
|
|
172
|
-
if (transaction.txid !== txHash) {
|
|
173
|
-
action = this.statusManager.updateAction(step, action.type, 'PENDING', {
|
|
174
|
-
txHash: transaction.txid,
|
|
175
|
-
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transaction.txid}`,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
if (isBridgeExecution) {
|
|
179
|
-
action = this.statusManager.updateAction(step, action.type, 'DONE');
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch (e) {
|
|
183
|
-
const error = await (0, parseBitcoinErrors_js_1.parseBitcoinErrors)(e, step, action);
|
|
184
|
-
action = this.statusManager.updateAction(step, action.type, 'FAILED', {
|
|
185
|
-
error: {
|
|
186
|
-
message: error.cause.message,
|
|
187
|
-
code: error.code,
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
throw error;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
await (0, sdk_1.waitForDestinationChainTransaction)(client, step, action, fromChain, toChain, this.statusManager, 10_000);
|
|
194
|
-
return step;
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
exports.BitcoinStepExecutor = BitcoinStepExecutor;
|
|
198
|
-
//# sourceMappingURL=BitcoinStepExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinStepExecutor.js","sourceRoot":"","sources":["../../src/BitcoinStepExecutor.ts"],"names":[],"mappings":";;;AACA,sCAOoB;AACpB,+CAA8C;AAC9C,mCAakB;AAClB,iDAAmE;AACnE,8DAAiE;AACjE,0EAAmE;AACnE,6EAAsE;AACtE,mEAA4D;AAC5D,mDAA4C;AAM5C,MAAa,mBAAoB,SAAQ,sBAAgB;IAC/C,MAAM,CAAQ;IAEtB,YAAY,OAAmC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED,WAAW,GAAG,CAAC,IAAsB,EAAE,EAAE;QAGvC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YAC7D,MAAM,IAAI,sBAAgB,CACxB,mBAAa,CAAC,4BAA4B,EAC1C,mHAAmH,CACpH,CAAA;QACH,CAAC;IACH,CAAC,CAAA;IAED,WAAW,GAAG,KAAK,EACjB,MAAiB,EACjB,IAAs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AAE,MAAM,CAAC,CAAA;gBACvD,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE;oBACpE,KAAK,EAAE;wBACL,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;wBAC5B,IAAI,EAAE,KAAK,CAAC,IAAI;qBACjB;iBACF,CAAC,CAAA;gBACF,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;QAED,MAAM,IAAA,wCAAkC,EACtC,MAAM,EACN,IAAI,EACJ,MAAM,EACN,SAAS,EACT,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,MAAM,CACP,CAAA;QAGD,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;CACF;AAzSD,kDAySC"}
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AAA7C,qHAAA,eAAe,OAAA;AAExB,uCAA8C;AAArC,6GAAA,iBAAiB,OAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Client } from '@bigmi/core';
|
|
2
|
-
import { BaseStepExecutor, type LiFiStepExtended, type SDKClient, type StepExecutorOptions } from '@lifi/sdk';
|
|
3
|
-
interface BitcoinStepExecutorOptions extends StepExecutorOptions {
|
|
4
|
-
client: Client;
|
|
5
|
-
}
|
|
6
|
-
export declare class BitcoinStepExecutor extends BaseStepExecutor {
|
|
7
|
-
private client;
|
|
8
|
-
constructor(options: BitcoinStepExecutorOptions);
|
|
9
|
-
checkClient: (step: LiFiStepExtended) => void;
|
|
10
|
-
executeStep: (client: SDKClient, step: LiFiStepExtended) => Promise<LiFiStepExtended>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { AddressType, getAddressInfo, hexToUnit8Array, signPsbt, waitForTransaction, withTimeout, } from '@bigmi/core';
|
|
2
|
-
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
3
|
-
import { BaseStepExecutor, ChainId, checkBalance, getStepTransaction, LiFiErrorCode, stepComparison, TransactionError, waitForDestinationChainTransaction, } from '@lifi/sdk';
|
|
4
|
-
import { address, initEccLib, networks, Psbt } from 'bitcoinjs-lib';
|
|
5
|
-
import { getBitcoinPublicClient } from './client/publicClient.js';
|
|
6
|
-
import { parseBitcoinErrors } from './errors/parseBitcoinErrors.js';
|
|
7
|
-
import { generateRedeemScript } from './utils/generateRedeemScript.js';
|
|
8
|
-
import { isPsbtFinalized } from './utils/isPsbtFinalized.js';
|
|
9
|
-
import { toXOnly } from './utils/toXOnly.js';
|
|
10
|
-
export class BitcoinStepExecutor extends BaseStepExecutor {
|
|
11
|
-
client;
|
|
12
|
-
constructor(options) {
|
|
13
|
-
super(options);
|
|
14
|
-
this.client = options.client;
|
|
15
|
-
}
|
|
16
|
-
checkClient = (step) => {
|
|
17
|
-
// TODO: check chain and possibly implement chain switch?
|
|
18
|
-
// Prevent execution of the quote by wallet different from the one which requested the quote
|
|
19
|
-
if (this.client.account?.address !== step.action.fromAddress) {
|
|
20
|
-
throw new TransactionError(LiFiErrorCode.WalletChangedDuringExecution, 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.');
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
executeStep = async (client, step) => {
|
|
24
|
-
step.execution = this.statusManager.initExecutionObject(step);
|
|
25
|
-
const fromChain = await client.getChainById(step.action.fromChainId);
|
|
26
|
-
const toChain = await client.getChainById(step.action.toChainId);
|
|
27
|
-
const isBridgeExecution = fromChain.id !== toChain.id;
|
|
28
|
-
const currentActionType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP';
|
|
29
|
-
let action = this.statusManager.findOrCreateAction({
|
|
30
|
-
step,
|
|
31
|
-
type: currentActionType,
|
|
32
|
-
chainId: fromChain.id,
|
|
33
|
-
});
|
|
34
|
-
const publicClient = await getBitcoinPublicClient(client, ChainId.BTC);
|
|
35
|
-
if (action.status !== 'DONE') {
|
|
36
|
-
try {
|
|
37
|
-
let txHash;
|
|
38
|
-
let txHex;
|
|
39
|
-
if (action.txHash) {
|
|
40
|
-
// Make sure that the chain is still correct
|
|
41
|
-
this.checkClient(step);
|
|
42
|
-
// Wait for exiting transaction
|
|
43
|
-
txHash = action.txHash;
|
|
44
|
-
txHex = action.txHex;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
action = this.statusManager.updateAction(step, action.type, 'STARTED');
|
|
48
|
-
// Check balance
|
|
49
|
-
await checkBalance(client, this.client.account.address, step);
|
|
50
|
-
// Create new transaction
|
|
51
|
-
if (!step.transactionRequest) {
|
|
52
|
-
const { execution, ...stepBase } = step;
|
|
53
|
-
const updatedStep = await getStepTransaction(client, stepBase);
|
|
54
|
-
const comparedStep = await stepComparison(this.statusManager, step, updatedStep, this.allowUserInteraction, this.executionOptions);
|
|
55
|
-
Object.assign(step, {
|
|
56
|
-
...comparedStep,
|
|
57
|
-
execution: step.execution,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
if (!step.transactionRequest?.data) {
|
|
61
|
-
throw new TransactionError(LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
62
|
-
}
|
|
63
|
-
action = this.statusManager.updateAction(step, action.type, 'ACTION_REQUIRED');
|
|
64
|
-
if (!this.allowUserInteraction) {
|
|
65
|
-
return step;
|
|
66
|
-
}
|
|
67
|
-
let transactionRequest = {
|
|
68
|
-
data: step.transactionRequest.data,
|
|
69
|
-
};
|
|
70
|
-
if (this.executionOptions?.updateTransactionRequestHook) {
|
|
71
|
-
const customizedTransactionRequest = await this.executionOptions.updateTransactionRequestHook({
|
|
72
|
-
requestType: 'transaction',
|
|
73
|
-
...transactionRequest,
|
|
74
|
-
});
|
|
75
|
-
transactionRequest = {
|
|
76
|
-
...transactionRequest,
|
|
77
|
-
...customizedTransactionRequest,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
if (!transactionRequest.data) {
|
|
81
|
-
throw new TransactionError(LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
82
|
-
}
|
|
83
|
-
this.checkClient(step);
|
|
84
|
-
const psbtHex = transactionRequest.data;
|
|
85
|
-
// Initialize ECC library required for Taproot operations
|
|
86
|
-
// https://github.com/bitcoinjs/bitcoinjs-lib?tab=readme-ov-file#using-taproot
|
|
87
|
-
initEccLib(ecc);
|
|
88
|
-
const psbt = Psbt.fromHex(psbtHex, { network: networks.bitcoin });
|
|
89
|
-
psbt.data.inputs.forEach((input, index) => {
|
|
90
|
-
const accountAddress = input.witnessUtxo
|
|
91
|
-
? address.fromOutputScript(input.witnessUtxo.script, networks.bitcoin)
|
|
92
|
-
: this.client.account?.address;
|
|
93
|
-
const addressInfo = getAddressInfo(accountAddress);
|
|
94
|
-
if (addressInfo.type === AddressType.p2tr) {
|
|
95
|
-
// Taproot (P2TR) addresses require specific PSBT fields for proper signing
|
|
96
|
-
// tapInternalKey: Required for Taproot key-path spending
|
|
97
|
-
// Most wallets / libraries usually handle this already
|
|
98
|
-
if (!input.tapInternalKey) {
|
|
99
|
-
const pubKey = this.client.account?.publicKey;
|
|
100
|
-
if (pubKey) {
|
|
101
|
-
const tapInternalKey = toXOnly(hexToUnit8Array(pubKey));
|
|
102
|
-
psbt.updateInput(index, {
|
|
103
|
-
tapInternalKey,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// sighashType: Required by bitcoinjs-lib even though the bitcoin protocol allows defaults
|
|
108
|
-
// check if sighashType is default (0) or not set (undefined)
|
|
109
|
-
if (!input.sighashType) {
|
|
110
|
-
psbt.updateInput(index, {
|
|
111
|
-
sighashType: 1, // Default to Transaction.SIGHASH_ALL - 1
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// redeemScript: Required by Pay-to-Script-Hash (P2SH) addresses for proper spending
|
|
116
|
-
if (addressInfo.type === AddressType.p2sh) {
|
|
117
|
-
if (!input.redeemScript) {
|
|
118
|
-
const pubKey = this.client.account?.publicKey;
|
|
119
|
-
if (pubKey) {
|
|
120
|
-
psbt.updateInput(index, {
|
|
121
|
-
redeemScript: generateRedeemScript(hexToUnit8Array(pubKey)),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const inputsToSign = Array.from(psbt.data.inputs
|
|
128
|
-
.reduce((map, input, index) => {
|
|
129
|
-
const accountAddress = input.witnessUtxo
|
|
130
|
-
? address.fromOutputScript(input.witnessUtxo.script, networks.bitcoin)
|
|
131
|
-
: this.client.account?.address;
|
|
132
|
-
if (map.has(accountAddress)) {
|
|
133
|
-
map.get(accountAddress).signingIndexes.push(index);
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
map.set(accountAddress, {
|
|
137
|
-
address: accountAddress,
|
|
138
|
-
sigHash: 1, // Default to Transaction.SIGHASH_ALL - 1
|
|
139
|
-
signingIndexes: [index],
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
return map;
|
|
143
|
-
}, new Map())
|
|
144
|
-
.values());
|
|
145
|
-
// We give users 10 minutes to sign the transaction or it should be considered expired
|
|
146
|
-
const signedPsbtHex = await withTimeout(() => signPsbt(this.client, {
|
|
147
|
-
psbt: psbt.toHex(),
|
|
148
|
-
inputsToSign: inputsToSign,
|
|
149
|
-
finalize: false,
|
|
150
|
-
}), {
|
|
151
|
-
timeout: 600_000,
|
|
152
|
-
errorInstance: new TransactionError(LiFiErrorCode.TransactionExpired, 'Transaction has expired.'),
|
|
153
|
-
});
|
|
154
|
-
const signedPsbt = Psbt.fromHex(signedPsbtHex);
|
|
155
|
-
if (!isPsbtFinalized(signedPsbt)) {
|
|
156
|
-
signedPsbt.finalizeAllInputs();
|
|
157
|
-
}
|
|
158
|
-
txHex = signedPsbt.extractTransaction().toHex();
|
|
159
|
-
txHash = await publicClient.sendUTXOTransaction({
|
|
160
|
-
hex: txHex,
|
|
161
|
-
});
|
|
162
|
-
action = this.statusManager.updateAction(step, action.type, 'PENDING', {
|
|
163
|
-
txHash: txHash,
|
|
164
|
-
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
|
|
165
|
-
txHex,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
let replacementReason;
|
|
169
|
-
const transaction = await waitForTransaction(publicClient, {
|
|
170
|
-
txId: txHash,
|
|
171
|
-
txHex,
|
|
172
|
-
senderAddress: this.client.account?.address,
|
|
173
|
-
onReplaced: (response) => {
|
|
174
|
-
replacementReason = response.reason;
|
|
175
|
-
action = this.statusManager.updateAction(step, action.type, 'PENDING', {
|
|
176
|
-
txHash: response.transaction.txid,
|
|
177
|
-
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.txid}`,
|
|
178
|
-
});
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
if (replacementReason === 'cancelled') {
|
|
182
|
-
throw new TransactionError(LiFiErrorCode.TransactionCanceled, 'User canceled transaction.');
|
|
183
|
-
}
|
|
184
|
-
if (transaction.txid !== txHash) {
|
|
185
|
-
action = this.statusManager.updateAction(step, action.type, 'PENDING', {
|
|
186
|
-
txHash: transaction.txid,
|
|
187
|
-
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transaction.txid}`,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
if (isBridgeExecution) {
|
|
191
|
-
action = this.statusManager.updateAction(step, action.type, 'DONE');
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
catch (e) {
|
|
195
|
-
const error = await parseBitcoinErrors(e, step, action);
|
|
196
|
-
action = this.statusManager.updateAction(step, action.type, 'FAILED', {
|
|
197
|
-
error: {
|
|
198
|
-
message: error.cause.message,
|
|
199
|
-
code: error.code,
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
throw error;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
await waitForDestinationChainTransaction(client, step, action, fromChain, toChain, this.statusManager, 10_000);
|
|
206
|
-
// DONE
|
|
207
|
-
return step;
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
//# sourceMappingURL=BitcoinStepExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinStepExecutor.js","sourceRoot":"","sources":["../../src/BitcoinStepExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,WAAW,GACZ,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAA;AAC9C,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,aAAa,EAIb,cAAc,EACd,gBAAgB,EAEhB,kCAAkC,GACnC,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAM5C,MAAM,OAAO,mBAAoB,SAAQ,gBAAgB;IAC/C,MAAM,CAAQ;IAEtB,YAAY,OAAmC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED,WAAW,GAAG,CAAC,IAAsB,EAAE,EAAE;QACvC,yDAAyD;QACzD,4FAA4F;QAC5F,IAAI,IAAI,CAA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AAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,IAAI,EAAE;qBAC3E,CACF,CAAA;gBACH,CAAC;gBAED,IAAI,iBAAiB,EAAE,CAAC;oBACtB,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;gBACrE,CAAC;YACH,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;gBACvD,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE;oBACpE,KAAK,EAAE;wBACL,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;wBAC5B,IAAI,EAAE,KAAK,CAAC,IAAI;qBACjB;iBACF,CAAC,CAAA;gBACF,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;QAED,MAAM,kCAAkC,CACtC,MAAM,EACN,IAAI,EACJ,MAAM,EACN,SAAS,EACT,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,MAAM,CACP,CAAA;QAED,OAAO;QACP,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;CACF"}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinProvider.d.ts","sourceRoot":"","sources":["../../src/BitcoinProvider.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE5E,wBAAgB,eAAe,CAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,kBAAkB,CAgCpB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Client } from '@bigmi/core';
|
|
2
|
-
import { BaseStepExecutor, type LiFiStepExtended, type SDKClient, type StepExecutorOptions } from '@lifi/sdk';
|
|
3
|
-
interface BitcoinStepExecutorOptions extends StepExecutorOptions {
|
|
4
|
-
client: Client;
|
|
5
|
-
}
|
|
6
|
-
export declare class BitcoinStepExecutor extends BaseStepExecutor {
|
|
7
|
-
private client;
|
|
8
|
-
constructor(options: BitcoinStepExecutorOptions);
|
|
9
|
-
checkClient: (step: LiFiStepExtended) => void;
|
|
10
|
-
executeStep: (client: SDKClient, step: LiFiStepExtended) => Promise<LiFiStepExtended>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=BitcoinStepExecutor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinStepExecutor.d.ts","sourceRoot":"","sources":["../../src/BitcoinStepExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAA;AAU5D,OAAO,EACL,gBAAgB,EAKhB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,mBAAmB,EAKzB,MAAM,WAAW,CAAA;AAQlB,UAAU,0BAA2B,SAAQ,mBAAmB;IAC9D,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,mBAAoB,SAAQ,gBAAgB;IACvD,OAAO,CAAC,MAAM,CAAQ;gBAEV,OAAO,EAAE,0BAA0B;IAK/C,WAAW,GAAI,MAAM,gBAAgB,UASpC;IAED,WAAW,GACT,QAAQ,SAAS,EACjB,MAAM,gBAAgB,KACrB,OAAO,CAAC,gBAAgB,CAAC,CAkR3B;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBitcoinBalance.d.ts","sourceRoot":"","sources":["../../../src/actions/getBitcoinBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,WAAW,EACjB,MAAM,WAAW,CAAA;AAGlB,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,SAAS,EACjB,eAAe,MAAM,EACrB,QAAQ,KAAK,EAAE,KACd,OAAO,CAAC,WAAW,EAAE,CAqBvB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBitcoinAddress.d.ts","sourceRoot":"","sources":["../../../src/actions/resolveBitcoinAddress.ts"],"names":[],"mappings":"AAAA,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG7B"}
|