mainnet-js 2.3.0 → 2.3.2
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/index.html +1 -1
- package/dist/{mainnet-2.3.0.js → mainnet-2.3.2.js} +422 -432
- package/dist/module/libauth.d.ts +1 -1
- package/dist/module/libauth.d.ts.map +1 -1
- package/dist/module/libauth.js +1 -1
- package/dist/module/libauth.js.map +1 -1
- package/dist/module/network/interface.d.ts +1 -1
- package/dist/module/network/interface.d.ts.map +1 -1
- package/dist/module/transaction/Wif.d.ts +2 -2
- package/dist/module/transaction/Wif.d.ts.map +1 -1
- package/dist/module/transaction/Wif.js +5 -5
- package/dist/module/transaction/Wif.js.map +1 -1
- package/dist/module/util/index.d.ts +1 -3
- package/dist/module/util/index.d.ts.map +1 -1
- package/dist/module/util/index.js +1 -3
- package/dist/module/util/index.js.map +1 -1
- package/dist/module/util/randomInt.d.ts +1 -1
- package/dist/module/util/randomInt.d.ts.map +1 -1
- package/dist/module/util/randomInt.js +1 -1
- package/dist/module/util/randomInt.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/libauth.ts +4 -4
- package/src/network/interface.ts +1 -1
- package/src/transaction/Wif.ts +7 -11
- package/src/util/index.ts +1 -3
- package/src/util/randomInt.test.ts +3 -3
- package/src/util/randomInt.ts +1 -1
- package/src/util/satoshiToAmount.test.ts +1 -1
- package/dist/module/util/randomValues.d.ts +0 -2
- package/dist/module/util/randomValues.d.ts.map +0 -1
- package/dist/module/util/randomValues.js +0 -13
- package/dist/module/util/randomValues.js.map +0 -1
- package/src/util/randomValues.ts +0 -13
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "https://github.com/mainnet-cash/mainnet-js/issues"
|
|
10
10
|
},
|
|
11
11
|
"name": "mainnet-js",
|
|
12
|
-
"version": "2.3.
|
|
12
|
+
"version": "2.3.2",
|
|
13
13
|
"homepage": "https://mainnet.cash",
|
|
14
14
|
"module": "dist/module/index.js",
|
|
15
15
|
"browser": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"reload": "npx reload --dir=../../jest/playwright "
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@bitauth/libauth": "^2.0.0
|
|
41
|
+
"@bitauth/libauth": "^2.0.0",
|
|
42
42
|
"bip39": "^3.0.3",
|
|
43
43
|
"buffer": "^6.0.3",
|
|
44
44
|
"electrum-cash": "^2.0.10",
|
package/src/libauth.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
importWalletTemplate,
|
|
3
|
+
walletTemplateP2pkhNonHd,
|
|
4
|
+
walletTemplateP2pkh,
|
|
5
|
+
walletTemplateToCompilerBCH,
|
|
6
6
|
cashAddressToLockingBytecode,
|
|
7
7
|
hexToBin,
|
|
8
8
|
generateTransaction,
|
package/src/network/interface.ts
CHANGED
package/src/transaction/Wif.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
walletTemplateP2pkhNonHd,
|
|
3
|
+
walletTemplateToCompilerBCH,
|
|
4
4
|
cashAddressToLockingBytecode,
|
|
5
5
|
Compiler,
|
|
6
6
|
encodeTransaction,
|
|
7
7
|
generateTransaction,
|
|
8
|
-
|
|
8
|
+
importWalletTemplate,
|
|
9
9
|
AnyCompilerConfiguration,
|
|
10
10
|
AuthenticationProgramStateCommon,
|
|
11
11
|
CompilationContextBCH,
|
|
@@ -55,14 +55,12 @@ export async function buildP2pkhNonHdTransaction({
|
|
|
55
55
|
throw new Error("Missing signing key when building transaction");
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const template =
|
|
59
|
-
authenticationTemplateP2pkhNonHd
|
|
60
|
-
);
|
|
58
|
+
const template = importWalletTemplate(walletTemplateP2pkhNonHd);
|
|
61
59
|
if (typeof template === "string") {
|
|
62
60
|
throw new Error("Transaction template error");
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
const compiler = await
|
|
63
|
+
const compiler = await walletTemplateToCompilerBCH(template);
|
|
66
64
|
const inputAmount = await sumUtxoValue(inputs);
|
|
67
65
|
|
|
68
66
|
const sendAmount = await sumSendRequestAmounts(outputs);
|
|
@@ -586,14 +584,12 @@ export async function signUnsignedTransaction(
|
|
|
586
584
|
throw decoded;
|
|
587
585
|
}
|
|
588
586
|
|
|
589
|
-
const template =
|
|
590
|
-
authenticationTemplateP2pkhNonHd
|
|
591
|
-
);
|
|
587
|
+
const template = importWalletTemplate(walletTemplateP2pkhNonHd);
|
|
592
588
|
if (typeof template === "string") {
|
|
593
589
|
throw new Error("Transaction template error");
|
|
594
590
|
}
|
|
595
591
|
|
|
596
|
-
const compiler =
|
|
592
|
+
const compiler = walletTemplateToCompilerBCH(template);
|
|
597
593
|
const transactionTemplate: Readonly<
|
|
598
594
|
TransactionTemplateFixed<typeof compiler>
|
|
599
595
|
> = { ...decoded };
|
package/src/util/index.ts
CHANGED
|
@@ -25,10 +25,8 @@ export { hash160 } from "./hash160.js";
|
|
|
25
25
|
export { ExchangeRate } from "../rate/ExchangeRate.js";
|
|
26
26
|
export { sanitizeAddress } from "./sanitizeAddress.js";
|
|
27
27
|
export { sanitizeUnit } from "./sanitizeUnit.js";
|
|
28
|
-
export {
|
|
28
|
+
export { getWeakRandomInt } from "./randomInt.js";
|
|
29
29
|
export { getXPubKey } from "../util/getXPubKey.js";
|
|
30
|
-
import * as randomValues from "./randomValues.js";
|
|
31
|
-
export { randomValues };
|
|
32
30
|
export { sumUtxoValue } from "./sumUtxoValue.js";
|
|
33
31
|
export {
|
|
34
32
|
BalanceResponse,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getWeakRandomInt } from "./randomInt";
|
|
2
2
|
|
|
3
3
|
test("get a random int", async () => {
|
|
4
|
-
let zero = await
|
|
4
|
+
let zero = await getWeakRandomInt(0);
|
|
5
5
|
expect(zero).toBe(0);
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
test("average some random ints", async () => {
|
|
9
9
|
let average = 0;
|
|
10
10
|
for (let i = 0; i < 100; i++) {
|
|
11
|
-
average +=
|
|
11
|
+
average += getWeakRandomInt(1000) / 100;
|
|
12
12
|
}
|
|
13
13
|
expect(average).toBeGreaterThan(400);
|
|
14
14
|
expect(average).toBeLessThan(600);
|
package/src/util/randomInt.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"randomValues.d.ts","sourceRoot":"","sources":["../../../src/util/randomValues.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getRuntimePlatform } from "./getRuntimePlatform.js";
|
|
2
|
-
import crypto from "crypto";
|
|
3
|
-
if (getRuntimePlatform() === "node") {
|
|
4
|
-
if (!globalThis.crypto || !globalThis.crypto.getRandomValues) {
|
|
5
|
-
globalThis.crypto = crypto;
|
|
6
|
-
// (globalThis.crypto as any).getRandomValues = (buf: Uint8Array) => {
|
|
7
|
-
// const bytes = crypto.randomBytes(buf.length);
|
|
8
|
-
// buf.set(bytes);
|
|
9
|
-
// return buf;
|
|
10
|
-
// };
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=randomValues.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"randomValues.js","sourceRoot":"","sources":["../../../src/util/randomValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,IAAI,kBAAkB,EAAE,KAAK,MAAM,EAAE;IACnC,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe,EAAE;QAC3D,UAAkB,CAAC,MAAM,GAAG,MAAM,CAAC;QACpC,sEAAsE;QACtE,kDAAkD;QAClD,oBAAoB;QACpB,gBAAgB;QAChB,KAAK;KACN;CACF"}
|
package/src/util/randomValues.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getRuntimePlatform } from "./getRuntimePlatform.js";
|
|
2
|
-
import crypto from "crypto";
|
|
3
|
-
|
|
4
|
-
if (getRuntimePlatform() === "node") {
|
|
5
|
-
if (!globalThis.crypto || !globalThis.crypto.getRandomValues) {
|
|
6
|
-
(globalThis as any).crypto = crypto;
|
|
7
|
-
// (globalThis.crypto as any).getRandomValues = (buf: Uint8Array) => {
|
|
8
|
-
// const bytes = crypto.randomBytes(buf.length);
|
|
9
|
-
// buf.set(bytes);
|
|
10
|
-
// return buf;
|
|
11
|
-
// };
|
|
12
|
-
}
|
|
13
|
-
}
|