mainnet-js 1.1.13 → 1.1.15
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-1.1.13.js → mainnet-1.1.15.js} +3 -3
- package/dist/module/config.d.ts +1 -0
- package/dist/module/config.d.ts.map +1 -1
- package/dist/module/config.js +1 -0
- package/dist/module/config.js.map +1 -1
- package/dist/module/wallet/Bcmr.js +1 -1
- package/dist/module/wallet/Bcmr.js.map +1 -1
- package/dist/module/wallet/Wif.d.ts.map +1 -1
- package/dist/module/wallet/Wif.js +3 -2
- package/dist/module/wallet/Wif.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Wallet.test.ts +19 -0
- package/src/config.ts +1 -0
- package/src/wallet/Bcmr.test.headless.js +18 -20
- package/src/wallet/Bcmr.test.ts +26 -28
- package/src/wallet/Bcmr.ts +1 -1
- package/src/wallet/Wif.ts +3 -2
package/src/wallet/Bcmr.test.ts
CHANGED
|
@@ -69,9 +69,7 @@ describe(`Test BCMR support`, () => {
|
|
|
69
69
|
const registryContent = JSON.stringify(registry, null, 2);
|
|
70
70
|
const registryContentHashBin = sha256.hash(utf8ToBin(registryContent));
|
|
71
71
|
const registryContentHash = binToHex(registryContentHashBin);
|
|
72
|
-
const registryContentHashBinBitcoinByteOrder = registryContentHashBin
|
|
73
|
-
.slice()
|
|
74
|
-
.reverse();
|
|
72
|
+
const registryContentHashBinBitcoinByteOrder = registryContentHashBin;
|
|
75
73
|
|
|
76
74
|
test("Add metadata registry and get token info", async () => {
|
|
77
75
|
expect(
|
|
@@ -248,8 +246,8 @@ describe(`Test BCMR support`, () => {
|
|
|
248
246
|
const contentHashBin = sha256.hash(utf8ToBin("registry_contents"));
|
|
249
247
|
const chunks = [
|
|
250
248
|
"BCMR",
|
|
251
|
-
contentHashBin
|
|
252
|
-
"
|
|
249
|
+
contentHashBin,
|
|
250
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
253
251
|
];
|
|
254
252
|
const opreturnData = OpReturnData.fromArray(chunks);
|
|
255
253
|
|
|
@@ -278,7 +276,7 @@ describe(`Test BCMR support`, () => {
|
|
|
278
276
|
const chunks = [
|
|
279
277
|
"BCMR",
|
|
280
278
|
sha256.hash(utf8ToBin("registry_contents")),
|
|
281
|
-
"
|
|
279
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
282
280
|
"something else",
|
|
283
281
|
];
|
|
284
282
|
const opreturnData = OpReturnData.fromArray(chunks);
|
|
@@ -324,7 +322,7 @@ describe(`Test BCMR support`, () => {
|
|
|
324
322
|
let chunks = [
|
|
325
323
|
"BCMR",
|
|
326
324
|
registryContentHashBinBitcoinByteOrder,
|
|
327
|
-
"
|
|
325
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
328
326
|
];
|
|
329
327
|
const opreturnData = OpReturnData.fromArray(chunks);
|
|
330
328
|
const response = await alice.send([
|
|
@@ -394,7 +392,7 @@ describe(`Test BCMR support`, () => {
|
|
|
394
392
|
let chunks = [
|
|
395
393
|
"BCMR",
|
|
396
394
|
registryContentHashBinBitcoinByteOrder,
|
|
397
|
-
"
|
|
395
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
398
396
|
];
|
|
399
397
|
const opreturnData = OpReturnData.fromArray(chunks);
|
|
400
398
|
const response = await alice.send([
|
|
@@ -404,7 +402,7 @@ describe(`Test BCMR support`, () => {
|
|
|
404
402
|
if (mineCombo[0]) await mine({ cashaddr: alice.cashaddr!, blocks: 1 });
|
|
405
403
|
|
|
406
404
|
chunks[2] =
|
|
407
|
-
"
|
|
405
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json";
|
|
408
406
|
const opreturnData2 = OpReturnData.fromArray(chunks);
|
|
409
407
|
const response2 = await bob.send([
|
|
410
408
|
new SendRequest({ cashaddr: bob.cashaddr!, value: 9500, unit: "sat" }),
|
|
@@ -413,7 +411,7 @@ describe(`Test BCMR support`, () => {
|
|
|
413
411
|
if (mineCombo[1]) await mine({ cashaddr: alice.cashaddr!, blocks: 1 });
|
|
414
412
|
|
|
415
413
|
chunks[2] =
|
|
416
|
-
"
|
|
414
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json";
|
|
417
415
|
const opreturnData3 = OpReturnData.fromArray(chunks);
|
|
418
416
|
const response3 = await bob.send([
|
|
419
417
|
new SendRequest({
|
|
@@ -487,9 +485,9 @@ describe(`Test BCMR support`, () => {
|
|
|
487
485
|
|
|
488
486
|
const registry_v1 = { ...registry };
|
|
489
487
|
registry_v1.extensions = { authchain: {} };
|
|
490
|
-
const contentHash_v1 = sha256
|
|
491
|
-
|
|
492
|
-
|
|
488
|
+
const contentHash_v1 = sha256.hash(
|
|
489
|
+
utf8ToBin(JSON.stringify(registry_v1, null, 2))
|
|
490
|
+
);
|
|
493
491
|
setupAxiosMock(
|
|
494
492
|
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v1.json",
|
|
495
493
|
JSON.stringify(registry_v1, null, 2)
|
|
@@ -497,7 +495,7 @@ describe(`Test BCMR support`, () => {
|
|
|
497
495
|
let chunks = [
|
|
498
496
|
"BCMR",
|
|
499
497
|
contentHash_v1,
|
|
500
|
-
"
|
|
498
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v1.json",
|
|
501
499
|
];
|
|
502
500
|
const opreturnData = OpReturnData.fromArray(chunks);
|
|
503
501
|
const response = await alice.send([
|
|
@@ -509,9 +507,9 @@ describe(`Test BCMR support`, () => {
|
|
|
509
507
|
registry_v2.extensions = {
|
|
510
508
|
authchain: { 0: await bob.provider!.getRawTransaction(response.txId) },
|
|
511
509
|
};
|
|
512
|
-
const contentHash_v2 = sha256
|
|
513
|
-
|
|
514
|
-
|
|
510
|
+
const contentHash_v2 = sha256.hash(
|
|
511
|
+
utf8ToBin(JSON.stringify(registry_v2, null, 2))
|
|
512
|
+
);
|
|
515
513
|
setupAxiosMock(
|
|
516
514
|
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json",
|
|
517
515
|
JSON.stringify(registry_v2, null, 2)
|
|
@@ -519,7 +517,7 @@ describe(`Test BCMR support`, () => {
|
|
|
519
517
|
chunks = [
|
|
520
518
|
"BCMR",
|
|
521
519
|
contentHash_v2,
|
|
522
|
-
"
|
|
520
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json",
|
|
523
521
|
];
|
|
524
522
|
const opreturnData2 = OpReturnData.fromArray(chunks);
|
|
525
523
|
const response2 = await bob.send([
|
|
@@ -534,9 +532,9 @@ describe(`Test BCMR support`, () => {
|
|
|
534
532
|
1: await bob.provider!.getRawTransaction(response2.txId),
|
|
535
533
|
},
|
|
536
534
|
};
|
|
537
|
-
const contentHash_v3 = sha256
|
|
538
|
-
|
|
539
|
-
|
|
535
|
+
const contentHash_v3 = sha256.hash(
|
|
536
|
+
utf8ToBin(JSON.stringify(registry_v3, null, 2))
|
|
537
|
+
);
|
|
540
538
|
setupAxiosMock(
|
|
541
539
|
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json",
|
|
542
540
|
JSON.stringify(registry_v3, null, 2)
|
|
@@ -544,7 +542,7 @@ describe(`Test BCMR support`, () => {
|
|
|
544
542
|
chunks = [
|
|
545
543
|
"BCMR",
|
|
546
544
|
contentHash_v3,
|
|
547
|
-
"
|
|
545
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json",
|
|
548
546
|
];
|
|
549
547
|
const opreturnData3 = OpReturnData.fromArray(chunks);
|
|
550
548
|
const response3 = await bob.send([
|
|
@@ -554,9 +552,9 @@ describe(`Test BCMR support`, () => {
|
|
|
554
552
|
|
|
555
553
|
const registry_v4 = { ...registry };
|
|
556
554
|
registry_v4.extensions = {};
|
|
557
|
-
const contentHash_v4 = sha256
|
|
558
|
-
|
|
559
|
-
|
|
555
|
+
const contentHash_v4 = sha256.hash(
|
|
556
|
+
utf8ToBin(JSON.stringify(registry_v4, null, 2))
|
|
557
|
+
);
|
|
560
558
|
setupAxiosMock(
|
|
561
559
|
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v4.json",
|
|
562
560
|
JSON.stringify(registry_v4, null, 2)
|
|
@@ -564,7 +562,7 @@ describe(`Test BCMR support`, () => {
|
|
|
564
562
|
chunks = [
|
|
565
563
|
"BCMR",
|
|
566
564
|
contentHash_v4,
|
|
567
|
-
"
|
|
565
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v4.json",
|
|
568
566
|
];
|
|
569
567
|
const opreturnData4 = OpReturnData.fromArray(chunks);
|
|
570
568
|
const response4 = await bob.send([
|
|
@@ -702,8 +700,8 @@ describe(`Test BCMR support`, () => {
|
|
|
702
700
|
const contentHashBin = sha256.hash(utf8ToBin("registry_contents"));
|
|
703
701
|
const chunks = [
|
|
704
702
|
"BCMR",
|
|
705
|
-
contentHashBin
|
|
706
|
-
"
|
|
703
|
+
contentHashBin,
|
|
704
|
+
"mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
707
705
|
];
|
|
708
706
|
const opreturnData = OpReturnData.fromArray(chunks);
|
|
709
707
|
|
package/src/wallet/Bcmr.ts
CHANGED
|
@@ -284,7 +284,7 @@ export class BCMR {
|
|
|
284
284
|
} else {
|
|
285
285
|
// HTTPS Publication Output
|
|
286
286
|
// content hash is in OP_SHA256 byte order per spec
|
|
287
|
-
result.contentHash = binToHex(chunks[1].slice()
|
|
287
|
+
result.contentHash = binToHex(chunks[1].slice());
|
|
288
288
|
result.uri = binToUtf8(chunks[2]);
|
|
289
289
|
if (result.uri.indexOf("https://") < 0) {
|
|
290
290
|
result.uri = `https://${result.uri}`;
|
package/src/wallet/Wif.ts
CHANGED
|
@@ -115,6 +115,7 @@ import { IdentitySnapshot, Registry } from "./bcmr-v2.schema.js";
|
|
|
115
115
|
import { BCMR } from "./Bcmr.js";
|
|
116
116
|
import { qrAddress } from "../qr/Qr.js";
|
|
117
117
|
import { ImageI } from "../qr/interface.js";
|
|
118
|
+
import { Config } from "../config.js";
|
|
118
119
|
|
|
119
120
|
//#endregion Imports
|
|
120
121
|
|
|
@@ -124,8 +125,8 @@ import { ImageI } from "../qr/interface.js";
|
|
|
124
125
|
export class Wallet extends BaseWallet {
|
|
125
126
|
cashaddr?: string;
|
|
126
127
|
tokenaddr?: string;
|
|
127
|
-
derivationPath: string = "
|
|
128
|
-
parentDerivationPath: string =
|
|
128
|
+
derivationPath: string = Config.DefaultParentDerivationPath + "/0/0";
|
|
129
|
+
parentDerivationPath: string = Config.DefaultParentDerivationPath;
|
|
129
130
|
parentXPubKey?: string;
|
|
130
131
|
privateKey?: Uint8Array;
|
|
131
132
|
publicKeyCompressed?: Uint8Array;
|