-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,188 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
# monero.ts wip library | ||
# monero.ts | ||
|
||
# Usage | ||
monero.ts uses Deno as its runtime of choice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { moneroChecksum } from "./checksum_monero.ts"; | ||
import { readCString } from "./src/utils.ts"; | ||
import { dylib } from "./src/bindings.ts"; | ||
|
||
export class ChecksumError extends Error { | ||
readonly code: number; | ||
readonly errors: string[]; | ||
|
||
constructor(code: number, errors: string[]) { | ||
super("MoneroC binding checksum failed:\n" + errors.join("\n")); | ||
this.code = code; | ||
this.errors = errors; | ||
} | ||
} | ||
|
||
/** | ||
* Validates MoneroC checksums | ||
* @returns {null} if checksums are correct | ||
* @returns {ChecksumError} which contains information about why checksum failed | ||
*/ | ||
export async function validateChecksum(): Promise<ChecksumError | null> { | ||
const cppHeaderHash = readCString(await dylib.symbols.MONERO_checksum_wallet2_api_c_h()); | ||
const tsHeaderHash = moneroChecksum.wallet2_api_c_h_sha256; | ||
|
||
const errors: string[] = []; | ||
|
||
let errorCode = 0; | ||
if (cppHeaderHash !== tsHeaderHash) { | ||
errors.push("ERR: Header file check mismatch"); | ||
errorCode++; | ||
} | ||
|
||
const cppSourceHash = readCString(await dylib.symbols.MONERO_checksum_wallet2_api_c_cpp()); | ||
const tsSourceHash = moneroChecksum.wallet2_api_c_cpp_sha256; | ||
if (cppSourceHash !== tsSourceHash) { | ||
errors.push(`ERR: CPP source file check mismatch ${cppSourceHash} == ${tsSourceHash}`); | ||
errorCode++; | ||
} | ||
|
||
const cppExportHash = readCString(await dylib.symbols.MONERO_checksum_wallet2_api_c_exp()); | ||
const tsExportHash = moneroChecksum.wallet2_api_c_exp_sha256; | ||
if (cppExportHash !== tsExportHash) { | ||
if (Deno.build.os !== "darwin") { | ||
errors.push("WARN: EXP source file check mismatch"); | ||
} else { | ||
errors.push(`ERR: EXP source file check mismatch ${cppExportHash} == ${tsExportHash}`); | ||
} | ||
errorCode++; | ||
} | ||
|
||
if (errorCode) { | ||
return new ChecksumError(errorCode, errors); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
if (import.meta.main) { | ||
const maybeError = await validateChecksum(); | ||
if (maybeError) { | ||
throw maybeError; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"fmt": { | ||
"lineWidth": 120 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export * from "./src/bindings.ts"; | ||
export * from "./src/pending_transaction.ts"; | ||
export * from "./src/transaction_history.ts"; | ||
export * from "./src/transaction_info.ts"; | ||
export * from "./src/wallet.ts"; | ||
export * from "./src/wallet_manager.ts"; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.