webycash-sdk 0.2.15 → 0.2.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/backend-ffi.js +15 -3
- package/libwebycash_sdk.so +0 -0
- package/package.json +1 -1
- package/wasm/package.json +1 -1
- package/wasm/webycash_sdk_wasm_bg.wasm +0 -0
- package/webycash_sdk.dll +0 -0
package/dist/backend-ffi.js
CHANGED
|
@@ -39,6 +39,15 @@ function takeString(val) {
|
|
|
39
39
|
return "";
|
|
40
40
|
return String(val);
|
|
41
41
|
}
|
|
42
|
+
/** Parse "Recovery completed! Webcash recovered: N, Total amount: X" */
|
|
43
|
+
function parseRecoveryResult(s) {
|
|
44
|
+
const countMatch = s.match(/recovered:\s*(\d+)/i);
|
|
45
|
+
const amountMatch = s.match(/amount:\s*([\d.]+)/i);
|
|
46
|
+
return {
|
|
47
|
+
recoveredCount: countMatch ? parseInt(countMatch[1], 10) : 0,
|
|
48
|
+
totalAmount: amountMatch ? BigInt(Math.round(parseFloat(amountMatch[1]) * 1e8)) : 0n,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
42
51
|
function assertFfi(handle) {
|
|
43
52
|
if (handle._tag !== "ffi")
|
|
44
53
|
throw new Error("Expected FFI handle");
|
|
@@ -126,8 +135,11 @@ export class FfiBackend {
|
|
|
126
135
|
return { handle, paymentWebcash: takeString(out[0]) };
|
|
127
136
|
}
|
|
128
137
|
async walletCheck(handle) {
|
|
138
|
+
// FFI check() only returns success/failure — no detailed counts available via C ABI
|
|
129
139
|
check(ffi.weby_wallet_check(assertFfi(handle)));
|
|
130
|
-
|
|
140
|
+
// Re-query stats to get actual counts post-check
|
|
141
|
+
const stats = await this.walletStats(handle);
|
|
142
|
+
return { handle, result: { validCount: stats.unspentWebcash, spentCount: stats.spentWebcash } };
|
|
131
143
|
}
|
|
132
144
|
async walletMerge(handle, maxOutputs) {
|
|
133
145
|
const out = [null];
|
|
@@ -137,12 +149,12 @@ export class FfiBackend {
|
|
|
137
149
|
async walletRecover(handle, masterSecretHex, gapLimit) {
|
|
138
150
|
const out = [null];
|
|
139
151
|
check(ffi.weby_wallet_recover(assertFfi(handle), masterSecretHex, gapLimit, out));
|
|
140
|
-
return { handle, result:
|
|
152
|
+
return { handle, result: parseRecoveryResult(takeString(out[0])) };
|
|
141
153
|
}
|
|
142
154
|
async walletRecoverFromWallet(handle, gapLimit) {
|
|
143
155
|
const out = [null];
|
|
144
156
|
check(ffi.weby_wallet_recover_from_wallet(assertFfi(handle), gapLimit, out));
|
|
145
|
-
return { handle, result:
|
|
157
|
+
return { handle, result: parseRecoveryResult(takeString(out[0])) };
|
|
146
158
|
}
|
|
147
159
|
// ── Inspection ─────────────────────────────────────────────
|
|
148
160
|
async walletStats(handle) {
|
package/libwebycash_sdk.so
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/wasm/package.json
CHANGED
|
Binary file
|
package/webycash_sdk.dll
CHANGED
|
Binary file
|