@adelos/sdk 0.1.10 → 0.1.11

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/index.d.mts CHANGED
@@ -22,6 +22,20 @@ interface RegistryInfo {
22
22
  account: RegistryAccount;
23
23
  exists: boolean;
24
24
  }
25
+ /** Stealth transaction detected during scanning */
26
+ interface StealthTransaction {
27
+ signature: string;
28
+ blockTime: number | null;
29
+ stealthAddress: PublicKey;
30
+ amount: bigint;
31
+ /** Ephemeral public key from memo - needed for withdraw */
32
+ ephemeralPk: Uint8Array;
33
+ }
34
+ /** Stealth transaction ready for withdrawal */
35
+ interface WithdrawableTransaction extends StealthTransaction {
36
+ /** Recovered stealth secret key - used to sign withdraw tx */
37
+ stealthSecretKey: Uint8Array;
38
+ }
25
39
 
26
40
  type SolanaCluster = "devnet";
27
41
  declare const ADELOS_CONFIG: {
@@ -106,12 +120,6 @@ declare function generateStealthAddress(recipientMetaPk: Uint8Array): {
106
120
  * Adelos Indexer - Privacy-Preserving Transaction Scanner
107
121
  */
108
122
 
109
- interface StealthTransaction {
110
- signature: string;
111
- blockTime: number | null;
112
- stealthAddress: PublicKey;
113
- amount: bigint;
114
- }
115
123
  declare class AdelosIndexer {
116
124
  private connection;
117
125
  constructor(connection: Connection);
@@ -124,7 +132,12 @@ declare class AdelosIndexer {
124
132
  attemptDecryption(tx: ParsedTransactionWithMeta, metaSk: Uint8Array, metaPk: Uint8Array): {
125
133
  stealthAddress: PublicKey;
126
134
  amount: bigint;
135
+ ephemeralPk: Uint8Array;
127
136
  } | null;
137
+ /**
138
+ * Prepare a stealth transaction for withdrawal by recovering the secret key.
139
+ */
140
+ prepareWithdraw(stealthTx: StealthTransaction, metaSk: Uint8Array, metaPk: Uint8Array): WithdrawableTransaction;
128
141
  private extractMemo;
129
142
  }
130
143
  /** Helper for quick initialization */
@@ -147,9 +160,24 @@ declare class AdelosSDK {
147
160
  createRegisterTransaction(owner: PublicKey, metaPubkey: Uint8Array, version?: "legacy" | "v0"): Promise<Transaction | VersionedTransaction>;
148
161
  /** Membuat transaksi pembaruan identitas (jika sudah terdaftar) */
149
162
  createUpdateTransaction(owner: PublicKey, metaPubkey: Uint8Array, version?: "legacy" | "v0"): Promise<Transaction | VersionedTransaction>;
163
+ /**
164
+ * Create a withdraw transaction from stealth address to any destination.
165
+ * This enables both:
166
+ * - Withdraw to self (destination = user's main wallet)
167
+ * - Withdraw to any address (for enhanced privacy - no link to main wallet!)
168
+ *
169
+ * @param stealthSecretKey - The recovered stealth private key (from prepareWithdraw)
170
+ * @param stealthAddress - The stealth address holding the funds
171
+ * @param destination - Where to send the funds (can be ANY address)
172
+ * @param amountLamports - Amount to withdraw in lamports (use BigInt)
173
+ */
174
+ createWithdrawTransaction(stealthSecretKey: Uint8Array, stealthAddress: PublicKey, destination: PublicKey, amountLamports: bigint): Promise<{
175
+ transaction: VersionedTransaction;
176
+ signature: string;
177
+ }>;
150
178
  buildTransaction(payer: PublicKey, instructions: TransactionInstruction[], version?: "legacy" | "v0"): Promise<Transaction | VersionedTransaction>;
151
179
  /** Satu fungsi kirim untuk semua jenis transaksi (Legacy/V0) */
152
180
  sendAndConfirm(signedTx: Transaction | VersionedTransaction): Promise<string>;
153
181
  }
154
182
 
155
- export { ADELOS_CONFIG, AdelosIndexer, type AdelosOptions, AdelosSDK, MEMO_PREFIX, MEMO_PROGRAM_ID, PROGRAM_ID, REGISTRY_SEED, RPC_URL, type RegistryAccount, type RegistryInfo, STEALTH_DOMAIN, type SolanaCluster, type StealthTransaction, bytesToHex, computeSharedSecret, computeSharedSecretAsRecipient, createIndexer, derivePublicKey, deriveRegistryPda, deriveStealthPubkey, generateEphemeralKeypair, generateStealthAddress, generateStealthMemo, getDiscriminator, hexToBytes, isValidMetaPubkey, parseStealthMemo, recoverStealthSecretKey };
183
+ export { ADELOS_CONFIG, AdelosIndexer, type AdelosOptions, AdelosSDK, MEMO_PREFIX, MEMO_PROGRAM_ID, PROGRAM_ID, REGISTRY_SEED, RPC_URL, type RegistryAccount, type RegistryInfo, STEALTH_DOMAIN, type SolanaCluster, type StealthTransaction, type WithdrawableTransaction, bytesToHex, computeSharedSecret, computeSharedSecretAsRecipient, createIndexer, derivePublicKey, deriveRegistryPda, deriveStealthPubkey, generateEphemeralKeypair, generateStealthAddress, generateStealthMemo, getDiscriminator, hexToBytes, isValidMetaPubkey, parseStealthMemo, recoverStealthSecretKey };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,20 @@ interface RegistryInfo {
22
22
  account: RegistryAccount;
23
23
  exists: boolean;
24
24
  }
25
+ /** Stealth transaction detected during scanning */
26
+ interface StealthTransaction {
27
+ signature: string;
28
+ blockTime: number | null;
29
+ stealthAddress: PublicKey;
30
+ amount: bigint;
31
+ /** Ephemeral public key from memo - needed for withdraw */
32
+ ephemeralPk: Uint8Array;
33
+ }
34
+ /** Stealth transaction ready for withdrawal */
35
+ interface WithdrawableTransaction extends StealthTransaction {
36
+ /** Recovered stealth secret key - used to sign withdraw tx */
37
+ stealthSecretKey: Uint8Array;
38
+ }
25
39
 
26
40
  type SolanaCluster = "devnet";
27
41
  declare const ADELOS_CONFIG: {
@@ -106,12 +120,6 @@ declare function generateStealthAddress(recipientMetaPk: Uint8Array): {
106
120
  * Adelos Indexer - Privacy-Preserving Transaction Scanner
107
121
  */
108
122
 
109
- interface StealthTransaction {
110
- signature: string;
111
- blockTime: number | null;
112
- stealthAddress: PublicKey;
113
- amount: bigint;
114
- }
115
123
  declare class AdelosIndexer {
116
124
  private connection;
117
125
  constructor(connection: Connection);
@@ -124,7 +132,12 @@ declare class AdelosIndexer {
124
132
  attemptDecryption(tx: ParsedTransactionWithMeta, metaSk: Uint8Array, metaPk: Uint8Array): {
125
133
  stealthAddress: PublicKey;
126
134
  amount: bigint;
135
+ ephemeralPk: Uint8Array;
127
136
  } | null;
137
+ /**
138
+ * Prepare a stealth transaction for withdrawal by recovering the secret key.
139
+ */
140
+ prepareWithdraw(stealthTx: StealthTransaction, metaSk: Uint8Array, metaPk: Uint8Array): WithdrawableTransaction;
128
141
  private extractMemo;
129
142
  }
130
143
  /** Helper for quick initialization */
@@ -147,9 +160,24 @@ declare class AdelosSDK {
147
160
  createRegisterTransaction(owner: PublicKey, metaPubkey: Uint8Array, version?: "legacy" | "v0"): Promise<Transaction | VersionedTransaction>;
148
161
  /** Membuat transaksi pembaruan identitas (jika sudah terdaftar) */
149
162
  createUpdateTransaction(owner: PublicKey, metaPubkey: Uint8Array, version?: "legacy" | "v0"): Promise<Transaction | VersionedTransaction>;
163
+ /**
164
+ * Create a withdraw transaction from stealth address to any destination.
165
+ * This enables both:
166
+ * - Withdraw to self (destination = user's main wallet)
167
+ * - Withdraw to any address (for enhanced privacy - no link to main wallet!)
168
+ *
169
+ * @param stealthSecretKey - The recovered stealth private key (from prepareWithdraw)
170
+ * @param stealthAddress - The stealth address holding the funds
171
+ * @param destination - Where to send the funds (can be ANY address)
172
+ * @param amountLamports - Amount to withdraw in lamports (use BigInt)
173
+ */
174
+ createWithdrawTransaction(stealthSecretKey: Uint8Array, stealthAddress: PublicKey, destination: PublicKey, amountLamports: bigint): Promise<{
175
+ transaction: VersionedTransaction;
176
+ signature: string;
177
+ }>;
150
178
  buildTransaction(payer: PublicKey, instructions: TransactionInstruction[], version?: "legacy" | "v0"): Promise<Transaction | VersionedTransaction>;
151
179
  /** Satu fungsi kirim untuk semua jenis transaksi (Legacy/V0) */
152
180
  sendAndConfirm(signedTx: Transaction | VersionedTransaction): Promise<string>;
153
181
  }
154
182
 
155
- export { ADELOS_CONFIG, AdelosIndexer, type AdelosOptions, AdelosSDK, MEMO_PREFIX, MEMO_PROGRAM_ID, PROGRAM_ID, REGISTRY_SEED, RPC_URL, type RegistryAccount, type RegistryInfo, STEALTH_DOMAIN, type SolanaCluster, type StealthTransaction, bytesToHex, computeSharedSecret, computeSharedSecretAsRecipient, createIndexer, derivePublicKey, deriveRegistryPda, deriveStealthPubkey, generateEphemeralKeypair, generateStealthAddress, generateStealthMemo, getDiscriminator, hexToBytes, isValidMetaPubkey, parseStealthMemo, recoverStealthSecretKey };
183
+ export { ADELOS_CONFIG, AdelosIndexer, type AdelosOptions, AdelosSDK, MEMO_PREFIX, MEMO_PROGRAM_ID, PROGRAM_ID, REGISTRY_SEED, RPC_URL, type RegistryAccount, type RegistryInfo, STEALTH_DOMAIN, type SolanaCluster, type StealthTransaction, type WithdrawableTransaction, bytesToHex, computeSharedSecret, computeSharedSecretAsRecipient, createIndexer, derivePublicKey, deriveRegistryPda, deriveStealthPubkey, generateEphemeralKeypair, generateStealthAddress, generateStealthMemo, getDiscriminator, hexToBytes, isValidMetaPubkey, parseStealthMemo, recoverStealthSecretKey };
package/dist/index.js CHANGED
@@ -240,7 +240,8 @@ var AdelosIndexer = class {
240
240
  signature: s.signature,
241
241
  blockTime: tx.blockTime ?? null,
242
242
  stealthAddress: detected.stealthAddress,
243
- amount: detected.amount
243
+ amount: detected.amount,
244
+ ephemeralPk: detected.ephemeralPk
244
245
  });
245
246
  } else {
246
247
  log(` \u21B3 Not for this recipient`);
@@ -271,7 +272,19 @@ var AdelosIndexer = class {
271
272
  const change = BigInt(postBalances[idx] || 0) - BigInt(preBalances[idx] || 0);
272
273
  return {
273
274
  stealthAddress: accounts[idx].pubkey,
274
- amount: change > 0n ? change : 0n
275
+ amount: change > 0n ? change : 0n,
276
+ ephemeralPk
277
+ };
278
+ }
279
+ /**
280
+ * Prepare a stealth transaction for withdrawal by recovering the secret key.
281
+ */
282
+ prepareWithdraw(stealthTx, metaSk, metaPk) {
283
+ const sharedSecret = computeSharedSecretAsRecipient(metaSk, stealthTx.ephemeralPk);
284
+ const stealthSecretKey = recoverStealthSecretKey(metaSk, sharedSecret);
285
+ return {
286
+ ...stealthTx,
287
+ stealthSecretKey
275
288
  };
276
289
  }
277
290
  extractMemo(tx) {
@@ -371,6 +384,41 @@ var AdelosSDK = class {
371
384
  });
372
385
  return this.buildTransaction(owner, [ix], version);
373
386
  }
387
+ /**
388
+ * Create a withdraw transaction from stealth address to any destination.
389
+ * This enables both:
390
+ * - Withdraw to self (destination = user's main wallet)
391
+ * - Withdraw to any address (for enhanced privacy - no link to main wallet!)
392
+ *
393
+ * @param stealthSecretKey - The recovered stealth private key (from prepareWithdraw)
394
+ * @param stealthAddress - The stealth address holding the funds
395
+ * @param destination - Where to send the funds (can be ANY address)
396
+ * @param amountLamports - Amount to withdraw in lamports (use BigInt)
397
+ */
398
+ async createWithdrawTransaction(stealthSecretKey, stealthAddress, destination, amountLamports) {
399
+ const { Keypair } = await import("@solana/web3.js");
400
+ const stealthKeypair = Keypair.fromSeed(stealthSecretKey);
401
+ if (!stealthKeypair.publicKey.equals(stealthAddress)) {
402
+ throw new Error("Stealth secret key does not match stealth address");
403
+ }
404
+ const ix = import_web33.SystemProgram.transfer({
405
+ fromPubkey: stealthAddress,
406
+ toPubkey: destination,
407
+ lamports: amountLamports
408
+ });
409
+ const { blockhash } = await this.connection.getLatestBlockhash();
410
+ const message = new import_web33.TransactionMessage({
411
+ payerKey: stealthAddress,
412
+ // Stealth pays the fee
413
+ recentBlockhash: blockhash,
414
+ instructions: [ix]
415
+ }).compileToV0Message();
416
+ const tx = new import_web33.VersionedTransaction(message);
417
+ tx.sign([stealthKeypair]);
418
+ const sig = await this.connection.sendRawTransaction(tx.serialize());
419
+ await this.connection.confirmTransaction(sig, "confirmed");
420
+ return { transaction: tx, signature: sig };
421
+ }
374
422
  // --- 3. Core Engine (Internal Helpers) ---
375
423
  async buildTransaction(payer, instructions, version = "v0") {
376
424
  const { blockhash } = await this.connection.getLatestBlockhash();
package/dist/index.mjs CHANGED
@@ -191,7 +191,8 @@ var AdelosIndexer = class {
191
191
  signature: s.signature,
192
192
  blockTime: tx.blockTime ?? null,
193
193
  stealthAddress: detected.stealthAddress,
194
- amount: detected.amount
194
+ amount: detected.amount,
195
+ ephemeralPk: detected.ephemeralPk
195
196
  });
196
197
  } else {
197
198
  log(` \u21B3 Not for this recipient`);
@@ -222,7 +223,19 @@ var AdelosIndexer = class {
222
223
  const change = BigInt(postBalances[idx] || 0) - BigInt(preBalances[idx] || 0);
223
224
  return {
224
225
  stealthAddress: accounts[idx].pubkey,
225
- amount: change > 0n ? change : 0n
226
+ amount: change > 0n ? change : 0n,
227
+ ephemeralPk
228
+ };
229
+ }
230
+ /**
231
+ * Prepare a stealth transaction for withdrawal by recovering the secret key.
232
+ */
233
+ prepareWithdraw(stealthTx, metaSk, metaPk) {
234
+ const sharedSecret = computeSharedSecretAsRecipient(metaSk, stealthTx.ephemeralPk);
235
+ const stealthSecretKey = recoverStealthSecretKey(metaSk, sharedSecret);
236
+ return {
237
+ ...stealthTx,
238
+ stealthSecretKey
226
239
  };
227
240
  }
228
241
  extractMemo(tx) {
@@ -322,6 +335,41 @@ var AdelosSDK = class {
322
335
  });
323
336
  return this.buildTransaction(owner, [ix], version);
324
337
  }
338
+ /**
339
+ * Create a withdraw transaction from stealth address to any destination.
340
+ * This enables both:
341
+ * - Withdraw to self (destination = user's main wallet)
342
+ * - Withdraw to any address (for enhanced privacy - no link to main wallet!)
343
+ *
344
+ * @param stealthSecretKey - The recovered stealth private key (from prepareWithdraw)
345
+ * @param stealthAddress - The stealth address holding the funds
346
+ * @param destination - Where to send the funds (can be ANY address)
347
+ * @param amountLamports - Amount to withdraw in lamports (use BigInt)
348
+ */
349
+ async createWithdrawTransaction(stealthSecretKey, stealthAddress, destination, amountLamports) {
350
+ const { Keypair } = await import("@solana/web3.js");
351
+ const stealthKeypair = Keypair.fromSeed(stealthSecretKey);
352
+ if (!stealthKeypair.publicKey.equals(stealthAddress)) {
353
+ throw new Error("Stealth secret key does not match stealth address");
354
+ }
355
+ const ix = SystemProgram.transfer({
356
+ fromPubkey: stealthAddress,
357
+ toPubkey: destination,
358
+ lamports: amountLamports
359
+ });
360
+ const { blockhash } = await this.connection.getLatestBlockhash();
361
+ const message = new TransactionMessage({
362
+ payerKey: stealthAddress,
363
+ // Stealth pays the fee
364
+ recentBlockhash: blockhash,
365
+ instructions: [ix]
366
+ }).compileToV0Message();
367
+ const tx = new VersionedTransaction(message);
368
+ tx.sign([stealthKeypair]);
369
+ const sig = await this.connection.sendRawTransaction(tx.serialize());
370
+ await this.connection.confirmTransaction(sig, "confirmed");
371
+ return { transaction: tx, signature: sig };
372
+ }
325
373
  // --- 3. Core Engine (Internal Helpers) ---
326
374
  async buildTransaction(payer, instructions, version = "v0") {
327
375
  const { blockhash } = await this.connection.getLatestBlockhash();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adelos/sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Adelos Protocol SDK - Privacy Stealth Transfers on Solana",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",