@gvnrdao/dh-lit-actions 0.0.68 → 0.0.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/package.json +1 -1
  2. package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.d.ts +1 -9
  3. package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.d.ts.map +1 -1
  4. package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js +115 -174
  5. package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js.map +1 -1
  6. package/pkg-dist/pkg-src/constants/chunks/package-registry.d.ts.map +1 -1
  7. package/pkg-dist/pkg-src/constants/chunks/package-registry.js +0 -2
  8. package/pkg-dist/pkg-src/constants/chunks/package-registry.js.map +1 -1
  9. package/pkg-dist/pkg-src/executors/chunks/vault-snapshot-executor.d.ts.map +1 -1
  10. package/pkg-dist/pkg-src/executors/chunks/vault-snapshot-executor.js +1 -0
  11. package/pkg-dist/pkg-src/executors/chunks/vault-snapshot-executor.js.map +1 -1
  12. package/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.d.ts +6 -0
  13. package/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.d.ts.map +1 -1
  14. package/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.d.ts +0 -2
  15. package/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.d.ts.map +1 -1
  16. package/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.d.ts.map +1 -1
  17. package/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js +18 -4
  18. package/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js.map +1 -1
  19. package/pkg-dist/pkg-src/utils/chunks/pkp-setup.d.ts.map +1 -1
  20. package/pkg-dist/pkg-src/utils/chunks/pkp-setup.js +6 -2
  21. package/pkg-dist/pkg-src/utils/chunks/pkp-setup.js.map +1 -1
  22. package/pkg-dist/src/constants/chunks/bitcoin-network-config.js +4 -4
  23. package/pkg-dist/src/constants/chunks/bitcoin-network-config.js.map +1 -1
  24. package/pkg-dist/src/interfaces/chunks/owner-authorization.d.ts +18 -0
  25. package/pkg-dist/src/interfaces/chunks/owner-authorization.d.ts.map +1 -1
  26. package/pkg-dist/src/interfaces/chunks/vault-balance.i.d.ts +1 -0
  27. package/pkg-dist/src/interfaces/chunks/vault-balance.i.d.ts.map +1 -1
  28. package/pkg-dist/src/modules/authorization.module.d.ts +86 -0
  29. package/pkg-dist/src/modules/authorization.module.d.ts.map +1 -1
  30. package/pkg-dist/src/modules/authorization.module.js +175 -0
  31. package/pkg-dist/src/modules/authorization.module.js.map +1 -1
  32. package/pkg-dist/src/modules/bitcoin/address.d.ts +40 -0
  33. package/pkg-dist/src/modules/bitcoin/address.d.ts.map +1 -0
  34. package/pkg-dist/src/modules/bitcoin/address.js +323 -0
  35. package/pkg-dist/src/modules/bitcoin/address.js.map +1 -0
  36. package/pkg-dist/src/modules/bitcoin/provider.d.ts +55 -0
  37. package/pkg-dist/src/modules/bitcoin/provider.d.ts.map +1 -0
  38. package/pkg-dist/src/modules/bitcoin/provider.js +67 -0
  39. package/pkg-dist/src/modules/bitcoin/provider.js.map +1 -0
  40. package/pkg-dist/src/modules/bitcoin/signature.d.ts +24 -0
  41. package/pkg-dist/src/modules/bitcoin/signature.d.ts.map +1 -0
  42. package/pkg-dist/src/modules/bitcoin/signature.js +64 -0
  43. package/pkg-dist/src/modules/bitcoin/signature.js.map +1 -0
  44. package/pkg-dist/src/modules/bitcoin/transaction.d.ts +63 -0
  45. package/pkg-dist/src/modules/bitcoin/transaction.d.ts.map +1 -0
  46. package/pkg-dist/src/modules/bitcoin/transaction.js +187 -0
  47. package/pkg-dist/src/modules/bitcoin/transaction.js.map +1 -0
  48. package/pkg-dist/src/modules/bitcoin-data-provider.module.d.ts +8 -1
  49. package/pkg-dist/src/modules/bitcoin-data-provider.module.d.ts.map +1 -1
  50. package/pkg-dist/src/modules/bitcoin-data-provider.module.js +106 -11
  51. package/pkg-dist/src/modules/bitcoin-data-provider.module.js.map +1 -1
  52. package/pkg-dist/src/modules/price-oracle.module.d.ts +21 -2
  53. package/pkg-dist/src/modules/price-oracle.module.d.ts.map +1 -1
  54. package/pkg-dist/src/modules/price-oracle.module.js +211 -72
  55. package/pkg-dist/src/modules/price-oracle.module.js.map +1 -1
  56. package/pkg-dist/src/modules/vault-snapshot.d.ts.map +1 -1
  57. package/pkg-dist/src/modules/vault-snapshot.js +37 -30
  58. package/pkg-dist/src/modules/vault-snapshot.js.map +1 -1
@@ -0,0 +1,323 @@
1
+ "use strict";
2
+ /**
3
+ * Bitcoin Address Module
4
+ *
5
+ * Provides Bitcoin address derivation from PKP public keys.
6
+ * Supports P2WPKH (SegWit v0) addresses for mainnet, testnet, and regtest networks.
7
+ *
8
+ * IMPORTANT: Changed from P2PKH to P2WPKH to support witness transactions.
9
+ * P2WPKH requires witness (SegWit) and produces bech32 addresses.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.deriveBitcoinAddress = deriveBitcoinAddress;
13
+ exports.deriveBitcoinAddressP2PKH = deriveBitcoinAddressP2PKH;
14
+ exports.addressToScriptPubKey = addressToScriptPubKey;
15
+ /**
16
+ * Derive Bitcoin P2WPKH (SegWit v0) address from PKP public key
17
+ *
18
+ * This is the DEFAULT address type used by vault PKPs.
19
+ * Uses bech32 encoding (bc1... for mainnet, bcrt1... for regtest, tb1... for testnet).
20
+ *
21
+ * @param pkpPublicKey - Uncompressed public key (130 hex chars: 04 + 32 bytes X + 32 bytes Y)
22
+ * @param network - Bitcoin network ("mainnet" | "testnet" | "regtest")
23
+ * @returns Bitcoin Bech32 address (P2WPKH)
24
+ */
25
+ async function deriveBitcoinAddress(pkpPublicKey, network) {
26
+ // Remove 0x prefix if present
27
+ const pubKeyHex = pkpPublicKey.startsWith("0x")
28
+ ? pkpPublicKey.slice(2)
29
+ : pkpPublicKey;
30
+ // PKP public key is uncompressed (65 bytes: 04 + 32 bytes X + 32 bytes Y)
31
+ if (pubKeyHex.length !== 130) {
32
+ throw new Error(`Invalid public key length: ${pubKeyHex.length}, expected 130 (uncompressed format)`);
33
+ }
34
+ if (!pubKeyHex.startsWith("04")) {
35
+ throw new Error(`Invalid public key prefix: expected 04 (uncompressed), got ${pubKeyHex.substring(0, 2)}`);
36
+ }
37
+ // Compress public key (33 bytes: prefix + 32 bytes X)
38
+ const xCoord = pubKeyHex.slice(2, 66); // Skip '04' prefix
39
+ const yCoord = pubKeyHex.slice(66, 130);
40
+ const yBN = BigInt("0x" + yCoord);
41
+ const prefix = yBN % 2n === 0n ? "02" : "03"; // Even Y = 02, Odd Y = 03
42
+ const compressedPubKey = prefix + xCoord;
43
+ // Hash160: SHA256 then RIPEMD160
44
+ // @ts-ignore - ethers available in LIT runtime
45
+ const sha256Hash = ethers.utils.sha256("0x" + compressedPubKey);
46
+ // @ts-ignore - ethers available in LIT runtime
47
+ const ripemd160 = ethers.utils.ripemd160(sha256Hash);
48
+ const pubKeyHash = ripemd160.slice(2); // Remove 0x prefix
49
+ // Encode as Bech32 (P2WPKH)
50
+ let hrp;
51
+ if (network === "mainnet") {
52
+ hrp = "bc";
53
+ }
54
+ else if (network === "testnet") {
55
+ hrp = "tb";
56
+ }
57
+ else {
58
+ hrp = "bcrt"; // regtest
59
+ }
60
+ const address = bech32Encode(hrp, 0, pubKeyHash);
61
+ return address;
62
+ }
63
+ /**
64
+ * Derive Bitcoin P2PKH (legacy) address from PKP public key
65
+ *
66
+ * DEPRECATED: Use deriveBitcoinAddress() for P2WPKH instead.
67
+ * This function is kept for backward compatibility only.
68
+ *
69
+ * @param pkpPublicKey - Uncompressed public key (130 hex chars: 04 + 32 bytes X + 32 bytes Y)
70
+ * @param network - Bitcoin network ("mainnet" | "testnet" | "regtest")
71
+ * @returns Bitcoin address (Base58 encoded)
72
+ */
73
+ async function deriveBitcoinAddressP2PKH(pkpPublicKey, network) {
74
+ // Remove 0x prefix if present
75
+ const pubKeyHex = pkpPublicKey.startsWith("0x")
76
+ ? pkpPublicKey.slice(2)
77
+ : pkpPublicKey;
78
+ // PKP public key is uncompressed (65 bytes: 04 + 32 bytes X + 32 bytes Y)
79
+ if (pubKeyHex.length !== 130) {
80
+ throw new Error(`Invalid public key length: ${pubKeyHex.length}, expected 130 (uncompressed format)`);
81
+ }
82
+ if (!pubKeyHex.startsWith("04")) {
83
+ throw new Error(`Invalid public key prefix: expected 04 (uncompressed), got ${pubKeyHex.substring(0, 2)}`);
84
+ }
85
+ // Compress public key (33 bytes: prefix + 32 bytes X)
86
+ const xCoord = pubKeyHex.slice(2, 66); // Skip '04' prefix
87
+ const yCoord = pubKeyHex.slice(66, 130);
88
+ const yBN = BigInt("0x" + yCoord);
89
+ const prefix = yBN % 2n === 0n ? "02" : "03"; // Even Y = 02, Odd Y = 03
90
+ const compressedPubKey = prefix + xCoord;
91
+ // Hash160: SHA256 then RIPEMD160
92
+ // @ts-ignore - ethers available in LIT runtime
93
+ const sha256Hash = ethers.utils.sha256("0x" + compressedPubKey);
94
+ // @ts-ignore - ethers available in LIT runtime
95
+ const ripemd160 = ethers.utils.ripemd160(sha256Hash);
96
+ // Add network prefix byte
97
+ let versionByte;
98
+ if (network === "mainnet") {
99
+ versionByte = "00"; // P2PKH mainnet
100
+ }
101
+ else {
102
+ versionByte = "6f"; // P2PKH testnet/regtest
103
+ }
104
+ const versionedHash = versionByte + ripemd160.slice(2);
105
+ // Calculate checksum (double SHA256, first 4 bytes)
106
+ // @ts-ignore - ethers available in LIT runtime
107
+ const checksum1 = ethers.utils.sha256("0x" + versionedHash);
108
+ // @ts-ignore - ethers available in LIT runtime
109
+ const checksum2 = ethers.utils.sha256(checksum1);
110
+ const checksum = checksum2.slice(2, 10); // First 4 bytes
111
+ // Base58 encode
112
+ const addressHex = versionedHash + checksum;
113
+ const address = base58Encode(addressHex);
114
+ return address;
115
+ }
116
+ /**
117
+ * Convert Bitcoin address to scriptPubKey
118
+ * Supports P2PKH (Base58) and P2WPKH (Bech32) addresses
119
+ *
120
+ * @param address - Bitcoin address (Base58 or Bech32 encoded)
121
+ * @returns ScriptPubKey hex string
122
+ */
123
+ function addressToScriptPubKey(address) {
124
+ // Check if Bech32 (SegWit native)
125
+ const isBech32 = /^(bc1|tb1|bcrt1)[0-9a-zA-Z]{11,87}$/.test(address);
126
+ if (isBech32) {
127
+ // Bech32 P2WPKH address
128
+ const decoded = bech32Decode(address);
129
+ // P2WPKH script: OP_0 <20-byte-pubkey-hash>
130
+ // OP_0 = 0x00, 0x14 = 20 (length of pubKeyHash)
131
+ return "0014" + decoded.witnessProgram;
132
+ }
133
+ else {
134
+ // Legacy Base58 P2PKH address
135
+ const decoded = base58Decode(address);
136
+ // Remove version byte (1 byte) and checksum (4 bytes)
137
+ const pubKeyHash = decoded.slice(2, decoded.length - 8);
138
+ // P2PKH script: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
139
+ // OP_DUP = 0x76, OP_HASH160 = 0xa9, OP_EQUALVERIFY = 0x88, OP_CHECKSIG = 0xac
140
+ // 0x14 = 20 (length of pubKeyHash)
141
+ return "76a914" + pubKeyHash + "88ac";
142
+ }
143
+ }
144
+ /**
145
+ * Base58 encoding (Bitcoin alphabet)
146
+ */
147
+ function base58Encode(hex) {
148
+ const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
149
+ let num = BigInt("0x" + hex);
150
+ let encoded = "";
151
+ while (num > 0n) {
152
+ const remainder = Number(num % 58n);
153
+ encoded = ALPHABET[remainder] + encoded;
154
+ num = num / 58n;
155
+ }
156
+ // Add leading '1's for leading zero bytes
157
+ for (let i = 0; i < hex.length && hex.substr(i, 2) === "00"; i += 2) {
158
+ encoded = "1" + encoded;
159
+ }
160
+ return encoded;
161
+ }
162
+ /**
163
+ * Base58 decoding
164
+ */
165
+ function base58Decode(encoded) {
166
+ const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
167
+ let num = 0n;
168
+ for (let i = 0; i < encoded.length; i++) {
169
+ const digit = ALPHABET.indexOf(encoded[i]);
170
+ if (digit < 0) {
171
+ throw new Error(`Invalid Base58 character: ${encoded[i]}`);
172
+ }
173
+ num = num * 58n + BigInt(digit);
174
+ }
175
+ let hex = num.toString(16);
176
+ if (hex.length % 2) {
177
+ hex = "0" + hex;
178
+ }
179
+ // Add leading zeros for leading '1's
180
+ for (let i = 0; i < encoded.length && encoded[i] === "1"; i++) {
181
+ hex = "00" + hex;
182
+ }
183
+ return hex;
184
+ }
185
+ /**
186
+ * Bech32 encoding for SegWit addresses
187
+ * Encodes witness version and program into bech32 address
188
+ *
189
+ * @param hrp - Human-readable part ("bc" for mainnet, "tb" for testnet, "bcrt" for regtest)
190
+ * @param witnessVersion - Witness version (0 for P2WPKH/P2WSH)
191
+ * @param witnessProgram - Hex string of witness program (20 bytes for P2WPKH, 32 for P2WSH)
192
+ * @returns Bech32 encoded address
193
+ */
194
+ function bech32Encode(hrp, witnessVersion, witnessProgram) {
195
+ const CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
196
+ // Convert witness program from hex to bytes
197
+ const programBytes = [];
198
+ for (let i = 0; i < witnessProgram.length; i += 2) {
199
+ programBytes.push(parseInt(witnessProgram.substr(i, 2), 16));
200
+ }
201
+ // Convert from 8-bit to 5-bit groups
202
+ const fiveBitData = convertBits(programBytes, 8, 5, true);
203
+ // Prepend witness version
204
+ const data = [witnessVersion, ...fiveBitData];
205
+ // Create checksum
206
+ const checksum = bech32CreateChecksum(hrp, data);
207
+ const combined = [...data, ...checksum];
208
+ // Encode to bech32
209
+ let encoded = hrp + "1";
210
+ for (let i = 0; i < combined.length; i++) {
211
+ encoded += CHARSET[combined[i]];
212
+ }
213
+ return encoded;
214
+ }
215
+ /**
216
+ * Create bech32 checksum
217
+ */
218
+ function bech32CreateChecksum(hrp, data) {
219
+ const values = bech32HrpExpand(hrp).concat(data).concat([0, 0, 0, 0, 0, 0]);
220
+ const mod = bech32Polymod(values) ^ 1;
221
+ const checksum = [];
222
+ for (let i = 0; i < 6; i++) {
223
+ checksum.push((mod >> (5 * (5 - i))) & 31);
224
+ }
225
+ return checksum;
226
+ }
227
+ /**
228
+ * Expand HRP for bech32 checksum
229
+ */
230
+ function bech32HrpExpand(hrp) {
231
+ const result = [];
232
+ for (let i = 0; i < hrp.length; i++) {
233
+ result.push(hrp.charCodeAt(i) >> 5);
234
+ }
235
+ result.push(0);
236
+ for (let i = 0; i < hrp.length; i++) {
237
+ result.push(hrp.charCodeAt(i) & 31);
238
+ }
239
+ return result;
240
+ }
241
+ /**
242
+ * Bech32 polymod for checksum calculation
243
+ */
244
+ function bech32Polymod(values) {
245
+ const GEN = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3];
246
+ let chk = 1;
247
+ for (let i = 0; i < values.length; i++) {
248
+ const b = chk >> 25;
249
+ chk = ((chk & 0x1ffffff) << 5) ^ values[i];
250
+ for (let j = 0; j < 5; j++) {
251
+ if ((b >> j) & 1) {
252
+ chk ^= GEN[j];
253
+ }
254
+ }
255
+ }
256
+ return chk;
257
+ }
258
+ /**
259
+ * Bech32 decoding for SegWit addresses
260
+ * Simplified decoder for P2WPKH witness program extraction
261
+ */
262
+ function bech32Decode(address) {
263
+ const CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
264
+ // Split at last '1' separator
265
+ const pos = address.lastIndexOf("1");
266
+ if (pos < 1) {
267
+ throw new Error("No separator character for bech32");
268
+ }
269
+ const hrp = address.substring(0, pos).toLowerCase();
270
+ const data = address.substring(pos + 1).toLowerCase();
271
+ // Decode data part
272
+ const decoded = [];
273
+ for (let i = 0; i < data.length; i++) {
274
+ const v = CHARSET.indexOf(data[i]);
275
+ if (v === -1) {
276
+ throw new Error(`Invalid bech32 character: ${data[i]}`);
277
+ }
278
+ decoded.push(v);
279
+ }
280
+ // Remove checksum (last 6 characters)
281
+ const payload = decoded.slice(0, -6);
282
+ // First byte is witness version
283
+ const witnessVersion = payload[0];
284
+ // Convert from 5-bit groups to 8-bit bytes
285
+ const witness = convertBits(payload.slice(1), 5, 8, false);
286
+ // Convert to hex
287
+ const witnessProgram = witness
288
+ .map((b) => b.toString(16).padStart(2, "0"))
289
+ .join("");
290
+ return { witnessProgram };
291
+ }
292
+ /**
293
+ * Convert between bit groups
294
+ * Used for Bech32 5-bit to 8-bit conversion
295
+ */
296
+ function convertBits(data, fromBits, toBits, pad) {
297
+ let acc = 0;
298
+ let bits = 0;
299
+ const result = [];
300
+ const maxv = (1 << toBits) - 1;
301
+ for (let i = 0; i < data.length; i++) {
302
+ const value = data[i];
303
+ if (value < 0 || value >> fromBits !== 0) {
304
+ throw new Error("Invalid data for bit conversion");
305
+ }
306
+ acc = (acc << fromBits) | value;
307
+ bits += fromBits;
308
+ while (bits >= toBits) {
309
+ bits -= toBits;
310
+ result.push((acc >> bits) & maxv);
311
+ }
312
+ }
313
+ if (pad) {
314
+ if (bits > 0) {
315
+ result.push((acc << (toBits - bits)) & maxv);
316
+ }
317
+ }
318
+ else if (bits >= fromBits || (acc << (toBits - bits)) & maxv) {
319
+ throw new Error("Invalid padding in bit conversion");
320
+ }
321
+ return result;
322
+ }
323
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../../src/modules/bitcoin/address.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAYH,oDAmDC;AAYD,8DA4DC;AASD,sDAuBC;AArKD;;;;;;;;;GASG;AACI,KAAK,UAAU,oBAAoB,CACxC,YAAoB,EACpB,OAA0C;IAE1C,8BAA8B;IAC9B,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC;QAC7C,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;QACvB,CAAC,CAAC,YAAY,CAAC;IAEjB,0EAA0E;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AC,CAAC;QAC/C,CAAC;IACH,CAAC;SAAM,IAAI,IAAI,IAAI,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Bitcoin Provider Module
3
+ *
4
+ * Provides Bitcoin blockchain data access through RPC provider.
5
+ * Supports UTXO queries, scriptPubKey retrieval, and transaction queries.
6
+ */
7
+ /**
8
+ * UTXO data from Bitcoin network
9
+ */
10
+ export interface UTXO {
11
+ txid: string;
12
+ vout: number;
13
+ value: number;
14
+ confirmations: number;
15
+ scriptPubKey: string;
16
+ }
17
+ /**
18
+ * Bitcoin RPC provider client
19
+ */
20
+ export declare class BitcoinProvider {
21
+ private providerUrl;
22
+ constructor(providerUrl: string);
23
+ /**
24
+ * Get UTXOs for Bitcoin address
25
+ *
26
+ * @param address - Bitcoin address
27
+ * @param minConfirmations - Minimum confirmations required
28
+ * @returns Array of UTXOs
29
+ */
30
+ getUtxos(address: string, minConfirmations?: number): Promise<UTXO[]>;
31
+ /**
32
+ * Get scriptPubKey for transaction output
33
+ *
34
+ * @param txid - Transaction ID
35
+ * @param vout - Output index
36
+ * @returns ScriptPubKey hex string
37
+ */
38
+ getScriptPubKey(txid: string, vout: number): Promise<string>;
39
+ /**
40
+ * Check if UTXO exists and is unspent
41
+ *
42
+ * @param txid - Transaction ID
43
+ * @param vout - Output index
44
+ * @returns true if UTXO exists and is unspent
45
+ */
46
+ checkUtxoExists(txid: string, vout: number): Promise<boolean>;
47
+ /**
48
+ * Broadcast Bitcoin transaction
49
+ *
50
+ * @param txHex - Signed transaction hex
51
+ * @returns Transaction ID
52
+ */
53
+ broadcastTransaction(txHex: string): Promise<string>;
54
+ }
55
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/modules/bitcoin/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAS;gBAEhB,WAAW,EAAE,MAAM;IAI/B;;;;;;OAMG;IACG,QAAQ,CACZ,OAAO,EAAE,MAAM,EACf,gBAAgB,GAAE,MAAU,GAC3B,OAAO,CAAC,IAAI,EAAE,CAAC;IAQlB;;;;;;OAMG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOlE;;;;;;OAMG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOnE;;;;;OAKG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAM3D"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * Bitcoin Provider Module
4
+ *
5
+ * Provides Bitcoin blockchain data access through RPC provider.
6
+ * Supports UTXO queries, scriptPubKey retrieval, and transaction queries.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BitcoinProvider = void 0;
10
+ /**
11
+ * Bitcoin RPC provider client
12
+ */
13
+ class BitcoinProvider {
14
+ constructor(providerUrl) {
15
+ this.providerUrl = providerUrl;
16
+ }
17
+ /**
18
+ * Get UTXOs for Bitcoin address
19
+ *
20
+ * @param address - Bitcoin address
21
+ * @param minConfirmations - Minimum confirmations required
22
+ * @returns Array of UTXOs
23
+ */
24
+ async getUtxos(address, minConfirmations = 1) {
25
+ // Query UTXOs from provider
26
+ // Implementation depends on provider API (Bitcoin Core RPC, Esplora, etc.)
27
+ // Placeholder - actual implementation would call provider API
28
+ throw new Error("getUtxos not implemented - provider-specific");
29
+ }
30
+ /**
31
+ * Get scriptPubKey for transaction output
32
+ *
33
+ * @param txid - Transaction ID
34
+ * @param vout - Output index
35
+ * @returns ScriptPubKey hex string
36
+ */
37
+ async getScriptPubKey(txid, vout) {
38
+ // Query transaction and extract scriptPubKey from specified output
39
+ // Placeholder - actual implementation would call provider API
40
+ throw new Error("getScriptPubKey not implemented - provider-specific");
41
+ }
42
+ /**
43
+ * Check if UTXO exists and is unspent
44
+ *
45
+ * @param txid - Transaction ID
46
+ * @param vout - Output index
47
+ * @returns true if UTXO exists and is unspent
48
+ */
49
+ async checkUtxoExists(txid, vout) {
50
+ // Query UTXO status from provider
51
+ // Placeholder - actual implementation would call provider API
52
+ throw new Error("checkUtxoExists not implemented - provider-specific");
53
+ }
54
+ /**
55
+ * Broadcast Bitcoin transaction
56
+ *
57
+ * @param txHex - Signed transaction hex
58
+ * @returns Transaction ID
59
+ */
60
+ async broadcastTransaction(txHex) {
61
+ // Send raw transaction to Bitcoin network
62
+ // Placeholder - actual implementation would call provider API
63
+ throw new Error("broadcastTransaction not implemented - provider-specific");
64
+ }
65
+ }
66
+ exports.BitcoinProvider = BitcoinProvider;
67
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../src/modules/bitcoin/provider.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAaH;;GAEG;AACH,MAAa,eAAe;IAG1B,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,CACZ,OAAe,EACf,mBAA2B,CAAC;QAE5B,4BAA4B;QAC5B,2EAA2E;QAE3E,8DAA8D;QAC9D,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CAAC,IAAY,EAAE,IAAY;QAC9C,mEAAmE;QAEnE,8DAA8D;QAC9D,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CAAC,IAAY,EAAE,IAAY;QAC9C,kCAAkC;QAElC,8DAA8D;QAC9D,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,oBAAoB,CAAC,KAAa;QACtC,0CAA0C;QAE1C,8DAA8D;QAC9D,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;CACF;AAjED,0CAiEC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Bitcoin Signature Module
3
+ *
4
+ * Handles conversion of Ethereum-format signatures to Bitcoin DER format.
5
+ * Implements BIP 62 s-value normalization and DER encoding.
6
+ *
7
+ * CRITICAL: Handles both prefixed (0x...) and non-prefixed hex strings correctly.
8
+ * LIT Protocol returns signatures without 0x prefix.
9
+ */
10
+ /**
11
+ * Convert Ethereum signature to Bitcoin DER format
12
+ *
13
+ * CRITICAL FIX: Conditional prefix removal
14
+ * - LIT Protocol returns {r: '59f9d5b0...', s: '6b5a9233...'} (NO 0x prefix)
15
+ * - Must check for prefix before slicing to avoid removing first data byte
16
+ *
17
+ * @param sig - Ethereum signature {r: string, s: string}
18
+ * @returns DER-encoded signature (hex string)
19
+ */
20
+ export declare function ethereumSignatureToBtcSignature(sig: {
21
+ r: string;
22
+ s: string;
23
+ }): string;
24
+ //# sourceMappingURL=signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../../src/modules/bitcoin/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAAC,GAAG,EAAE;IACnD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GAAG,MAAM,CA+CT"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /**
3
+ * Bitcoin Signature Module
4
+ *
5
+ * Handles conversion of Ethereum-format signatures to Bitcoin DER format.
6
+ * Implements BIP 62 s-value normalization and DER encoding.
7
+ *
8
+ * CRITICAL: Handles both prefixed (0x...) and non-prefixed hex strings correctly.
9
+ * LIT Protocol returns signatures without 0x prefix.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ethereumSignatureToBtcSignature = ethereumSignatureToBtcSignature;
13
+ /**
14
+ * Convert Ethereum signature to Bitcoin DER format
15
+ *
16
+ * CRITICAL FIX: Conditional prefix removal
17
+ * - LIT Protocol returns {r: '59f9d5b0...', s: '6b5a9233...'} (NO 0x prefix)
18
+ * - Must check for prefix before slicing to avoid removing first data byte
19
+ *
20
+ * @param sig - Ethereum signature {r: string, s: string}
21
+ * @returns DER-encoded signature (hex string)
22
+ */
23
+ function ethereumSignatureToBtcSignature(sig) {
24
+ // CRITICAL FIX: Conditional prefix removal
25
+ // Check for 0x prefix before slicing to avoid removing first data byte
26
+ const rHex = sig.r.startsWith("0x") ? sig.r.slice(2) : sig.r;
27
+ const sHex = sig.s.startsWith("0x") ? sig.s.slice(2) : sig.s;
28
+ let r = Buffer.from(rHex, "hex");
29
+ let s = Buffer.from(sHex, "hex");
30
+ // BIP 62: s-value normalization (low-s requirement)
31
+ // Bitcoin requires s <= n/2 where n is the curve order
32
+ // If s > n/2, replace with n - s
33
+ // @ts-ignore - EC available in LIT runtime (elliptic library)
34
+ const EC = require("elliptic").ec;
35
+ const secp256k1 = new EC("secp256k1");
36
+ const n = secp256k1.curve.n;
37
+ let sBN = BigInt("0x" + s.toString("hex"));
38
+ const halfN = n.divn(2);
39
+ if (sBN > BigInt(halfN.toString())) {
40
+ // s is too large, normalize it
41
+ sBN = BigInt(n.toString()) - sBN;
42
+ s = Buffer.from(sBN.toString(16).padStart(64, "0"), "hex");
43
+ }
44
+ // Ensure positive representation (DER requires leading 0x00 if high bit set)
45
+ // If first byte >= 0x80, prepend 0x00 to indicate positive number
46
+ if (r[0] >= 0x80) {
47
+ r = Buffer.concat([Buffer.from([0x00]), r]);
48
+ }
49
+ if (s[0] >= 0x80) {
50
+ s = Buffer.concat([Buffer.from([0x00]), s]);
51
+ }
52
+ // Remove leading zero bytes (unless needed for sign bit)
53
+ while (r.length > 1 && r[0] === 0x00 && r[1] < 0x80) {
54
+ r = r.slice(1);
55
+ }
56
+ while (s.length > 1 && s[0] === 0x00 && s[1] < 0x80) {
57
+ s = s.slice(1);
58
+ }
59
+ // DER encode using bip66
60
+ // @ts-ignore - bip66 available in LIT runtime
61
+ const bip66 = require("bip66");
62
+ return Buffer.from(bip66.encode(r, s)).toString("hex");
63
+ }
64
+ //# sourceMappingURL=signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../src/modules/bitcoin/signature.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAYH,0EAkDC;AA5DD;;;;;;;;;GASG;AACH,SAAgB,+BAA+B,CAAC,GAG/C;IACC,2CAA2C;IAC3C,uEAAuE;IACvE,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;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C,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,yDAAyD;IACzD,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;QACpD,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;QACpD,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,yBAAyB;IACzB,8CAA8C;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Bitcoin Transaction Module
3
+ *
4
+ * Provides Bitcoin transaction building and signature hash computation.
5
+ * Implements Bitcoin protocol transaction structure and SIGHASH_ALL signing.
6
+ */
7
+ /**
8
+ * UTXO input for transaction building
9
+ */
10
+ export interface UTXOInput {
11
+ txid: string;
12
+ vout: number;
13
+ value: number;
14
+ scriptPubKey: string;
15
+ }
16
+ /**
17
+ * Transaction building parameters
18
+ */
19
+ export interface TransactionParams {
20
+ utxo: UTXOInput;
21
+ destination: string;
22
+ amount: number;
23
+ changeAddress: string;
24
+ changeAmount: number;
25
+ network: string;
26
+ pkpPublicKey: string;
27
+ }
28
+ /**
29
+ * Transaction building result
30
+ */
31
+ export interface TransactionResult {
32
+ txHex: string;
33
+ sigHash: string;
34
+ }
35
+ /**
36
+ * Build Bitcoin transaction and compute signature hash
37
+ *
38
+ * Creates a SegWit (P2WPKH) Bitcoin transaction following BIP 143:
39
+ * - Version: 4 bytes (little endian) - version 2
40
+ * - Input count: varint
41
+ * - Inputs: txid (reversed) + vout + scriptSig (empty for witness) + sequence
42
+ * - Output count: varint
43
+ * - Outputs: value + scriptPubKey
44
+ * - Locktime: 4 bytes
45
+ *
46
+ * For BIP 143 SIGHASH_ALL signature hash (P2WPKH):
47
+ * The sighash preimage includes:
48
+ * 1. nVersion (4 bytes)
49
+ * 2. hashPrevouts (32 bytes) - double SHA256 of all input outpoints
50
+ * 3. hashSequence (32 bytes) - double SHA256 of all input sequences
51
+ * 4. outpoint (36 bytes) - txid + vout of input being signed
52
+ * 5. scriptCode (variable) - for P2WPKH: OP_DUP OP_HASH160 <20-byte-hash> OP_EQUALVERIFY OP_CHECKSIG
53
+ * 6. value (8 bytes) - value of output being spent
54
+ * 7. nSequence (4 bytes) - sequence of input being signed
55
+ * 8. hashOutputs (32 bytes) - double SHA256 of all outputs
56
+ * 9. nLocktime (4 bytes)
57
+ * 10. nHashType (4 bytes) - SIGHASH_ALL = 0x01000000
58
+ *
59
+ * @param params - Transaction parameters
60
+ * @returns Transaction hex and signature hash
61
+ */
62
+ export declare function buildBitcoinTransaction(params: TransactionParams): TransactionResult;
63
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../../src/modules/bitcoin/transaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,iBAAiB,GACxB,iBAAiB,CAyInB"}