@lifi/sdk-provider-bitcoin 4.0.0-alpha.8 → 4.0.0-beta.0
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.js +1 -1
- package/dist/cjs/BitcoinProvider.js.map +1 -1
- package/dist/cjs/client/publicClient.d.ts +1 -2
- package/dist/cjs/core/BitcoinStepExecutor.d.ts +15 -0
- package/dist/cjs/core/BitcoinStepExecutor.js +53 -0
- package/dist/cjs/core/BitcoinStepExecutor.js.map +1 -0
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.d.ts +5 -0
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js +101 -0
- package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -0
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.d.ts +5 -0
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js +45 -0
- package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/errors/parseBitcoinErrors.d.ts +2 -2
- package/dist/cjs/errors/parseBitcoinErrors.js +3 -3
- package/dist/cjs/errors/parseBitcoinErrors.js.map +1 -1
- package/dist/cjs/types.d.ts +7 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/BitcoinProvider.js +1 -1
- package/dist/esm/BitcoinProvider.js.map +1 -1
- package/dist/esm/client/publicClient.d.ts +1 -2
- package/dist/esm/core/BitcoinStepExecutor.d.ts +15 -0
- package/dist/esm/core/BitcoinStepExecutor.js +51 -0
- package/dist/esm/core/BitcoinStepExecutor.js.map +1 -0
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts +5 -0
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js +106 -0
- package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -0
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts +5 -0
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js +41 -0
- package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -0
- package/dist/esm/errors/parseBitcoinErrors.d.ts +2 -2
- package/dist/esm/errors/parseBitcoinErrors.js +3 -3
- package/dist/esm/errors/parseBitcoinErrors.js.map +1 -1
- package/dist/esm/types.d.ts +7 -1
- package/dist/esm/types.js +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/client/publicClient.d.ts +1 -2
- package/dist/types/client/publicClient.d.ts.map +1 -1
- package/dist/types/core/BitcoinStepExecutor.d.ts +16 -0
- package/dist/types/core/BitcoinStepExecutor.d.ts.map +1 -0
- package/dist/types/core/tasks/BitcoinSignAndExecuteTask.d.ts +6 -0
- package/dist/types/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +1 -0
- package/dist/types/core/tasks/BitcoinWaitForTransactionTask.d.ts +6 -0
- package/dist/types/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +1 -0
- package/dist/types/errors/parseBitcoinErrors.d.ts +2 -2
- package/dist/types/errors/parseBitcoinErrors.d.ts.map +1 -1
- package/dist/types/types.d.ts +7 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/BitcoinProvider.ts +1 -1
- package/src/client/publicClient.ts +1 -1
- package/src/core/BitcoinStepExecutor.ts +98 -0
- package/src/core/tasks/BitcoinSignAndExecuteTask.ts +168 -0
- package/src/core/tasks/BitcoinWaitForTransactionTask.ts +74 -0
- package/src/errors/parseBitcoinErrors.ts +4 -4
- package/src/types.ts +13 -1
- package/src/version.ts +1 -1
- package/dist/cjs/BitcoinStepExecutor.d.ts +0 -12
- package/dist/cjs/BitcoinStepExecutor.js +0 -199
- package/dist/cjs/BitcoinStepExecutor.js.map +0 -1
- package/dist/esm/BitcoinStepExecutor.d.ts +0 -12
- package/dist/esm/BitcoinStepExecutor.js +0 -212
- package/dist/esm/BitcoinStepExecutor.js.map +0 -1
- package/dist/types/BitcoinStepExecutor.d.ts +0 -13
- package/dist/types/BitcoinStepExecutor.d.ts.map +0 -1
- package/src/BitcoinStepExecutor.ts +0 -344
|
@@ -5,7 +5,7 @@ const core_1 = require("@bigmi/core");
|
|
|
5
5
|
const sdk_1 = require("@lifi/sdk");
|
|
6
6
|
const getBitcoinBalance_js_1 = require("./actions/getBitcoinBalance.js");
|
|
7
7
|
const resolveBitcoinAddress_js_1 = require("./actions/resolveBitcoinAddress.js");
|
|
8
|
-
const BitcoinStepExecutor_js_1 = require("./BitcoinStepExecutor.js");
|
|
8
|
+
const BitcoinStepExecutor_js_1 = require("./core/BitcoinStepExecutor.js");
|
|
9
9
|
function BitcoinProvider(options) {
|
|
10
10
|
const _options = options ?? {};
|
|
11
11
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinProvider.js","sourceRoot":"","sources":["../../src/BitcoinProvider.ts"],"names":[],"mappings":";;AAOA,0CAkCC;AAzCD,sCAA2C;AAC3C,mCAA+D;AAC/D,yEAAkE;AAClE,iFAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"BitcoinProvider.js","sourceRoot":"","sources":["../../src/BitcoinProvider.ts"],"names":[],"mappings":";;AAOA,0CAkCC;AAzCD,sCAA2C;AAC3C,mCAA+D;AAC/D,yEAAkE;AAClE,iFAA0E;AAC1E,0EAAmE;AAGnE,SAAgB,eAAe,CAC7B,OAAgC;IAEhC,MAAM,QAAQ,GAA2B,OAAO,IAAI,EAAE,CAAA;IACtD,OAAO;QACL,IAAI,IAAI;YACN,OAAO,eAAS,CAAC,IAAI,CAAA;QACvB,CAAC;QACD,SAAS,EAAE,oBAAa;QACxB,cAAc,EAAE,gDAAqB;QACrC,UAAU,EAAE,wCAAiB;QAC7B,KAAK,CAAC,eAAe,CACnB,OAA4B;YAE5B,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;YAC5C,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAA;YAErD,MAAM,QAAQ,GAAG,IAAI,4CAAmB,CAAC;gBACvC,MAAM,EAAE,YAAY;gBACpB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,gBAAgB,EAAE;oBAChB,GAAG,OAAO,CAAC,gBAAgB;iBAC5B;aACF,CAAC,CAAA;YAEF,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,UAAU,CAAC,OAA+B;YACxC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Account, type Chain, type Client, type FallbackTransport, type HttpTransport, type PublicActions, type UTXOSchema, type WalletActions } from '@bigmi/core';
|
|
2
2
|
import type { SDKClient } from '@lifi/sdk';
|
|
3
|
-
type PublicClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account | undefined, UTXOSchema, PublicActions & WalletActions>;
|
|
3
|
+
export type PublicClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account | undefined, UTXOSchema, PublicActions & WalletActions>;
|
|
4
4
|
export declare const getBitcoinPublicClient: (client: SDKClient, chainId: number) => Promise<PublicClient>;
|
|
5
|
-
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Client } from '@bigmi/core';
|
|
2
|
+
import { BaseStepExecutor, type ExecutionAction, type LiFiStepExtended, type SDKError, type StepExecutorBaseContext, type StepExecutorOptions, TaskPipeline } from '@lifi/sdk';
|
|
3
|
+
import type { BitcoinStepExecutorContext } from '../types.js';
|
|
4
|
+
interface BitcoinStepExecutorOptions extends StepExecutorOptions {
|
|
5
|
+
client: Client;
|
|
6
|
+
}
|
|
7
|
+
export declare class BitcoinStepExecutor extends BaseStepExecutor {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(options: BitcoinStepExecutorOptions);
|
|
10
|
+
checkClient: (step: LiFiStepExtended) => void;
|
|
11
|
+
createPipeline: (context: BitcoinStepExecutorContext) => TaskPipeline;
|
|
12
|
+
parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
|
|
13
|
+
createContext: (baseContext: StepExecutorBaseContext) => Promise<BitcoinStepExecutorContext>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitcoinStepExecutor = void 0;
|
|
4
|
+
const sdk_1 = require("@lifi/sdk");
|
|
5
|
+
const publicClient_js_1 = require("../client/publicClient.js");
|
|
6
|
+
const parseBitcoinErrors_js_1 = require("../errors/parseBitcoinErrors.js");
|
|
7
|
+
const BitcoinSignAndExecuteTask_js_1 = require("./tasks/BitcoinSignAndExecuteTask.js");
|
|
8
|
+
const BitcoinWaitForTransactionTask_js_1 = require("./tasks/BitcoinWaitForTransactionTask.js");
|
|
9
|
+
class BitcoinStepExecutor extends sdk_1.BaseStepExecutor {
|
|
10
|
+
client;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.client = options.client;
|
|
14
|
+
}
|
|
15
|
+
checkClient = (step) => {
|
|
16
|
+
if (this.client.account?.address !== step.action.fromAddress) {
|
|
17
|
+
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.');
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
createPipeline = (context) => {
|
|
21
|
+
const { step, isBridgeExecution } = context;
|
|
22
|
+
const tasks = [
|
|
23
|
+
new sdk_1.CheckBalanceTask(),
|
|
24
|
+
new sdk_1.PrepareTransactionTask(),
|
|
25
|
+
new BitcoinSignAndExecuteTask_js_1.BitcoinSignAndExecuteTask(),
|
|
26
|
+
new BitcoinWaitForTransactionTask_js_1.BitcoinWaitForTransactionTask(),
|
|
27
|
+
new sdk_1.WaitForTransactionStatusTask(isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'),
|
|
28
|
+
];
|
|
29
|
+
const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP');
|
|
30
|
+
const taskName = swapOrBridgeAction?.txHash
|
|
31
|
+
? swapOrBridgeAction?.status === 'DONE'
|
|
32
|
+
? sdk_1.WaitForTransactionStatusTask.name
|
|
33
|
+
: BitcoinWaitForTransactionTask_js_1.BitcoinWaitForTransactionTask.name
|
|
34
|
+
: sdk_1.CheckBalanceTask.name;
|
|
35
|
+
const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
|
|
36
|
+
const tasksToRun = tasks.slice(firstTaskIndex);
|
|
37
|
+
return new sdk_1.TaskPipeline(tasksToRun);
|
|
38
|
+
};
|
|
39
|
+
parseErrors = (error, step, action) => (0, parseBitcoinErrors_js_1.parseBitcoinErrors)(error, step, action);
|
|
40
|
+
createContext = async (baseContext) => {
|
|
41
|
+
const { client, fromChain } = baseContext;
|
|
42
|
+
const publicClient = await (0, publicClient_js_1.getBitcoinPublicClient)(client, fromChain.id);
|
|
43
|
+
return {
|
|
44
|
+
...baseContext,
|
|
45
|
+
pollingIntervalMs: 10_000,
|
|
46
|
+
checkClient: this.checkClient,
|
|
47
|
+
walletClient: this.client,
|
|
48
|
+
publicClient,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.BitcoinStepExecutor = BitcoinStepExecutor;
|
|
53
|
+
//# sourceMappingURL=BitcoinStepExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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AAC,CAAC,gEAA6B,CAAC,IAAI;YACtC,CAAC,CAAC,sBAAgB,CAAC,IAAI,CAAA;QAEzB,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,CACpC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAC7C,CAAA;QAED,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QAE9C,OAAO,IAAI,kBAAY,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC,CAAA;IAEQ,WAAW,GAAG,CACrB,KAAY,EACZ,IAAuB,EACvB,MAAwB,EACL,EAAE,CAAC,IAAA,0CAAkB,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAEtD,aAAa,GAAG,KAAK,EAC5B,WAAoC,EACC,EAAE;QACvC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,WAAW,CAAA;QAEzC,MAAM,YAAY,GAAG,MAAM,IAAA,wCAAsB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;QAEvE,OAAO;YACL,GAAG,WAAW;YACd,iBAAiB,EAAE,MAAM;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,MAAM;YACzB,YAAY;SACb,CAAA;IACH,CAAC,CAAA;CACF;AAxED,kDAwEC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk';
|
|
2
|
+
import type { BitcoinStepExecutorContext } from '../../types.js';
|
|
3
|
+
export declare class BitcoinSignAndExecuteTask extends BaseStepExecutionTask {
|
|
4
|
+
run(context: BitcoinStepExecutorContext): Promise<TaskResult>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitcoinSignAndExecuteTask = 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 generateRedeemScript_js_1 = require("../../utils/generateRedeemScript.js");
|
|
9
|
+
const isPsbtFinalized_js_1 = require("../../utils/isPsbtFinalized.js");
|
|
10
|
+
const toXOnly_js_1 = require("../../utils/toXOnly.js");
|
|
11
|
+
class BitcoinSignAndExecuteTask extends sdk_1.BaseStepExecutionTask {
|
|
12
|
+
async run(context) {
|
|
13
|
+
const { step, walletClient, statusManager, executionOptions, fromChain, publicClient, checkClient, isBridgeExecution, } = context;
|
|
14
|
+
const action = statusManager.findAction(step, isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP');
|
|
15
|
+
if (!action) {
|
|
16
|
+
throw new sdk_1.TransactionError(sdk_1.LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction. Action not found.');
|
|
17
|
+
}
|
|
18
|
+
const transactionRequestData = await (0, sdk_1.getTransactionRequestData)(step, executionOptions);
|
|
19
|
+
checkClient(step);
|
|
20
|
+
const psbtHex = transactionRequestData;
|
|
21
|
+
(0, bitcoinjs_lib_1.initEccLib)(ecc);
|
|
22
|
+
const psbt = bitcoinjs_lib_1.Psbt.fromHex(psbtHex, { network: bitcoinjs_lib_1.networks.bitcoin });
|
|
23
|
+
psbt.data.inputs.forEach((input, index) => {
|
|
24
|
+
const accountAddress = input.witnessUtxo
|
|
25
|
+
? bitcoinjs_lib_1.address.fromOutputScript(input.witnessUtxo.script, bitcoinjs_lib_1.networks.bitcoin)
|
|
26
|
+
: walletClient.account?.address;
|
|
27
|
+
const addressInfo = (0, core_1.getAddressInfo)(accountAddress);
|
|
28
|
+
if (addressInfo.type === core_1.AddressType.p2tr) {
|
|
29
|
+
if (!input.tapInternalKey) {
|
|
30
|
+
const pubKey = walletClient.account?.publicKey;
|
|
31
|
+
if (pubKey) {
|
|
32
|
+
const tapInternalKey = (0, toXOnly_js_1.toXOnly)((0, core_1.hexToUnit8Array)(pubKey));
|
|
33
|
+
psbt.updateInput(index, {
|
|
34
|
+
tapInternalKey,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!input.sighashType) {
|
|
39
|
+
psbt.updateInput(index, {
|
|
40
|
+
sighashType: 1,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (addressInfo.type === core_1.AddressType.p2sh) {
|
|
45
|
+
if (!input.redeemScript) {
|
|
46
|
+
const pubKey = walletClient.account?.publicKey;
|
|
47
|
+
if (pubKey) {
|
|
48
|
+
psbt.updateInput(index, {
|
|
49
|
+
redeemScript: (0, generateRedeemScript_js_1.generateRedeemScript)((0, core_1.hexToUnit8Array)(pubKey)),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const inputsToSign = Array.from(psbt.data.inputs
|
|
56
|
+
.reduce((map, input, index) => {
|
|
57
|
+
const accountAddress = input.witnessUtxo
|
|
58
|
+
? bitcoinjs_lib_1.address.fromOutputScript(input.witnessUtxo.script, bitcoinjs_lib_1.networks.bitcoin)
|
|
59
|
+
: walletClient.account?.address;
|
|
60
|
+
if (map.has(accountAddress)) {
|
|
61
|
+
map.get(accountAddress).signingIndexes.push(index);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
map.set(accountAddress, {
|
|
65
|
+
address: accountAddress,
|
|
66
|
+
sigHash: 1,
|
|
67
|
+
signingIndexes: [index],
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return map;
|
|
71
|
+
}, new Map())
|
|
72
|
+
.values());
|
|
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
|
+
}
|
|
100
|
+
exports.BitcoinSignAndExecuteTask = BitcoinSignAndExecuteTask;
|
|
101
|
+
//# sourceMappingURL=BitcoinSignAndExecuteTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitcoinSignAndExecuteTask.js","sourceRoot":"","sources":["../../../../src/core/tasks/BitcoinSignAndExecuteTask.ts"],"names":[],"mappings":";;;AAAA,sCAMoB;AACpB,+CAA8C;AAC9C,mCAMkB;AAClB,iDAAmE;AAEnE,iFAA0E;AAC1E,uEAAgE;AAChE,uDAAgD;AAEhD,MAAa,yBAA0B,SAAQ,2BAAqB;IAClE,KAAK,CAAC,GAAG,CAAC,OAAmC;QAC3C,MAAM,EACJ,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,YAAY,EAC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O;YACL,MAAM,EAAE,WAAW;SACpB,CAAA;IACH,CAAC;CACF;AAlJD,8DAkJC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitcoinWaitForTransactionTask = void 0;
|
|
4
|
+
const core_1 = require("@bigmi/core");
|
|
5
|
+
const sdk_1 = require("@lifi/sdk");
|
|
6
|
+
class BitcoinWaitForTransactionTask extends sdk_1.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) {
|
|
13
|
+
throw new sdk_1.TransactionError(sdk_1.LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction. Transaction hash or hex is not set.');
|
|
14
|
+
}
|
|
15
|
+
checkClient(step);
|
|
16
|
+
let replacementReason;
|
|
17
|
+
const transaction = await (0, core_1.waitForTransaction)(publicClient, {
|
|
18
|
+
txId: txHash,
|
|
19
|
+
txHex,
|
|
20
|
+
senderAddress: walletClient.account?.address,
|
|
21
|
+
onReplaced: (response) => {
|
|
22
|
+
replacementReason = response.reason;
|
|
23
|
+
statusManager.updateAction(step, action.type, 'PENDING', {
|
|
24
|
+
txHash: response.transaction.txid,
|
|
25
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.txid}`,
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (replacementReason === 'cancelled') {
|
|
30
|
+
throw new sdk_1.TransactionError(sdk_1.LiFiErrorCode.TransactionCanceled, 'User canceled transaction.');
|
|
31
|
+
}
|
|
32
|
+
if (transaction.txid !== txHash) {
|
|
33
|
+
statusManager.updateAction(step, action.type, 'PENDING', {
|
|
34
|
+
txHash: transaction.txid,
|
|
35
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transaction.txid}`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (isBridgeExecution) {
|
|
39
|
+
statusManager.updateAction(step, action.type, 'DONE');
|
|
40
|
+
}
|
|
41
|
+
return { status: 'COMPLETED' };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.BitcoinWaitForTransactionTask = BitcoinWaitForTransactionTask;
|
|
45
|
+
//# sourceMappingURL=BitcoinWaitForTransactionTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitcoinWaitForTransactionTask.js","sourceRoot":"","sources":["../../../../src/core/tasks/BitcoinWaitForTransactionTask.ts"],"names":[],"mappings":";;;AACA,sCAAgD;AAChD,mCAKkB;AAGlB,MAAa,6BAA8B,SAAQ,2BAAqB;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,CA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C,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACvD,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAA;IAChC,CAAC;CACF;AA/DD,sEA+DC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare const parseBitcoinErrors: (e: Error, step?: LiFiStep,
|
|
1
|
+
import { type ExecutionAction, type LiFiStep, SDKError } from '@lifi/sdk';
|
|
2
|
+
export declare const parseBitcoinErrors: (e: Error, step?: LiFiStep, action?: ExecutionAction) => Promise<SDKError>;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseBitcoinErrors = void 0;
|
|
4
4
|
const sdk_1 = require("@lifi/sdk");
|
|
5
|
-
const parseBitcoinErrors = async (e, step,
|
|
5
|
+
const parseBitcoinErrors = async (e, step, action) => {
|
|
6
6
|
if (e instanceof sdk_1.SDKError) {
|
|
7
7
|
e.step = e.step ?? step;
|
|
8
|
-
e.
|
|
8
|
+
e.action = e.action ?? action;
|
|
9
9
|
return e;
|
|
10
10
|
}
|
|
11
11
|
const baseError = handleSpecificErrors(e);
|
|
12
|
-
return new sdk_1.SDKError(baseError, step,
|
|
12
|
+
return new sdk_1.SDKError(baseError, step, action);
|
|
13
13
|
};
|
|
14
14
|
exports.parseBitcoinErrors = parseBitcoinErrors;
|
|
15
15
|
const handleSpecificErrors = (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBitcoinErrors.js","sourceRoot":"","sources":["../../../src/errors/parseBitcoinErrors.ts"],"names":[],"mappings":";;;AAAA,mCASkB;AAEX,MAAM,kBAAkB,GAAG,KAAK,EACrC,CAAQ,EACR,IAAe,EACf,
|
|
1
|
+
{"version":3,"file":"parseBitcoinErrors.js","sourceRoot":"","sources":["../../../src/errors/parseBitcoinErrors.ts"],"names":[],"mappings":";;;AAAA,mCASk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,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACnE,CAAC;IAED,IAAI,CAAC,YAAY,eAAS,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAA;IACV,CAAC;IAED,OAAO,IAAI,kBAAY,CAAC,CAAC,CAAC,OAAO,IAAI,kBAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAA;AACpE,CAAC,CAAA"}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { Client } from '@bigmi/core';
|
|
2
|
-
import { type SDKProvider } from '@lifi/sdk';
|
|
2
|
+
import { type LiFiStepExtended, type SDKProvider, type StepExecutorContext } from '@lifi/sdk';
|
|
3
|
+
import type { PublicClient } from './client/publicClient.js';
|
|
3
4
|
export interface BitcoinProviderOptions {
|
|
4
5
|
getWalletClient?: () => Promise<Client>;
|
|
5
6
|
}
|
|
7
|
+
export interface BitcoinStepExecutorContext extends StepExecutorContext {
|
|
8
|
+
walletClient: Client;
|
|
9
|
+
publicClient: PublicClient;
|
|
10
|
+
checkClient: (step: LiFiStepExtended) => void;
|
|
11
|
+
}
|
|
6
12
|
export interface BitcoinSDKProvider extends SDKProvider {
|
|
7
13
|
setOptions(options: BitcoinProviderOptions): void;
|
|
8
14
|
}
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;AAuBA,8CAIC;AA1BD,mCAKkB;AAiBlB,SAAgB,iBAAiB,CAC/B,QAAqB;IAErB,OAAO,QAAQ,CAAC,IAAI,KAAK,eAAS,CAAC,IAAI,CAAA;AACzC,CAAC"}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk-provider-bitcoin";
|
|
2
|
-
export declare const version = "4.0.0-
|
|
2
|
+
export declare const version = "4.0.0-beta.0";
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,4BAA4B,CAAA;AACnC,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,4BAA4B,CAAA;AACnC,QAAA,OAAO,GAAG,cAAc,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { isUTXOAddress } from '@bigmi/core';
|
|
|
2
2
|
import { ChainType } from '@lifi/sdk';
|
|
3
3
|
import { getBitcoinBalance } from './actions/getBitcoinBalance.js';
|
|
4
4
|
import { resolveBitcoinAddress } from './actions/resolveBitcoinAddress.js';
|
|
5
|
-
import { BitcoinStepExecutor } from './BitcoinStepExecutor.js';
|
|
5
|
+
import { BitcoinStepExecutor } from './core/BitcoinStepExecutor.js';
|
|
6
6
|
export function BitcoinProvider(options) {
|
|
7
7
|
const _options = options ?? {};
|
|
8
8
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinProvider.js","sourceRoot":"","sources":["../../src/BitcoinProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,SAAS,EAA4B,MAAM,WAAW,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"BitcoinProvider.js","sourceRoot":"","sources":["../../src/BitcoinProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,SAAS,EAA4B,MAAM,WAAW,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAGnE,MAAM,UAAU,eAAe,CAC7B,OAAgC;IAEhC,MAAM,QAAQ,GAA2B,OAAO,IAAI,EAAE,CAAA;IACtD,OAAO;QACL,IAAI,IAAI;YACN,OAAO,SAAS,CAAC,IAAI,CAAA;QACvB,CAAC;QACD,SAAS,EAAE,aAAa;QACxB,cAAc,EAAE,qBAAqB;QACrC,UAAU,EAAE,iBAAiB;QAC7B,KAAK,CAAC,eAAe,CACnB,OAA4B;YAE5B,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;YAC5C,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAA;YAErD,MAAM,QAAQ,GAAG,IAAI,mBAAmB,CAAC;gBACvC,MAAM,EAAE,YAAY;gBACpB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,gBAAgB,EAAE;oBAChB,GAAG,OAAO,CAAC,gBAAgB;iBAC5B;aACF,CAAC,CAAA;YAEF,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,UAAU,CAAC,OAA+B;YACxC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Account, type Chain, type Client, type FallbackTransport, type HttpTransport, type PublicActions, type UTXOSchema, type WalletActions } from '@bigmi/core';
|
|
2
2
|
import type { SDKClient } from '@lifi/sdk';
|
|
3
|
-
type PublicClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account | undefined, UTXOSchema, PublicActions & WalletActions>;
|
|
3
|
+
export type PublicClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account | undefined, UTXOSchema, PublicActions & WalletActions>;
|
|
4
4
|
/**
|
|
5
5
|
* Get an instance of a provider for a specific chain
|
|
6
6
|
* @param client - The SDK client
|
|
@@ -8,4 +8,3 @@ type PublicClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, A
|
|
|
8
8
|
* @returns The public client for the given chain
|
|
9
9
|
*/
|
|
10
10
|
export declare const getBitcoinPublicClient: (client: SDKClient, chainId: number) => Promise<PublicClient>;
|
|
11
|
-
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Client } from '@bigmi/core';
|
|
2
|
+
import { BaseStepExecutor, type ExecutionAction, type LiFiStepExtended, type SDKError, type StepExecutorBaseContext, type StepExecutorOptions, TaskPipeline } from '@lifi/sdk';
|
|
3
|
+
import type { BitcoinStepExecutorContext } from '../types.js';
|
|
4
|
+
interface BitcoinStepExecutorOptions extends StepExecutorOptions {
|
|
5
|
+
client: Client;
|
|
6
|
+
}
|
|
7
|
+
export declare class BitcoinStepExecutor extends BaseStepExecutor {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(options: BitcoinStepExecutorOptions);
|
|
10
|
+
checkClient: (step: LiFiStepExtended) => void;
|
|
11
|
+
createPipeline: (context: BitcoinStepExecutorContext) => TaskPipeline;
|
|
12
|
+
parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
|
|
13
|
+
createContext: (baseContext: StepExecutorBaseContext) => Promise<BitcoinStepExecutorContext>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseStepExecutor, CheckBalanceTask, LiFiErrorCode, PrepareTransactionTask, TaskPipeline, TransactionError, WaitForTransactionStatusTask, } from '@lifi/sdk';
|
|
2
|
+
import { getBitcoinPublicClient } from '../client/publicClient.js';
|
|
3
|
+
import { parseBitcoinErrors } from '../errors/parseBitcoinErrors.js';
|
|
4
|
+
import { BitcoinSignAndExecuteTask } from './tasks/BitcoinSignAndExecuteTask.js';
|
|
5
|
+
import { BitcoinWaitForTransactionTask } from './tasks/BitcoinWaitForTransactionTask.js';
|
|
6
|
+
export class BitcoinStepExecutor extends BaseStepExecutor {
|
|
7
|
+
client;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
super(options);
|
|
10
|
+
this.client = options.client;
|
|
11
|
+
}
|
|
12
|
+
checkClient = (step) => {
|
|
13
|
+
// TODO: check chain and possibly implement chain switch?
|
|
14
|
+
// Prevent execution of the quote by wallet different from the one which requested the quote
|
|
15
|
+
if (this.client.account?.address !== step.action.fromAddress) {
|
|
16
|
+
throw new TransactionError(LiFiErrorCode.WalletChangedDuringExecution, 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
createPipeline = (context) => {
|
|
20
|
+
const { step, isBridgeExecution } = context;
|
|
21
|
+
const tasks = [
|
|
22
|
+
new CheckBalanceTask(),
|
|
23
|
+
new PrepareTransactionTask(),
|
|
24
|
+
new BitcoinSignAndExecuteTask(),
|
|
25
|
+
new BitcoinWaitForTransactionTask(),
|
|
26
|
+
new WaitForTransactionStatusTask(isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'),
|
|
27
|
+
];
|
|
28
|
+
const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP');
|
|
29
|
+
const taskName = swapOrBridgeAction?.txHash
|
|
30
|
+
? swapOrBridgeAction?.status === 'DONE'
|
|
31
|
+
? WaitForTransactionStatusTask.name
|
|
32
|
+
: BitcoinWaitForTransactionTask.name
|
|
33
|
+
: CheckBalanceTask.name;
|
|
34
|
+
const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
|
|
35
|
+
const tasksToRun = tasks.slice(firstTaskIndex);
|
|
36
|
+
return new TaskPipeline(tasksToRun);
|
|
37
|
+
};
|
|
38
|
+
parseErrors = (error, step, action) => parseBitcoinErrors(error, step, action);
|
|
39
|
+
createContext = async (baseContext) => {
|
|
40
|
+
const { client, fromChain } = baseContext;
|
|
41
|
+
const publicClient = await getBitcoinPublicClient(client, fromChain.id);
|
|
42
|
+
return {
|
|
43
|
+
...baseContext,
|
|
44
|
+
pollingIntervalMs: 10_000,
|
|
45
|
+
checkClient: this.checkClient,
|
|
46
|
+
walletClient: this.client,
|
|
47
|
+
publicClient,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=BitcoinStepExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitcoinStepExecutor.js","sourceRoot":"","sources":["../../../src/core/BitcoinStepExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAEhB,aAAa,EAEb,sBAAsB,EAItB,YAAY,EACZ,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAEpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAA;AAMxF,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,CAAC,MAAM,CAAC,OAA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AAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAEtD,aAAa,GAAG,KAAK,EAC5B,WAAoC,EACC,EAAE;QACvC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,WAAW,CAAA;QAEzC,MAAM,YAAY,GAAG,MAAM,sBAAsB,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;QAEvE,OAAO;YACL,GAAG,WAAW;YACd,iBAAiB,EAAE,MAAM;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,MAAM;YACzB,YAAY;SACb,CAAA;IACH,CAAC,CAAA;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk';
|
|
2
|
+
import type { BitcoinStepExecutorContext } from '../../types.js';
|
|
3
|
+
export declare class BitcoinSignAndExecuteTask extends BaseStepExecutionTask {
|
|
4
|
+
run(context: BitcoinStepExecutorContext): Promise<TaskResult>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
}
|
|
106
|
+
//# sourceMappingURL=BitcoinSignAndExecuteTask.js.map
|
|
@@ -0,0 +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,W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AE;YAChE,KAAK;YACL,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE;SACrB,CAAC,CAAA;QAEF,OAAO;YACL,MAAM,EAAE,WAAW;SACpB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
5
|
+
}
|