@spirobel/monero-wallet-api 0.3.14 → 0.3.16
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/io/atomicWrite.js
CHANGED
|
@@ -5,6 +5,11 @@ export async function atomicWrite(targetPath, data) {
|
|
|
5
5
|
const { rename } = await import("node:fs/promises");
|
|
6
6
|
const tempPath = targetPath + ".tmp";
|
|
7
7
|
const bytesWritten = await Bun.write(tempPath, data);
|
|
8
|
-
|
|
8
|
+
try {
|
|
9
|
+
await rename(tempPath, targetPath);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
//eat rename failed
|
|
13
|
+
}
|
|
9
14
|
return bytesWritten;
|
|
10
15
|
}
|
|
@@ -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
|
}
|