@arkade-os/skill 0.1.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/README.md +116 -0
- package/SKILL.md +269 -0
- package/cli/arkade.mjs +1018 -0
- package/dist/cjs/index.js +88 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/skills/arkadeBitcoin.js +359 -0
- package/dist/cjs/skills/arkadeBitcoin.js.map +1 -0
- package/dist/cjs/skills/index.js +78 -0
- package/dist/cjs/skills/index.js.map +1 -0
- package/dist/cjs/skills/lendaswap.js +458 -0
- package/dist/cjs/skills/lendaswap.js.map +1 -0
- package/dist/cjs/skills/lightning.js +287 -0
- package/dist/cjs/skills/lightning.js.map +1 -0
- package/dist/cjs/skills/types.js +11 -0
- package/dist/cjs/skills/types.js.map +1 -0
- package/dist/esm/index.js +72 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/skills/arkadeBitcoin.js +354 -0
- package/dist/esm/skills/arkadeBitcoin.js.map +1 -0
- package/dist/esm/skills/index.js +69 -0
- package/dist/esm/skills/index.js.map +1 -0
- package/dist/esm/skills/lendaswap.js +453 -0
- package/dist/esm/skills/lendaswap.js.map +1 -0
- package/dist/esm/skills/lightning.js +282 -0
- package/dist/esm/skills/lightning.js.map +1 -0
- package/dist/esm/skills/types.js +10 -0
- package/dist/esm/skills/types.js.map +1 -0
- package/dist/types/index.d.ts +72 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/skills/arkadeBitcoin.d.ts +218 -0
- package/dist/types/skills/arkadeBitcoin.d.ts.map +1 -0
- package/dist/types/skills/index.d.ts +67 -0
- package/dist/types/skills/index.d.ts.map +1 -0
- package/dist/types/skills/lendaswap.d.ts +152 -0
- package/dist/types/skills/lendaswap.d.ts.map +1 -0
- package/dist/types/skills/lightning.d.ts +181 -0
- package/dist/types/skills/lightning.d.ts.map +1 -0
- package/dist/types/skills/types.d.ts +548 -0
- package/dist/types/skills/types.d.ts.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @arkade-os/skill - Arkade SDK Skills for Agent Integration
|
|
4
|
+
*
|
|
5
|
+
* This package provides skills for sending and receiving Bitcoin over
|
|
6
|
+
* Arkade and Lightning, designed for agent integration (CLI-friendly
|
|
7
|
+
* for agents like MoltBot).
|
|
8
|
+
*
|
|
9
|
+
* ## Available Skills
|
|
10
|
+
*
|
|
11
|
+
* - **ArkadeBitcoinSkill**: Send/receive Bitcoin via Arkade with on/off ramp support
|
|
12
|
+
* - **ArkaLightningSkill**: Lightning Network payments via Boltz submarine swaps
|
|
13
|
+
* - **LendaSwapSkill**: USDC/USDT stablecoin swaps via LendaSwap
|
|
14
|
+
*
|
|
15
|
+
* ## Quick Start
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { Wallet, SingleKey } from "@arkade-os/sdk";
|
|
19
|
+
* import {
|
|
20
|
+
* ArkadeBitcoinSkill,
|
|
21
|
+
* ArkaLightningSkill,
|
|
22
|
+
* LendaSwapSkill,
|
|
23
|
+
* } from "@arkade-os/skill";
|
|
24
|
+
*
|
|
25
|
+
* // Create a wallet (default server: arkade.computer)
|
|
26
|
+
* const wallet = await Wallet.create({
|
|
27
|
+
* identity: SingleKey.fromHex(privateKeyHex),
|
|
28
|
+
* arkServerUrl: "https://arkade.computer",
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Bitcoin operations
|
|
32
|
+
* const bitcoin = new ArkadeBitcoinSkill(wallet);
|
|
33
|
+
* const balance = await bitcoin.getBalance();
|
|
34
|
+
*
|
|
35
|
+
* // Lightning operations
|
|
36
|
+
* const lightning = new ArkaLightningSkill({ wallet, network: "bitcoin" });
|
|
37
|
+
* const invoice = await lightning.createInvoice({ amount: 50000 });
|
|
38
|
+
*
|
|
39
|
+
* // Stablecoin swaps
|
|
40
|
+
* const lendaswap = new LendaSwapSkill({ wallet, apiKey: "..." });
|
|
41
|
+
* const quote = await lendaswap.getQuoteBtcToStablecoin(100000, "usdc_pol");
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* ## CLI Usage
|
|
45
|
+
*
|
|
46
|
+
* ```bash
|
|
47
|
+
* # Initialize wallet (default server: arkade.computer)
|
|
48
|
+
* arkade init <private-key-hex>
|
|
49
|
+
*
|
|
50
|
+
* # Show addresses
|
|
51
|
+
* arkade address
|
|
52
|
+
* arkade boarding-address
|
|
53
|
+
*
|
|
54
|
+
* # Check balance
|
|
55
|
+
* arkade balance
|
|
56
|
+
*
|
|
57
|
+
* # Send Bitcoin
|
|
58
|
+
* arkade send <ark-address> <amount-sats>
|
|
59
|
+
*
|
|
60
|
+
* # Lightning
|
|
61
|
+
* arkade ln-invoice <amount> [description]
|
|
62
|
+
* arkade ln-pay <bolt11>
|
|
63
|
+
*
|
|
64
|
+
* # Stablecoins
|
|
65
|
+
* arkade swap-quote <amount> <from> <to>
|
|
66
|
+
* arkade swap-pairs
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @packageDocumentation
|
|
70
|
+
*/
|
|
71
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
72
|
+
if (k2 === undefined) k2 = k;
|
|
73
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
74
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
75
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
76
|
+
}
|
|
77
|
+
Object.defineProperty(o, k2, desc);
|
|
78
|
+
}) : (function(o, m, k, k2) {
|
|
79
|
+
if (k2 === undefined) k2 = k;
|
|
80
|
+
o[k2] = m[k];
|
|
81
|
+
}));
|
|
82
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
83
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
84
|
+
};
|
|
85
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
86
|
+
// Re-export all skills and types
|
|
87
|
+
__exportStar(require("./skills"), exports);
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;;;;;;;;;;;;;;;;AAEH,iCAAiC;AACjC,2CAAyB"}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ArkadeBitcoinSkill - Send and receive Bitcoin over Arkade protocol.
|
|
4
|
+
*
|
|
5
|
+
* This skill provides a unified interface for Bitcoin operations
|
|
6
|
+
* designed for agent integration (CLI-friendly for agents like MoltBot).
|
|
7
|
+
*
|
|
8
|
+
* @module skills/arkadeBitcoin
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.ArkadeBitcoinSkill = void 0;
|
|
12
|
+
exports.createArkadeBitcoinSkill = createArkadeBitcoinSkill;
|
|
13
|
+
const sdk_1 = require("@arkade-os/sdk");
|
|
14
|
+
/**
|
|
15
|
+
* ArkadeBitcoinSkill provides a unified interface for sending and receiving
|
|
16
|
+
* Bitcoin over the Arkade protocol.
|
|
17
|
+
*
|
|
18
|
+
* This skill wraps the core wallet functionality and provides:
|
|
19
|
+
* - Offchain Bitcoin transactions via Ark
|
|
20
|
+
* - Get paid onchain via boarding address + onboard
|
|
21
|
+
* - Pay onchain via offboard to any Bitcoin address
|
|
22
|
+
* - Balance management
|
|
23
|
+
* - Transaction history
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { Wallet, SingleKey } from "@arkade-os/sdk";
|
|
28
|
+
* import { ArkadeBitcoinSkill } from "@arkade-os/skill";
|
|
29
|
+
*
|
|
30
|
+
* // Create a wallet
|
|
31
|
+
* const wallet = await Wallet.create({
|
|
32
|
+
* identity: SingleKey.fromHex(privateKeyHex),
|
|
33
|
+
* arkServerUrl: "https://arkade.computer",
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Create the skill
|
|
37
|
+
* const bitcoinSkill = new ArkadeBitcoinSkill(wallet);
|
|
38
|
+
*
|
|
39
|
+
* // Get addresses for receiving
|
|
40
|
+
* const addresses = await bitcoinSkill.getReceiveAddresses();
|
|
41
|
+
* console.log("Ark Address:", addresses[0].address);
|
|
42
|
+
*
|
|
43
|
+
* // Check balance
|
|
44
|
+
* const balance = await bitcoinSkill.getBalance();
|
|
45
|
+
* console.log("Available:", balance.offchain.available, "sats");
|
|
46
|
+
*
|
|
47
|
+
* // Send Bitcoin offchain
|
|
48
|
+
* const result = await bitcoinSkill.send({
|
|
49
|
+
* address: recipientArkAddress,
|
|
50
|
+
* amount: 10000, // 10,000 sats
|
|
51
|
+
* });
|
|
52
|
+
* console.log("Sent! Txid:", result.txid);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
class ArkadeBitcoinSkill {
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new ArkadeBitcoinSkill instance.
|
|
58
|
+
*
|
|
59
|
+
* @param wallet - The Arkade wallet to use for operations.
|
|
60
|
+
* Must be a full wallet (not readonly) for send/settle operations.
|
|
61
|
+
*/
|
|
62
|
+
constructor(wallet) {
|
|
63
|
+
this.wallet = wallet;
|
|
64
|
+
this.name = "arkade-bitcoin";
|
|
65
|
+
this.description = "Send and receive Bitcoin over Arkade offchain, get paid onchain (onboard), pay onchain (offboard)";
|
|
66
|
+
this.version = "1.0.0";
|
|
67
|
+
this.ramps = new sdk_1.Ramps(wallet);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get all available addresses for receiving Bitcoin.
|
|
71
|
+
*
|
|
72
|
+
* Returns both the Ark address (for offchain receipts) and the
|
|
73
|
+
* boarding address (for onchain deposits that can be onboarded).
|
|
74
|
+
*
|
|
75
|
+
* @returns Array of addresses with their types and descriptions
|
|
76
|
+
*/
|
|
77
|
+
async getReceiveAddresses() {
|
|
78
|
+
const [arkAddress, boardingAddress] = await Promise.all([
|
|
79
|
+
this.wallet.getAddress(),
|
|
80
|
+
this.wallet.getBoardingAddress(),
|
|
81
|
+
]);
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
address: arkAddress,
|
|
85
|
+
type: "ark",
|
|
86
|
+
description: "Ark address for receiving offchain Bitcoin instantly",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
address: boardingAddress,
|
|
90
|
+
type: "boarding",
|
|
91
|
+
description: "Boarding address for receiving onchain Bitcoin (requires onboarding)",
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the Ark address for receiving offchain Bitcoin.
|
|
97
|
+
*
|
|
98
|
+
* This is the primary address for receiving Bitcoin via Arkade.
|
|
99
|
+
* Funds sent to this address are immediately available offchain.
|
|
100
|
+
*
|
|
101
|
+
* @returns The bech32m-encoded Ark address
|
|
102
|
+
*/
|
|
103
|
+
async getArkAddress() {
|
|
104
|
+
return this.wallet.getAddress();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the boarding address for receiving onchain Bitcoin.
|
|
108
|
+
*
|
|
109
|
+
* Funds sent to this address appear as boarding UTXOs and must be
|
|
110
|
+
* onboarded to become offchain VTXOs before they can be spent.
|
|
111
|
+
*
|
|
112
|
+
* @returns The Bitcoin boarding address
|
|
113
|
+
*/
|
|
114
|
+
async getBoardingAddress() {
|
|
115
|
+
return this.wallet.getBoardingAddress();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the current balance with detailed breakdown.
|
|
119
|
+
*
|
|
120
|
+
* @returns Balance information including offchain and onchain amounts
|
|
121
|
+
*/
|
|
122
|
+
async getBalance() {
|
|
123
|
+
const walletBalance = await this.wallet.getBalance();
|
|
124
|
+
return {
|
|
125
|
+
total: walletBalance.total,
|
|
126
|
+
offchain: {
|
|
127
|
+
settled: walletBalance.settled,
|
|
128
|
+
preconfirmed: walletBalance.preconfirmed,
|
|
129
|
+
available: walletBalance.available,
|
|
130
|
+
recoverable: walletBalance.recoverable,
|
|
131
|
+
},
|
|
132
|
+
onchain: {
|
|
133
|
+
confirmed: walletBalance.boarding.confirmed,
|
|
134
|
+
unconfirmed: walletBalance.boarding.unconfirmed,
|
|
135
|
+
total: walletBalance.boarding.total,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Send Bitcoin to an address.
|
|
141
|
+
*
|
|
142
|
+
* For Ark addresses, this creates an offchain transaction that is
|
|
143
|
+
* instantly confirmed. The recipient must also be using an Ark-compatible
|
|
144
|
+
* wallet connected to the same Ark server.
|
|
145
|
+
*
|
|
146
|
+
* @param params - Send parameters including address and amount
|
|
147
|
+
* @returns Result containing the transaction ID and details
|
|
148
|
+
* @throws Error if the address is invalid or insufficient balance
|
|
149
|
+
*/
|
|
150
|
+
async send(params) {
|
|
151
|
+
const txid = await this.wallet.sendBitcoin({
|
|
152
|
+
address: params.address,
|
|
153
|
+
amount: params.amount,
|
|
154
|
+
feeRate: params.feeRate,
|
|
155
|
+
memo: params.memo,
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
txid,
|
|
159
|
+
type: "ark",
|
|
160
|
+
amount: params.amount,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get the transaction history.
|
|
165
|
+
*
|
|
166
|
+
* @returns Array of transactions with type, amount, and status
|
|
167
|
+
*/
|
|
168
|
+
async getTransactionHistory() {
|
|
169
|
+
return this.wallet.getTransactionHistory();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Wait for incoming funds.
|
|
173
|
+
*
|
|
174
|
+
* This method blocks until either:
|
|
175
|
+
* - New VTXOs are received (offchain)
|
|
176
|
+
* - New UTXOs are received at the boarding address (onchain)
|
|
177
|
+
* - The timeout expires
|
|
178
|
+
*
|
|
179
|
+
* @param timeoutMs - Optional timeout in milliseconds (default: no timeout)
|
|
180
|
+
* @returns Information about the received funds
|
|
181
|
+
* @throws Error if timeout expires without receiving funds
|
|
182
|
+
*/
|
|
183
|
+
async waitForIncomingFunds(timeoutMs) {
|
|
184
|
+
let stopSubscription;
|
|
185
|
+
let timeoutId;
|
|
186
|
+
let settled = false;
|
|
187
|
+
const fundsPromise = new Promise((resolve, reject) => {
|
|
188
|
+
this.wallet
|
|
189
|
+
.notifyIncomingFunds((funds) => {
|
|
190
|
+
if (settled) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
settled = true;
|
|
194
|
+
resolve(funds);
|
|
195
|
+
})
|
|
196
|
+
.then((stop) => {
|
|
197
|
+
stopSubscription = stop;
|
|
198
|
+
if (settled) {
|
|
199
|
+
stop();
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
.catch((error) => {
|
|
203
|
+
if (settled) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
settled = true;
|
|
207
|
+
reject(error);
|
|
208
|
+
});
|
|
209
|
+
if (timeoutMs !== undefined) {
|
|
210
|
+
timeoutId = setTimeout(() => {
|
|
211
|
+
if (settled) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
settled = true;
|
|
215
|
+
reject(new Error("Timeout waiting for incoming funds"));
|
|
216
|
+
}, timeoutMs);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
let result;
|
|
220
|
+
try {
|
|
221
|
+
result = await fundsPromise;
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
if (timeoutId) {
|
|
225
|
+
clearTimeout(timeoutId);
|
|
226
|
+
}
|
|
227
|
+
if (stopSubscription) {
|
|
228
|
+
stopSubscription();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (result.type === "utxo") {
|
|
232
|
+
return {
|
|
233
|
+
type: "utxo",
|
|
234
|
+
amount: result.coins.reduce((sum, coin) => sum + coin.value, 0),
|
|
235
|
+
ids: result.coins.map((coin) => `${coin.txid}:${coin.vout}`),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
return {
|
|
240
|
+
type: "vtxo",
|
|
241
|
+
amount: result.newVtxos.reduce((sum, vtxo) => sum + vtxo.value, 0),
|
|
242
|
+
ids: result.newVtxos.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get paid onchain: Convert received onchain BTC to offchain.
|
|
248
|
+
*
|
|
249
|
+
* Use this after receiving onchain Bitcoin to your boarding address.
|
|
250
|
+
* This converts boarding UTXOs into VTXOs through a cooperative
|
|
251
|
+
* settlement with the Ark server. After onboarding, funds are
|
|
252
|
+
* available for instant offchain transactions.
|
|
253
|
+
*
|
|
254
|
+
* Flow: Someone pays you onchain → funds arrive at boarding address → onboard → funds available offchain
|
|
255
|
+
*
|
|
256
|
+
* @param params - Onboard parameters
|
|
257
|
+
* @returns Result containing the commitment transaction ID
|
|
258
|
+
* @throws Error if no boarding UTXOs are available or fees exceed value
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* // Step 1: Give your boarding address to receive onchain payment
|
|
263
|
+
* const boardingAddress = await bitcoinSkill.getBoardingAddress();
|
|
264
|
+
*
|
|
265
|
+
* // Step 2: After receiving payment, onboard the funds
|
|
266
|
+
* const arkInfo = await arkProvider.getInfo();
|
|
267
|
+
* const result = await bitcoinSkill.onboard({
|
|
268
|
+
* feeInfo: arkInfo.feeInfo,
|
|
269
|
+
* eventCallback: (event) => console.log("Settlement event:", event.type),
|
|
270
|
+
* });
|
|
271
|
+
* console.log("Onboarded! Commitment:", result.commitmentTxid);
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
async onboard(params) {
|
|
275
|
+
const boardingUtxos = await this.wallet.getBoardingUtxos();
|
|
276
|
+
const totalBefore = boardingUtxos.reduce((sum, utxo) => sum + BigInt(utxo.value), 0n);
|
|
277
|
+
const commitmentTxid = await this.ramps.onboard(params.feeInfo, undefined, params.amount, params.eventCallback);
|
|
278
|
+
const amount = params.amount ?? totalBefore;
|
|
279
|
+
return {
|
|
280
|
+
commitmentTxid,
|
|
281
|
+
amount,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Pay onchain: Send offchain BTC to any onchain Bitcoin address.
|
|
286
|
+
*
|
|
287
|
+
* Use this to pay someone who needs onchain Bitcoin. This performs a
|
|
288
|
+
* collaborative exit, converting your VTXOs back to regular onchain
|
|
289
|
+
* Bitcoin UTXOs at the recipient's destination address.
|
|
290
|
+
*
|
|
291
|
+
* Flow: You have offchain funds → offboard to recipient's onchain address → they receive onchain BTC
|
|
292
|
+
*
|
|
293
|
+
* @param params - Offboard parameters including destination address
|
|
294
|
+
* @returns Result containing the commitment transaction ID
|
|
295
|
+
* @throws Error if no VTXOs are available or fees exceed value
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* // Pay someone at an onchain Bitcoin address
|
|
300
|
+
* const arkInfo = await arkProvider.getInfo();
|
|
301
|
+
* const result = await bitcoinSkill.offboard({
|
|
302
|
+
* destinationAddress: "bc1q...", // recipient's onchain address
|
|
303
|
+
* feeInfo: arkInfo.feeInfo,
|
|
304
|
+
* eventCallback: (event) => console.log("Settlement event:", event.type),
|
|
305
|
+
* });
|
|
306
|
+
* console.log("Paid onchain! Commitment:", result.commitmentTxid);
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
async offboard(params) {
|
|
310
|
+
const vtxos = await this.wallet.getVtxos({ withRecoverable: true });
|
|
311
|
+
const totalBefore = vtxos.reduce((sum, vtxo) => sum + BigInt(vtxo.value), 0n);
|
|
312
|
+
const commitmentTxid = await this.ramps.offboard(params.destinationAddress, params.feeInfo, params.amount, params.eventCallback);
|
|
313
|
+
const amount = params.amount ?? totalBefore;
|
|
314
|
+
return {
|
|
315
|
+
commitmentTxid,
|
|
316
|
+
amount,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Get the underlying wallet instance.
|
|
321
|
+
*
|
|
322
|
+
* Use this for advanced operations not covered by the skill interface.
|
|
323
|
+
*
|
|
324
|
+
* @returns The wallet instance
|
|
325
|
+
*/
|
|
326
|
+
getWallet() {
|
|
327
|
+
return this.wallet;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get detailed information about available VTXOs.
|
|
331
|
+
*
|
|
332
|
+
* @param filter - Optional filter for VTXO types to include
|
|
333
|
+
* @returns Array of extended virtual coins with full details
|
|
334
|
+
*/
|
|
335
|
+
async getVtxos(filter) {
|
|
336
|
+
return this.wallet.getVtxos(filter);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Get detailed information about boarding UTXOs.
|
|
340
|
+
*
|
|
341
|
+
* @returns Array of extended coins with full details
|
|
342
|
+
*/
|
|
343
|
+
async getBoardingUtxos() {
|
|
344
|
+
return this.wallet.getBoardingUtxos();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
exports.ArkadeBitcoinSkill = ArkadeBitcoinSkill;
|
|
348
|
+
/**
|
|
349
|
+
* Create an ArkadeBitcoinSkill from a wallet.
|
|
350
|
+
*
|
|
351
|
+
* This is a convenience function for creating the skill.
|
|
352
|
+
*
|
|
353
|
+
* @param wallet - The Arkade wallet to use
|
|
354
|
+
* @returns A new ArkadeBitcoinSkill instance
|
|
355
|
+
*/
|
|
356
|
+
function createArkadeBitcoinSkill(wallet) {
|
|
357
|
+
return new ArkadeBitcoinSkill(wallet);
|
|
358
|
+
}
|
|
359
|
+
//# sourceMappingURL=arkadeBitcoin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arkadeBitcoin.js","sourceRoot":"","sources":["../../../src/skills/arkadeBitcoin.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA2ZH,4DAEC;AA3ZD,wCAOwB;AAcxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAa,kBAAkB;IAQ7B;;;;;OAKG;IACH,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAblC,SAAI,GAAG,gBAAgB,CAAC;QACxB,gBAAW,GAClB,mGAAmG,CAAC;QAC7F,YAAO,GAAG,OAAO,CAAC;QAWzB,IAAI,CAAC,KAAK,GAAG,IAAI,WAAK,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,mBAAmB;QACvB,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACtD,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE;SACjC,CAAC,CAAC;QAEH,OAAO;YACL;gBACE,OAAO,EAAE,UAAU;gBACnB,IAAI,EAAE,KAAK;gBACX,WAAW,EAAE,sDAAsD;aACpE;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,IAAI,EAAE,UAAU;gBAChB,WAAW,EACT,sEAAsE;aACzE;SACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,kBAAkB;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,aAAa,GA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capabilities that provide specific functionality for agents
|
|
6
|
+
* and applications. This module provides skills for:
|
|
7
|
+
*
|
|
8
|
+
* - **ArkadeBitcoinSkill**: Send and receive Bitcoin over Arkade
|
|
9
|
+
* - **ArkaLightningSkill**: Lightning Network payments via Boltz swaps
|
|
10
|
+
* - **LendaSwapSkill**: USDC/USDT stablecoin swaps via LendaSwap
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { Wallet, SingleKey } from "@arkade-os/sdk";
|
|
15
|
+
* import {
|
|
16
|
+
* ArkadeBitcoinSkill,
|
|
17
|
+
* ArkaLightningSkill,
|
|
18
|
+
* LendaSwapSkill,
|
|
19
|
+
* } from "@arkade-os/skill";
|
|
20
|
+
*
|
|
21
|
+
* // Create a wallet
|
|
22
|
+
* const wallet = await Wallet.create({
|
|
23
|
+
* identity: SingleKey.fromHex(privateKeyHex),
|
|
24
|
+
* arkServerUrl: "https://arkade.computer",
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // === Bitcoin Skill ===
|
|
28
|
+
* const bitcoin = new ArkadeBitcoinSkill(wallet);
|
|
29
|
+
*
|
|
30
|
+
* // Get addresses for receiving
|
|
31
|
+
* const arkAddress = await bitcoin.getArkAddress();
|
|
32
|
+
* console.log("Ark address:", arkAddress);
|
|
33
|
+
*
|
|
34
|
+
* // Check balance
|
|
35
|
+
* const balance = await bitcoin.getBalance();
|
|
36
|
+
* console.log("Balance:", balance.total, "sats");
|
|
37
|
+
*
|
|
38
|
+
* // === Lightning Skill ===
|
|
39
|
+
* const lightning = new ArkaLightningSkill({
|
|
40
|
+
* wallet,
|
|
41
|
+
* network: "bitcoin",
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Create invoice to receive Lightning payment
|
|
45
|
+
* const invoice = await lightning.createInvoice({
|
|
46
|
+
* amount: 25000,
|
|
47
|
+
* description: "Coffee payment",
|
|
48
|
+
* });
|
|
49
|
+
* console.log("Invoice:", invoice.bolt11);
|
|
50
|
+
*
|
|
51
|
+
* // === LendaSwap Skill ===
|
|
52
|
+
* const lendaswap = new LendaSwapSkill({
|
|
53
|
+
* wallet,
|
|
54
|
+
* apiKey: process.env.LENDASWAP_API_KEY,
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* // Get quote for BTC to USDC
|
|
58
|
+
* const quote = await lendaswap.getQuoteBtcToStablecoin(100000, "usdc_pol");
|
|
59
|
+
* console.log("Quote:", quote.targetAmount, "USDC");
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @module skills
|
|
63
|
+
*/
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.createLendaSwapSkill = exports.LendaSwapSkill = exports.createLightningSkill = exports.ArkaLightningSkill = exports.createArkadeBitcoinSkill = exports.ArkadeBitcoinSkill = void 0;
|
|
66
|
+
// Bitcoin skill
|
|
67
|
+
var arkadeBitcoin_1 = require("./arkadeBitcoin");
|
|
68
|
+
Object.defineProperty(exports, "ArkadeBitcoinSkill", { enumerable: true, get: function () { return arkadeBitcoin_1.ArkadeBitcoinSkill; } });
|
|
69
|
+
Object.defineProperty(exports, "createArkadeBitcoinSkill", { enumerable: true, get: function () { return arkadeBitcoin_1.createArkadeBitcoinSkill; } });
|
|
70
|
+
// Lightning skill
|
|
71
|
+
var lightning_1 = require("./lightning");
|
|
72
|
+
Object.defineProperty(exports, "ArkaLightningSkill", { enumerable: true, get: function () { return lightning_1.ArkaLightningSkill; } });
|
|
73
|
+
Object.defineProperty(exports, "createLightningSkill", { enumerable: true, get: function () { return lightning_1.createLightningSkill; } });
|
|
74
|
+
// LendaSwap skill
|
|
75
|
+
var lendaswap_1 = require("./lendaswap");
|
|
76
|
+
Object.defineProperty(exports, "LendaSwapSkill", { enumerable: true, get: function () { return lendaswap_1.LendaSwapSkill; } });
|
|
77
|
+
Object.defineProperty(exports, "createLendaSwapSkill", { enumerable: true, get: function () { return lendaswap_1.createLendaSwapSkill; } });
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/skills/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;;;AAqCH,gBAAgB;AAChB,iDAA+E;AAAtE,mHAAA,kBAAkB,OAAA;AAAE,yHAAA,wBAAwB,OAAA;AAErD,kBAAkB;AAClB,yCAIqB;AAHnB,+GAAA,kBAAkB,OAAA;AAClB,iHAAA,oBAAoB,OAAA;AAItB,kBAAkB;AAClB,yCAIqB;AAHnB,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA"}
|