quantumcoin 6.14.1 → 6.14.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/README.md +2 -0
- package/dist/quantumcoin.js +2697 -7812
- package/dist/quantumcoin.js.map +1 -1
- package/dist/quantumcoin.min.js +1 -1
- package/dist/quantumcoin.min.js'.gz' +0 -0
- package/dist/quantumcoin.umd.js +2698 -7835
- package/dist/quantumcoin.umd.js.map +1 -1
- package/dist/quantumcoin.umd.min.js +1 -1
- package/dist/quantumcoin.umd.min.js'.gz' +0 -0
- package/dist/wordlists-extra.min.js'.gz' +0 -0
- package/lib.commonjs/address/address.d.ts +1 -21
- package/lib.commonjs/address/address.d.ts.map +1 -1
- package/lib.commonjs/address/address.js +2 -30
- package/lib.commonjs/address/address.js.map +1 -1
- package/lib.commonjs/address/index.d.ts +1 -1
- package/lib.commonjs/address/index.d.ts.map +1 -1
- package/lib.commonjs/address/index.js +1 -2
- package/lib.commonjs/address/index.js.map +1 -1
- package/lib.commonjs/crypto/signature.d.ts +4 -17
- package/lib.commonjs/crypto/signature.d.ts.map +1 -1
- package/lib.commonjs/crypto/signature.js +57 -60
- package/lib.commonjs/crypto/signature.js.map +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts +5 -64
- package/lib.commonjs/crypto/signing-key.d.ts.map +1 -1
- package/lib.commonjs/crypto/signing-key.js +27 -101
- package/lib.commonjs/crypto/signing-key.js.map +1 -1
- package/lib.commonjs/providers/default-provider.d.ts +0 -8
- package/lib.commonjs/providers/default-provider.d.ts.map +1 -1
- package/lib.commonjs/providers/default-provider.js +0 -108
- package/lib.commonjs/providers/default-provider.js.map +1 -1
- package/lib.commonjs/providers/index.d.ts +0 -9
- package/lib.commonjs/providers/index.d.ts.map +1 -1
- package/lib.commonjs/providers/index.js +1 -21
- package/lib.commonjs/providers/index.js.map +1 -1
- package/lib.commonjs/providers/network.js +1 -99
- package/lib.commonjs/providers/network.js.map +1 -1
- package/lib.commonjs/quantumcoin.d.ts +4 -4
- package/lib.commonjs/quantumcoin.d.ts.map +1 -1
- package/lib.commonjs/quantumcoin.js +4 -26
- package/lib.commonjs/quantumcoin.js.map +1 -1
- package/lib.commonjs/transaction/address.d.ts +1 -1
- package/lib.commonjs/transaction/address.d.ts.map +1 -1
- package/lib.commonjs/transaction/address.js +9 -5
- package/lib.commonjs/transaction/address.js.map +1 -1
- package/lib.commonjs/wallet/hdwallet.d.ts.map +1 -1
- package/lib.commonjs/wallet/hdwallet.js +4 -5
- package/lib.commonjs/wallet/hdwallet.js.map +1 -1
- package/lib.commonjs/wallet/index.d.ts +2 -6
- package/lib.commonjs/wallet/index.d.ts.map +1 -1
- package/lib.commonjs/wallet/index.js +1 -14
- package/lib.commonjs/wallet/index.js.map +1 -1
- package/lib.commonjs/wallet/json-keystore.d.ts +3 -52
- package/lib.commonjs/wallet/json-keystore.d.ts.map +1 -1
- package/lib.commonjs/wallet/json-keystore.js +41 -246
- package/lib.commonjs/wallet/json-keystore.js.map +1 -1
- package/lib.commonjs/wallet/seedwallet.d.ts +4 -0
- package/lib.commonjs/wallet/seedwallet.d.ts.map +1 -0
- package/lib.commonjs/wallet/seedwallet.js +8 -0
- package/lib.commonjs/wallet/seedwallet.js.map +1 -0
- package/lib.commonjs/wallet/wallet.d.ts +5 -14
- package/lib.commonjs/wallet/wallet.d.ts.map +1 -1
- package/lib.commonjs/wallet/wallet.js +12 -51
- package/lib.commonjs/wallet/wallet.js.map +1 -1
- package/lib.esm/address/address.d.ts +1 -21
- package/lib.esm/address/address.d.ts.map +1 -1
- package/lib.esm/address/address.js +1 -28
- package/lib.esm/address/address.js.map +1 -1
- package/lib.esm/address/index.d.ts +1 -1
- package/lib.esm/address/index.d.ts.map +1 -1
- package/lib.esm/address/index.js +1 -1
- package/lib.esm/address/index.js.map +1 -1
- package/lib.esm/crypto/signature.d.ts +4 -17
- package/lib.esm/crypto/signature.d.ts.map +1 -1
- package/lib.esm/crypto/signature.js +45 -46
- package/lib.esm/crypto/signature.js.map +1 -1
- package/lib.esm/crypto/signing-key.d.ts +5 -64
- package/lib.esm/crypto/signing-key.d.ts.map +1 -1
- package/lib.esm/crypto/signing-key.js +26 -102
- package/lib.esm/crypto/signing-key.js.map +1 -1
- package/lib.esm/providers/default-provider.d.ts +0 -8
- package/lib.esm/providers/default-provider.d.ts.map +1 -1
- package/lib.esm/providers/default-provider.js +0 -108
- package/lib.esm/providers/default-provider.js.map +1 -1
- package/lib.esm/providers/index.d.ts +0 -9
- package/lib.esm/providers/index.d.ts.map +1 -1
- package/lib.esm/providers/index.js +0 -9
- package/lib.esm/providers/index.js.map +1 -1
- package/lib.esm/providers/network.js +3 -101
- package/lib.esm/providers/network.js.map +1 -1
- package/lib.esm/quantumcoin.d.ts +4 -4
- package/lib.esm/quantumcoin.d.ts.map +1 -1
- package/lib.esm/quantumcoin.js +3 -3
- package/lib.esm/quantumcoin.js.map +1 -1
- package/lib.esm/transaction/address.d.ts +1 -1
- package/lib.esm/transaction/address.d.ts.map +1 -1
- package/lib.esm/transaction/address.js +7 -4
- package/lib.esm/transaction/address.js.map +1 -1
- package/lib.esm/wallet/hdwallet.d.ts.map +1 -1
- package/lib.esm/wallet/hdwallet.js +4 -5
- package/lib.esm/wallet/hdwallet.js.map +1 -1
- package/lib.esm/wallet/index.d.ts +2 -6
- package/lib.esm/wallet/index.d.ts.map +1 -1
- package/lib.esm/wallet/index.js +1 -4
- package/lib.esm/wallet/index.js.map +1 -1
- package/lib.esm/wallet/json-keystore.d.ts +3 -52
- package/lib.esm/wallet/json-keystore.d.ts.map +1 -1
- package/lib.esm/wallet/json-keystore.js +32 -241
- package/lib.esm/wallet/json-keystore.js.map +1 -1
- package/lib.esm/wallet/seedwallet.d.ts +4 -0
- package/lib.esm/wallet/seedwallet.d.ts.map +1 -0
- package/lib.esm/wallet/seedwallet.js +4 -0
- package/lib.esm/wallet/seedwallet.js.map +1 -0
- package/lib.esm/wallet/wallet.d.ts +5 -14
- package/lib.esm/wallet/wallet.d.ts.map +1 -1
- package/lib.esm/wallet/wallet.js +12 -53
- package/lib.esm/wallet/wallet.js.map +1 -1
- package/package.json +5 -2
- package/src.ts/address/address.ts +2 -27
- package/src.ts/address/index.ts +1 -1
- package/src.ts/crypto/signature.ts +31 -45
- package/src.ts/crypto/signing-key.ts +31 -109
- package/src.ts/providers/default-provider.ts +0 -106
- package/src.ts/providers/index.ts +0 -10
- package/src.ts/providers/network.ts +3 -111
- package/src.ts/quantumcoin.ts +7 -17
- package/src.ts/transaction/address.ts +8 -5
- package/src.ts/wallet/index.ts +2 -17
- package/src.ts/wallet/json-keystore.ts +42 -325
- package/src.ts/wallet/wallet.ts +23 -47
- package/src.ts/providers/provider-alchemy.ts +0 -166
- package/src.ts/providers/provider-ankr.ts +0 -153
- package/src.ts/providers/provider-blockscout.ts +0 -167
- package/src.ts/providers/provider-chainstack.ts +0 -113
- package/src.ts/providers/provider-cloudflare.ts +0 -24
- package/src.ts/providers/provider-etherscan.ts +0 -671
- package/src.ts/providers/provider-infura.ts +0 -220
- package/src.ts/providers/provider-pocket.ts +0 -121
- package/src.ts/providers/provider-quicknode.ts +0 -177
- package/src.ts/wallet/hdwallet.ts +0 -586
- package/src.ts/wallet/json-crowdsale.ts +0 -74
- package/src.ts/wallet/mnemonic.ts +0 -203
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { pbkdf2, sha256 } from "../crypto/index.js";
|
|
2
|
-
import {
|
|
3
|
-
defineProperties, getBytes, hexlify, assertNormalize, assertPrivate, assertArgument, toUtf8Bytes
|
|
4
|
-
} from "../utils/index.js";
|
|
5
|
-
import { LangEn } from "../wordlists/lang-en.js";
|
|
6
|
-
|
|
7
|
-
import type { BytesLike } from "../utils/index.js";
|
|
8
|
-
import type { Wordlist } from "../wordlists/index.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// Returns a byte with the MSB bits set
|
|
12
|
-
function getUpperMask(bits: number): number {
|
|
13
|
-
return ((1 << bits) - 1) << (8 - bits) & 0xff;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Returns a byte with the LSB bits set
|
|
17
|
-
function getLowerMask(bits: number): number {
|
|
18
|
-
return ((1 << bits) - 1) & 0xff;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function mnemonicToEntropy(mnemonic: string, wordlist?: null | Wordlist): string {
|
|
23
|
-
assertNormalize("NFKD");
|
|
24
|
-
|
|
25
|
-
if (wordlist == null) { wordlist = LangEn.wordlist(); }
|
|
26
|
-
|
|
27
|
-
const words = wordlist.split(mnemonic);
|
|
28
|
-
assertArgument((words.length % 3) === 0 && words.length >= 12 && words.length <= 24,
|
|
29
|
-
"invalid mnemonic length", "mnemonic", "[ REDACTED ]");
|
|
30
|
-
|
|
31
|
-
const entropy = new Uint8Array(Math.ceil(11 * words.length / 8));
|
|
32
|
-
|
|
33
|
-
let offset = 0;
|
|
34
|
-
for (let i = 0; i < words.length; i++) {
|
|
35
|
-
let index = wordlist.getWordIndex(words[i].normalize("NFKD"));
|
|
36
|
-
assertArgument(index >= 0, `invalid mnemonic word at index ${ i }`, "mnemonic", "[ REDACTED ]");
|
|
37
|
-
|
|
38
|
-
for (let bit = 0; bit < 11; bit++) {
|
|
39
|
-
if (index & (1 << (10 - bit))) {
|
|
40
|
-
entropy[offset >> 3] |= (1 << (7 - (offset % 8)));
|
|
41
|
-
}
|
|
42
|
-
offset++;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const entropyBits = 32 * words.length / 3;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const checksumBits = words.length / 3;
|
|
50
|
-
const checksumMask = getUpperMask(checksumBits);
|
|
51
|
-
|
|
52
|
-
const checksum = getBytes(sha256(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
|
53
|
-
|
|
54
|
-
assertArgument(checksum === (entropy[entropy.length - 1] & checksumMask),
|
|
55
|
-
"invalid mnemonic checksum", "mnemonic", "[ REDACTED ]");
|
|
56
|
-
|
|
57
|
-
return hexlify(entropy.slice(0, entropyBits / 8));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function entropyToMnemonic(entropy: Uint8Array, wordlist?: null | Wordlist): string {
|
|
61
|
-
|
|
62
|
-
assertArgument((entropy.length % 4) === 0 && entropy.length >= 16 && entropy.length <= 32,
|
|
63
|
-
"invalid entropy size", "entropy", "[ REDACTED ]");
|
|
64
|
-
|
|
65
|
-
if (wordlist == null) { wordlist = LangEn.wordlist(); }
|
|
66
|
-
|
|
67
|
-
const indices: Array<number> = [ 0 ];
|
|
68
|
-
|
|
69
|
-
let remainingBits = 11;
|
|
70
|
-
for (let i = 0; i < entropy.length; i++) {
|
|
71
|
-
|
|
72
|
-
// Consume the whole byte (with still more to go)
|
|
73
|
-
if (remainingBits > 8) {
|
|
74
|
-
indices[indices.length - 1] <<= 8;
|
|
75
|
-
indices[indices.length - 1] |= entropy[i];
|
|
76
|
-
|
|
77
|
-
remainingBits -= 8;
|
|
78
|
-
|
|
79
|
-
// This byte will complete an 11-bit index
|
|
80
|
-
} else {
|
|
81
|
-
indices[indices.length - 1] <<= remainingBits;
|
|
82
|
-
indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits);
|
|
83
|
-
|
|
84
|
-
// Start the next word
|
|
85
|
-
indices.push(entropy[i] & getLowerMask(8 - remainingBits));
|
|
86
|
-
|
|
87
|
-
remainingBits += 3;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Compute the checksum bits
|
|
92
|
-
const checksumBits = entropy.length / 4;
|
|
93
|
-
const checksum = parseInt(sha256(entropy).substring(2, 4), 16) & getUpperMask(checksumBits);
|
|
94
|
-
|
|
95
|
-
// Shift the checksum into the word indices
|
|
96
|
-
indices[indices.length - 1] <<= checksumBits;
|
|
97
|
-
indices[indices.length - 1] |= (checksum >> (8 - checksumBits));
|
|
98
|
-
|
|
99
|
-
return wordlist.join(indices.map((index) => (<Wordlist>wordlist).getWord(index)));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const _guard = { };
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* A **Mnemonic** wraps all properties required to compute [[link-bip-39]]
|
|
106
|
-
* seeds and convert between phrases and entropy.
|
|
107
|
-
*/
|
|
108
|
-
export class Mnemonic {
|
|
109
|
-
/**
|
|
110
|
-
* The mnemonic phrase of 12, 15, 18, 21 or 24 words.
|
|
111
|
-
*
|
|
112
|
-
* Use the [[wordlist]] ``split`` method to get the individual words.
|
|
113
|
-
*/
|
|
114
|
-
readonly phrase!: string;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* The password used for this mnemonic. If no password is used this
|
|
118
|
-
* is the empty string (i.e. ``""``) as per the specification.
|
|
119
|
-
*/
|
|
120
|
-
readonly password!: string;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* The wordlist for this mnemonic.
|
|
124
|
-
*/
|
|
125
|
-
readonly wordlist!: Wordlist;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* The underlying entropy which the mnemonic encodes.
|
|
129
|
-
*/
|
|
130
|
-
readonly entropy!: string;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @private
|
|
134
|
-
*/
|
|
135
|
-
constructor(guard: any, entropy: string, phrase: string, password?: null | string, wordlist?: null | Wordlist) {
|
|
136
|
-
if (password == null) { password = ""; }
|
|
137
|
-
if (wordlist == null) { wordlist = LangEn.wordlist(); }
|
|
138
|
-
assertPrivate(guard, _guard, "Mnemonic");
|
|
139
|
-
defineProperties<Mnemonic>(this, { phrase, password, wordlist, entropy });
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Returns the seed for the mnemonic.
|
|
144
|
-
*/
|
|
145
|
-
computeSeed(): string {
|
|
146
|
-
const salt = toUtf8Bytes("mnemonic" + this.password, "NFKD");
|
|
147
|
-
return pbkdf2(toUtf8Bytes(this.phrase, "NFKD"), salt, 2048, 64, "sha512");
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Creates a new Mnemonic for the %%phrase%%.
|
|
152
|
-
*
|
|
153
|
-
* The default %%password%% is the empty string and the default
|
|
154
|
-
* wordlist is the [English wordlists](LangEn).
|
|
155
|
-
*/
|
|
156
|
-
static fromPhrase(phrase: string, password?: null | string, wordlist?: null | Wordlist): Mnemonic {
|
|
157
|
-
// Normalize the case and space; throws if invalid
|
|
158
|
-
const entropy = mnemonicToEntropy(phrase, wordlist);
|
|
159
|
-
phrase = entropyToMnemonic(getBytes(entropy), wordlist);
|
|
160
|
-
return new Mnemonic(_guard, entropy, phrase, password, wordlist);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Create a new **Mnemonic** from the %%entropy%%.
|
|
165
|
-
*
|
|
166
|
-
* The default %%password%% is the empty string and the default
|
|
167
|
-
* wordlist is the [English wordlists](LangEn).
|
|
168
|
-
*/
|
|
169
|
-
static fromEntropy(_entropy: BytesLike, password?: null | string, wordlist?: null | Wordlist): Mnemonic {
|
|
170
|
-
const entropy = getBytes(_entropy, "entropy");
|
|
171
|
-
const phrase = entropyToMnemonic(entropy, wordlist);
|
|
172
|
-
return new Mnemonic(_guard, hexlify(entropy), phrase, password, wordlist);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Returns the phrase for %%mnemonic%%.
|
|
177
|
-
*/
|
|
178
|
-
static entropyToPhrase(_entropy: BytesLike, wordlist?: null | Wordlist): string {
|
|
179
|
-
const entropy = getBytes(_entropy, "entropy");
|
|
180
|
-
return entropyToMnemonic(entropy, wordlist);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Returns the entropy for %%phrase%%.
|
|
185
|
-
*/
|
|
186
|
-
static phraseToEntropy(phrase: string, wordlist?: null | Wordlist): string {
|
|
187
|
-
return mnemonicToEntropy(phrase, wordlist);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Returns true if %%phrase%% is a valid [[link-bip-39]] phrase.
|
|
192
|
-
*
|
|
193
|
-
* This checks all the provided words belong to the %%wordlist%%,
|
|
194
|
-
* that the length is valid and the checksum is correct.
|
|
195
|
-
*/
|
|
196
|
-
static isValidMnemonic(phrase: string, wordlist?: null | Wordlist): boolean {
|
|
197
|
-
try {
|
|
198
|
-
mnemonicToEntropy(phrase, wordlist);
|
|
199
|
-
return true;
|
|
200
|
-
} catch (error) { }
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
}
|