@spirobel/monero-wallet-api 0.3.13 → 0.3.15

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.
@@ -21,6 +21,8 @@ export type FoundTransaction = {
21
21
  outputs: Output[];
22
22
  tx_hash: string;
23
23
  status: OutputStatus;
24
+ payment_id: number;
25
+ confirmations: number;
24
26
  txlog?: TxLog;
25
27
  };
26
28
  export type TxHash = string;
@@ -35,6 +37,7 @@ export type ScanStats = {
35
37
  found_transactions: Record<TxHash, FoundTransaction>;
36
38
  ordered_transactions: TxHash[];
37
39
  };
40
+ export declare function confirmationsOfOutput(output: Output, daemon_height: number): number;
38
41
  export declare function processFoundTransactions(cache: ScanCache, stats: ScanStats, current_height: number): void;
39
42
  export declare function removeChangeFromPrimaddressAmounts(stats: ScanStats): void;
40
43
  export declare function addSubAddressesFromCacheToScanStats(cache: ScanCache, stats: ScanStats): void;
@@ -85,11 +85,16 @@ export function addPendingAmount(scan_stats, output) {
85
85
  statsSubaddress.pending_amount = 0n;
86
86
  statsSubaddress.pending_amount += output.amount;
87
87
  }
88
+ export function confirmationsOfOutput(output, daemon_height) {
89
+ return daemon_height - output.block_height;
90
+ }
88
91
  export function processFoundTransactions(cache, stats, current_height) {
89
92
  stats.found_transactions = {};
90
93
  stats.ordered_transactions = [];
94
+ const daemon_height = cache.daemon_height;
91
95
  Object.entries(cache.outputs).forEach(([_, output]) => {
92
96
  const status = outputStatus(output, cache, current_height || 0);
97
+ const confirmations = confirmationsOfOutput(output, daemon_height);
93
98
  const in_ordered_transactions = stats.ordered_transactions.includes(output.tx_hash);
94
99
  if (!in_ordered_transactions)
95
100
  stats.ordered_transactions.push(output.tx_hash);
@@ -109,6 +114,8 @@ export function processFoundTransactions(cache, stats, current_height) {
109
114
  amount: output.amount,
110
115
  outputs: [output],
111
116
  tx_hash: output.tx_hash,
117
+ payment_id: output.payment_id,
118
+ confirmations,
112
119
  };
113
120
  }
114
121
  // handle spent case
@@ -131,6 +138,8 @@ export function processFoundTransactions(cache, stats, current_height) {
131
138
  amount: -output.amount,
132
139
  outputs: [],
133
140
  tx_hash: output.spent_in_tx_hash,
141
+ payment_id: output.payment_id,
142
+ confirmations,
134
143
  txlog,
135
144
  };
136
145
  }
@@ -63,5 +63,5 @@ export type ShareViewkey002Pruned = {
63
63
  primary_address: string;
64
64
  wallet_slot: number;
65
65
  };
66
- export declare function potentialSuccessRedirect002(payload: ShareViewkeyPayload): Promise<void>;
66
+ export declare function potentialSuccessRedirect002(payload: ShareViewkeyPayload): Promise<ShareViewkeyResult | undefined>;
67
67
  export declare function handle002ShareRequest(req: Request, wallets: ScanSettingOpened[], parsed_cb: (parsed_body: ShareViewkey002Pruned) => Promise<void>, successUrl?: string): Promise<ShareViewkeyResult>;
@@ -221,6 +221,9 @@ export async function potentialSuccessRedirect002(payload) {
221
221
  window.location.href = shareVKresult.successUrl;
222
222
  window.location.reload();
223
223
  }
224
+ else {
225
+ return shareVKresult;
226
+ }
224
227
  }
225
228
  // backend response
226
229
  export async function handle002ShareRequest(req, wallets, parsed_cb, successUrl) {
@@ -239,9 +242,6 @@ export async function handle002ShareRequest(req, wallets, parsed_cb, successUrl)
239
242
  if (foundSlot.primary_address !== primary_address) {
240
243
  return { ok: false, successUrl: null };
241
244
  }
242
- if (foundSlot.secret_view_key !== viewkey) {
243
- return { ok: false, successUrl: null };
244
- }
245
245
  }
246
246
  await parsed_cb({ viewkey, primary_address, wallet_slot });
247
247
  return {
package/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "clean": "rm -rf ./dist"
41
41
  },
42
42
  "files": ["dist"],
43
- "version": "0.3.13",
43
+ "version": "0.3.15",
44
44
  "devDependencies": {
45
45
  "@types/bun": "latest"
46
46
  },