Skip to content
Snippets Groups Projects
Commit f336a504 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

scanForMatchingPrivateKeys uses waxStdException throwing scheme to throw...

scanForMatchingPrivateKeys uses waxStdException throwing scheme to throw actual custom exception only when it is needed
parent 20b5475f
No related branches found
No related tags found
1 merge request!228Expose `cpp_check_memo_for_private_keys`functionality to the Wax public interface
......@@ -8,8 +8,8 @@ import { ApiTransaction } from "./api";
import type { TAccountName } from "./hive_apps_operations";
import { operation, transaction } from "../protocol";
import { WaxError } from '../errors.js';
import { safeWasmCall } from "./util/wasm_errors.js";
import { WaxError, WaxPrivateKeyLeakDetectedException } from '../errors.js';
import { safeWasmCall, TWaxStdExceptionData } from "./util/wasm_errors.js";
import { JSON_stringify_operation, JSON_stringify_transaction, matchesHiveProtocolType } from "./util/proto_type_utils";
import { Transaction } from "./transaction.js";
import Long from "long";
......@@ -416,7 +416,14 @@ export class WaxBaseApi implements IWaxBaseInterface {
actualOtherKeys.push_back(key);
}
safeWasmCall(()=>this.proto.cpp_scan_text_for_matching_private_keys(content, account, accountAuthorities, memoKey, actualOtherKeys ));
safeWasmCall(()=>this.proto.cpp_scan_text_for_matching_private_keys(content, account, accountAuthorities, memoKey, actualOtherKeys),
(e: TWaxStdExceptionData): void => {
if(e.msg === "Detected private key leak.") {
const json = e.data as {public_key: string, authority_role: string};
throw new WaxPrivateKeyLeakDetectedException(e.msg, json.public_key, account, json.authority_role);
}
}
);
}
private calculateManabarPercent(current: Long, max: Long): number {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment