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
|
@@ -10,15 +10,21 @@
|
|
|
10
10
|
* @_subsection: api/wallet:JSON Wallets [json-wallets]
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
13
|
+
exports.encryptKeystoreJsonSync = exports.decryptKeystoreJsonSync = exports.isKeystoreJson = void 0;
|
|
14
|
+
//import { CTR } from "aes-js";
|
|
15
|
+
//import { getAddress } from "../address/index.js";
|
|
16
|
+
//randomBytes, scrypt, scryptSync, uuidV4
|
|
17
|
+
//import { keccak256 } from "../crypto/index.js";
|
|
18
|
+
//import { computeAddress } from "../transaction/index.js";
|
|
19
|
+
//concat, assert, assertArgument,
|
|
20
|
+
const index_js_1 = require("../utils/index.js");
|
|
21
|
+
const signing_key_1 = require("../crypto/signing-key");
|
|
22
|
+
//zpad
|
|
23
|
+
//import { spelunk } from "./utils.js";
|
|
24
|
+
//import type { ProgressCallback } from "../crypto/index.js";
|
|
25
|
+
//import {Wallet} from "quantum-coin-js-sdk";
|
|
26
|
+
//import type { BytesLike } from "../utils/index.js";
|
|
27
|
+
const qcsdk = require("quantum-coin-js-sdk");
|
|
22
28
|
/**
|
|
23
29
|
* Returns true if %%json%% is a valid JSON Keystore Wallet.
|
|
24
30
|
*/
|
|
@@ -34,105 +40,6 @@ function isKeystoreJson(json) {
|
|
|
34
40
|
return false;
|
|
35
41
|
}
|
|
36
42
|
exports.isKeystoreJson = isKeystoreJson;
|
|
37
|
-
function decrypt(data, key, ciphertext) {
|
|
38
|
-
const cipher = (0, utils_js_1.spelunk)(data, "crypto.cipher:string");
|
|
39
|
-
if (cipher === "aes-128-ctr") {
|
|
40
|
-
const iv = (0, utils_js_1.spelunk)(data, "crypto.cipherparams.iv:data!");
|
|
41
|
-
const aesCtr = new aes_js_1.CTR(key, iv);
|
|
42
|
-
return (0, index_js_4.hexlify)(aesCtr.decrypt(ciphertext));
|
|
43
|
-
}
|
|
44
|
-
(0, index_js_4.assert)(false, "unsupported cipher", "UNSUPPORTED_OPERATION", {
|
|
45
|
-
operation: "decrypt"
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function getAccount(data, _key) {
|
|
49
|
-
const key = (0, index_js_4.getBytes)(_key);
|
|
50
|
-
const ciphertext = (0, utils_js_1.spelunk)(data, "crypto.ciphertext:data!");
|
|
51
|
-
const computedMAC = (0, index_js_4.hexlify)((0, index_js_2.keccak256)((0, index_js_4.concat)([key.slice(16, 32), ciphertext]))).substring(2);
|
|
52
|
-
(0, index_js_4.assertArgument)(computedMAC === (0, utils_js_1.spelunk)(data, "crypto.mac:string!").toLowerCase(), "incorrect password", "password", "[ REDACTED ]");
|
|
53
|
-
const privateKey = decrypt(data, key.slice(0, 16), ciphertext);
|
|
54
|
-
const address = (0, index_js_3.computeAddress)(privateKey);
|
|
55
|
-
if (data.address) {
|
|
56
|
-
let check = data.address.toLowerCase();
|
|
57
|
-
if (!check.startsWith("0x")) {
|
|
58
|
-
check = "0x" + check;
|
|
59
|
-
}
|
|
60
|
-
(0, index_js_4.assertArgument)((0, index_js_1.getAddress)(check) === address, "keystore address/privateKey mismatch", "address", data.address);
|
|
61
|
-
}
|
|
62
|
-
const account = { address, privateKey };
|
|
63
|
-
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
|
64
|
-
const version = (0, utils_js_1.spelunk)(data, "x-ethers.version:string");
|
|
65
|
-
if (version === "0.1") {
|
|
66
|
-
const mnemonicKey = key.slice(32, 64);
|
|
67
|
-
const mnemonicCiphertext = (0, utils_js_1.spelunk)(data, "x-ethers.mnemonicCiphertext:data!");
|
|
68
|
-
const mnemonicIv = (0, utils_js_1.spelunk)(data, "x-ethers.mnemonicCounter:data!");
|
|
69
|
-
const mnemonicAesCtr = new aes_js_1.CTR(mnemonicKey, mnemonicIv);
|
|
70
|
-
account.mnemonic = {
|
|
71
|
-
path: ((0, utils_js_1.spelunk)(data, "x-ethers.path:string") || defaultPath),
|
|
72
|
-
locale: ((0, utils_js_1.spelunk)(data, "x-ethers.locale:string") || "en"),
|
|
73
|
-
entropy: (0, index_js_4.hexlify)((0, index_js_4.getBytes)(mnemonicAesCtr.decrypt(mnemonicCiphertext)))
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return account;
|
|
77
|
-
}
|
|
78
|
-
function getDecryptKdfParams(data) {
|
|
79
|
-
const kdf = (0, utils_js_1.spelunk)(data, "crypto.kdf:string");
|
|
80
|
-
if (kdf && typeof (kdf) === "string") {
|
|
81
|
-
if (kdf.toLowerCase() === "scrypt") {
|
|
82
|
-
const salt = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.salt:data!");
|
|
83
|
-
const N = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.n:int!");
|
|
84
|
-
const r = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.r:int!");
|
|
85
|
-
const p = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.p:int!");
|
|
86
|
-
// Make sure N is a power of 2
|
|
87
|
-
(0, index_js_4.assertArgument)(N > 0 && (N & (N - 1)) === 0, "invalid kdf.N", "kdf.N", N);
|
|
88
|
-
(0, index_js_4.assertArgument)(r > 0 && p > 0, "invalid kdf", "kdf", kdf);
|
|
89
|
-
const dkLen = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.dklen:int!");
|
|
90
|
-
(0, index_js_4.assertArgument)(dkLen === 32, "invalid kdf.dklen", "kdf.dflen", dkLen);
|
|
91
|
-
return { name: "scrypt", salt, N, r, p, dkLen: 64 };
|
|
92
|
-
}
|
|
93
|
-
else if (kdf.toLowerCase() === "pbkdf2") {
|
|
94
|
-
const salt = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.salt:data!");
|
|
95
|
-
const prf = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.prf:string!");
|
|
96
|
-
const algorithm = prf.split("-").pop();
|
|
97
|
-
(0, index_js_4.assertArgument)(algorithm === "sha256" || algorithm === "sha512", "invalid kdf.pdf", "kdf.pdf", prf);
|
|
98
|
-
const count = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.c:int!");
|
|
99
|
-
const dkLen = (0, utils_js_1.spelunk)(data, "crypto.kdfparams.dklen:int!");
|
|
100
|
-
(0, index_js_4.assertArgument)(dkLen === 32, "invalid kdf.dklen", "kdf.dklen", dkLen);
|
|
101
|
-
return { name: "pbkdf2", salt, count, dkLen, algorithm };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
(0, index_js_4.assertArgument)(false, "unsupported key-derivation function", "kdf", kdf);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Returns the account details for the JSON Keystore Wallet %%json%%
|
|
108
|
-
* using %%password%%.
|
|
109
|
-
*
|
|
110
|
-
* It is preferred to use the [async version](decryptKeystoreJson)
|
|
111
|
-
* instead, which allows a [[ProgressCallback]] to keep the user informed
|
|
112
|
-
* as to the decryption status.
|
|
113
|
-
*
|
|
114
|
-
* This method will block the event loop (freezing all UI) until decryption
|
|
115
|
-
* is complete, which can take quite some time, depending on the wallet
|
|
116
|
-
* paramters and platform.
|
|
117
|
-
*/
|
|
118
|
-
function decryptKeystoreJsonSync(json, _password) {
|
|
119
|
-
const data = JSON.parse(json);
|
|
120
|
-
const password = (0, utils_js_1.getPassword)(_password);
|
|
121
|
-
const params = getDecryptKdfParams(data);
|
|
122
|
-
if (params.name === "pbkdf2") {
|
|
123
|
-
const { salt, count, dkLen, algorithm } = params;
|
|
124
|
-
const key = (0, index_js_2.pbkdf2)(password, salt, count, dkLen, algorithm);
|
|
125
|
-
return getAccount(data, key);
|
|
126
|
-
}
|
|
127
|
-
(0, index_js_4.assert)(params.name === "scrypt", "cannot be reached", "UNKNOWN_ERROR", { params });
|
|
128
|
-
const { salt, N, r, p, dkLen } = params;
|
|
129
|
-
const key = (0, index_js_2.scryptSync)(password, salt, N, r, p, dkLen);
|
|
130
|
-
return getAccount(data, key);
|
|
131
|
-
}
|
|
132
|
-
exports.decryptKeystoreJsonSync = decryptKeystoreJsonSync;
|
|
133
|
-
function stall(duration) {
|
|
134
|
-
return new Promise((resolve) => { setTimeout(() => { resolve(); }, duration); });
|
|
135
|
-
}
|
|
136
43
|
/**
|
|
137
44
|
* Resolves to the decrypted JSON Keystore Wallet %%json%% using the
|
|
138
45
|
* %%password%%.
|
|
@@ -140,156 +47,44 @@ function stall(duration) {
|
|
|
140
47
|
* If provided, %%progress%% will be called periodically during the
|
|
141
48
|
* decrpytion to provide feedback, and if the function returns
|
|
142
49
|
* ``false`` will halt decryption.
|
|
143
|
-
*
|
|
144
|
-
* The %%progressCallback%% will **always** receive ``0`` before
|
|
145
|
-
* decryption begins and ``1`` when complete.
|
|
146
50
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (params.name === "pbkdf2") {
|
|
152
|
-
if (progress) {
|
|
153
|
-
progress(0);
|
|
154
|
-
await stall(0);
|
|
155
|
-
}
|
|
156
|
-
const { salt, count, dkLen, algorithm } = params;
|
|
157
|
-
const key = (0, index_js_2.pbkdf2)(password, salt, count, dkLen, algorithm);
|
|
158
|
-
if (progress) {
|
|
159
|
-
progress(1);
|
|
160
|
-
await stall(0);
|
|
161
|
-
}
|
|
162
|
-
return getAccount(data, key);
|
|
51
|
+
function decryptKeystoreJsonSync(json, _password) {
|
|
52
|
+
let pass;
|
|
53
|
+
if (typeof _password === 'string') {
|
|
54
|
+
pass = _password;
|
|
163
55
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const key = await (0, index_js_2.scrypt)(password, salt, N, r, p, dkLen, progress);
|
|
167
|
-
return getAccount(data, key);
|
|
168
|
-
}
|
|
169
|
-
exports.decryptKeystoreJson = decryptKeystoreJson;
|
|
170
|
-
function getEncryptKdfParams(options) {
|
|
171
|
-
// Check/generate the salt
|
|
172
|
-
const salt = (options.salt != null) ? (0, index_js_4.getBytes)(options.salt, "options.salt") : (0, index_js_2.randomBytes)(32);
|
|
173
|
-
// Override the scrypt password-based key derivation function parameters
|
|
174
|
-
let N = (1 << 17), r = 8, p = 1;
|
|
175
|
-
if (options.scrypt) {
|
|
176
|
-
if (options.scrypt.N) {
|
|
177
|
-
N = options.scrypt.N;
|
|
178
|
-
}
|
|
179
|
-
if (options.scrypt.r) {
|
|
180
|
-
r = options.scrypt.r;
|
|
181
|
-
}
|
|
182
|
-
if (options.scrypt.p) {
|
|
183
|
-
p = options.scrypt.p;
|
|
184
|
-
}
|
|
56
|
+
else {
|
|
57
|
+
pass = (0, index_js_1.toUtf8String)(_password);
|
|
185
58
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
function _encryptKeystore(key, kdf, account, options) {
|
|
192
|
-
const privateKey = (0, index_js_4.getBytes)(account.privateKey, "privateKey");
|
|
193
|
-
// Override initialization vector
|
|
194
|
-
const iv = (options.iv != null) ? (0, index_js_4.getBytes)(options.iv, "options.iv") : (0, index_js_2.randomBytes)(16);
|
|
195
|
-
(0, index_js_4.assertArgument)(iv.length === 16, "invalid options.iv length", "options.iv", options.iv);
|
|
196
|
-
// Override the uuid
|
|
197
|
-
const uuidRandom = (options.uuid != null) ? (0, index_js_4.getBytes)(options.uuid, "options.uuid") : (0, index_js_2.randomBytes)(16);
|
|
198
|
-
(0, index_js_4.assertArgument)(uuidRandom.length === 16, "invalid options.uuid length", "options.uuid", options.iv);
|
|
199
|
-
// This will be used to encrypt the wallet (as per Web3 secret storage)
|
|
200
|
-
// - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix)
|
|
201
|
-
// - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet)
|
|
202
|
-
const derivedKey = key.slice(0, 16);
|
|
203
|
-
const macPrefix = key.slice(16, 32);
|
|
204
|
-
// Encrypt the private key
|
|
205
|
-
const aesCtr = new aes_js_1.CTR(derivedKey, iv);
|
|
206
|
-
const ciphertext = (0, index_js_4.getBytes)(aesCtr.encrypt(privateKey));
|
|
207
|
-
// Compute the message authentication code, used to check the password
|
|
208
|
-
const mac = (0, index_js_2.keccak256)((0, index_js_4.concat)([macPrefix, ciphertext]));
|
|
209
|
-
// See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
|
|
210
|
-
const data = {
|
|
211
|
-
address: account.address.substring(2).toLowerCase(),
|
|
212
|
-
id: (0, index_js_4.uuidV4)(uuidRandom),
|
|
213
|
-
version: 3,
|
|
214
|
-
Crypto: {
|
|
215
|
-
cipher: "aes-128-ctr",
|
|
216
|
-
cipherparams: {
|
|
217
|
-
iv: (0, index_js_4.hexlify)(iv).substring(2),
|
|
218
|
-
},
|
|
219
|
-
ciphertext: (0, index_js_4.hexlify)(ciphertext).substring(2),
|
|
220
|
-
kdf: "scrypt",
|
|
221
|
-
kdfparams: {
|
|
222
|
-
salt: (0, index_js_4.hexlify)(kdf.salt).substring(2),
|
|
223
|
-
n: kdf.N,
|
|
224
|
-
dklen: 32,
|
|
225
|
-
p: kdf.p,
|
|
226
|
-
r: kdf.r
|
|
227
|
-
},
|
|
228
|
-
mac: mac.substring(2)
|
|
229
|
-
}
|
|
59
|
+
let wal = qcsdk.deserializeEncryptedWallet(json, pass);
|
|
60
|
+
let privKey = wal.privateKey;
|
|
61
|
+
let ks = {
|
|
62
|
+
address: wal.address,
|
|
63
|
+
privateKey: (0, index_js_1.hexlify)(privKey)
|
|
230
64
|
};
|
|
231
|
-
|
|
232
|
-
if (account.mnemonic) {
|
|
233
|
-
const client = (options.client != null) ? options.client : `ethers/${_version_js_1.version}`;
|
|
234
|
-
const path = account.mnemonic.path || defaultPath;
|
|
235
|
-
const locale = account.mnemonic.locale || "en";
|
|
236
|
-
const mnemonicKey = key.slice(32, 64);
|
|
237
|
-
const entropy = (0, index_js_4.getBytes)(account.mnemonic.entropy, "account.mnemonic.entropy");
|
|
238
|
-
const mnemonicIv = (0, index_js_2.randomBytes)(16);
|
|
239
|
-
const mnemonicAesCtr = new aes_js_1.CTR(mnemonicKey, mnemonicIv);
|
|
240
|
-
const mnemonicCiphertext = (0, index_js_4.getBytes)(mnemonicAesCtr.encrypt(entropy));
|
|
241
|
-
const now = new Date();
|
|
242
|
-
const timestamp = (now.getUTCFullYear() + "-" +
|
|
243
|
-
(0, utils_js_1.zpad)(now.getUTCMonth() + 1, 2) + "-" +
|
|
244
|
-
(0, utils_js_1.zpad)(now.getUTCDate(), 2) + "T" +
|
|
245
|
-
(0, utils_js_1.zpad)(now.getUTCHours(), 2) + "-" +
|
|
246
|
-
(0, utils_js_1.zpad)(now.getUTCMinutes(), 2) + "-" +
|
|
247
|
-
(0, utils_js_1.zpad)(now.getUTCSeconds(), 2) + ".0Z");
|
|
248
|
-
const gethFilename = ("UTC--" + timestamp + "--" + data.address);
|
|
249
|
-
data["x-ethers"] = {
|
|
250
|
-
client, gethFilename, path, locale,
|
|
251
|
-
mnemonicCounter: (0, index_js_4.hexlify)(mnemonicIv).substring(2),
|
|
252
|
-
mnemonicCiphertext: (0, index_js_4.hexlify)(mnemonicCiphertext).substring(2),
|
|
253
|
-
version: "0.1"
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
return JSON.stringify(data);
|
|
65
|
+
return ks;
|
|
257
66
|
}
|
|
258
|
-
|
|
259
|
-
* Return the JSON Keystore Wallet for %%account%% encrypted with
|
|
260
|
-
* %%password%%.
|
|
261
|
-
*
|
|
262
|
-
* The %%options%% can be used to tune the password-based key
|
|
263
|
-
* derivation function parameters, explicitly set the random values
|
|
264
|
-
* used. Any provided [[ProgressCallback]] is ignord.
|
|
265
|
-
*/
|
|
266
|
-
function encryptKeystoreJsonSync(account, password, options) {
|
|
267
|
-
if (options == null) {
|
|
268
|
-
options = {};
|
|
269
|
-
}
|
|
270
|
-
const passwordBytes = (0, utils_js_1.getPassword)(password);
|
|
271
|
-
const kdf = getEncryptKdfParams(options);
|
|
272
|
-
const key = (0, index_js_2.scryptSync)(passwordBytes, kdf.salt, kdf.N, kdf.r, kdf.p, 64);
|
|
273
|
-
return _encryptKeystore((0, index_js_4.getBytes)(key), kdf, account, options);
|
|
274
|
-
}
|
|
275
|
-
exports.encryptKeystoreJsonSync = encryptKeystoreJsonSync;
|
|
67
|
+
exports.decryptKeystoreJsonSync = decryptKeystoreJsonSync;
|
|
276
68
|
/**
|
|
277
69
|
* Resolved to the JSON Keystore Wallet for %%account%% encrypted
|
|
278
70
|
* with %%password%%.
|
|
279
71
|
*
|
|
280
72
|
* The %%options%% can be used to tune the password-based key
|
|
281
73
|
* derivation function parameters, explicitly set the random values
|
|
282
|
-
* used
|
|
283
|
-
* on the completion status..
|
|
74
|
+
* used.
|
|
284
75
|
*/
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
76
|
+
function encryptKeystoreJsonSync(account, password) {
|
|
77
|
+
const signingKey = new signing_key_1.SigningKey(account.privateKey);
|
|
78
|
+
const privateKey = (0, index_js_1.getBytes)(signingKey.privateKey);
|
|
79
|
+
const publicKey = (0, index_js_1.getBytes)(signingKey.publicKey);
|
|
80
|
+
const wal = new qcsdk.Wallet(account.address, privateKey, publicKey);
|
|
81
|
+
if (typeof password === 'string') {
|
|
82
|
+
return qcsdk.serializeEncryptedWallet(wal, password);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
let passPhrase = (0, index_js_1.toUtf8String)(password);
|
|
86
|
+
return qcsdk.serializeEncryptedWallet(wal, passPhrase);
|
|
288
87
|
}
|
|
289
|
-
const passwordBytes = (0, utils_js_1.getPassword)(password);
|
|
290
|
-
const kdf = getEncryptKdfParams(options);
|
|
291
|
-
const key = await (0, index_js_2.scrypt)(passwordBytes, kdf.salt, kdf.N, kdf.r, kdf.p, 64, options.progressCallback);
|
|
292
|
-
return _encryptKeystore((0, index_js_4.getBytes)(key), kdf, account, options);
|
|
293
88
|
}
|
|
294
|
-
exports.
|
|
89
|
+
exports.encryptKeystoreJsonSync = encryptKeystoreJsonSync;
|
|
295
90
|
//# sourceMappingURL=json-keystore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-keystore.js","sourceRoot":"","sources":["../../src.ts/wallet/json-keystore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,mCAA6B;AAE7B,kDAAiD;AACjD,iDAAwF;AACxF,sDAAyD;AACzD,gDAE2B;AAE3B,yCAAwD;AAKxD,gDAAyC;AAGzC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAgCvC;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAY;IACvC,IAAI;QACA,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC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
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HDNodeWallet = void 0;
|
|
4
|
+
const base_wallet_js_1 = require("./base-wallet.js");
|
|
5
|
+
class HDNodeWallet extends base_wallet_js_1.BaseWallet {
|
|
6
|
+
}
|
|
7
|
+
exports.HDNodeWallet = HDNodeWallet;
|
|
8
|
+
//# sourceMappingURL=seedwallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seedwallet.js","sourceRoot":"","sources":["../../src.ts/wallet/seedwallet.ts"],"names":[],"mappings":";;;AAAA,qDAA8C;AAE9C,MAAa,YAAa,SAAQ,2BAAU;CAE3C;AAFD,oCAEC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { SigningKey } from "../crypto/index.js";
|
|
2
2
|
import { BaseWallet } from "./base-wallet.js";
|
|
3
|
-
import { HDNodeWallet } from "./hdwallet.js";
|
|
4
|
-
import type { ProgressCallback } from "../crypto/index.js";
|
|
5
3
|
import type { Provider } from "../providers/index.js";
|
|
6
4
|
/**
|
|
7
5
|
* A **Wallet** manages a single private key which is used to sign
|
|
@@ -28,7 +26,7 @@ export declare class Wallet extends BaseWallet {
|
|
|
28
26
|
* If %%progressCallback%% is specified, it will receive periodic
|
|
29
27
|
* updates as the encryption process progreses.
|
|
30
28
|
*/
|
|
31
|
-
encrypt(password: Uint8Array | string
|
|
29
|
+
encrypt(password: Uint8Array | string): Promise<string>;
|
|
32
30
|
/**
|
|
33
31
|
* Returns a [JSON Keystore Wallet](json-wallets) encryped with
|
|
34
32
|
* %%password%%.
|
|
@@ -43,11 +41,8 @@ export declare class Wallet extends BaseWallet {
|
|
|
43
41
|
/**
|
|
44
42
|
* Creates (asynchronously) a **Wallet** by decrypting the %%json%%
|
|
45
43
|
* with %%password%%.
|
|
46
|
-
*
|
|
47
|
-
* If %%progress%% is provided, it is called periodically during
|
|
48
|
-
* decryption so that any UI can be updated.
|
|
49
44
|
*/
|
|
50
|
-
static fromEncryptedJson(json: string, password: Uint8Array | string
|
|
45
|
+
static fromEncryptedJson(json: string, password: Uint8Array | string): Promise<Wallet>;
|
|
51
46
|
/**
|
|
52
47
|
* Creates a **Wallet** by decrypting the %%json%% with %%password%%.
|
|
53
48
|
*
|
|
@@ -55,17 +50,13 @@ export declare class Wallet extends BaseWallet {
|
|
|
55
50
|
* will lock up and freeze the UI during decryption, which may take
|
|
56
51
|
* some time.
|
|
57
52
|
*/
|
|
58
|
-
static fromEncryptedJsonSync(json: string, password: Uint8Array | string):
|
|
53
|
+
static fromEncryptedJsonSync(json: string, password: Uint8Array | string): Wallet;
|
|
59
54
|
/**
|
|
60
|
-
* Creates a new random [[
|
|
55
|
+
* Creates a new random [[Wallet]] using the available
|
|
61
56
|
* [cryptographic random source](randomBytes).
|
|
62
57
|
*
|
|
63
58
|
* If there is no crytographic random source, this will throw.
|
|
64
59
|
*/
|
|
65
|
-
static createRandom(provider?: null | Provider):
|
|
66
|
-
/**
|
|
67
|
-
* Creates a [[HDNodeWallet]] for %%phrase%%.
|
|
68
|
-
*/
|
|
69
|
-
static fromPhrase(phrase: string, provider?: Provider): HDNodeWallet;
|
|
60
|
+
static createRandom(provider?: null | Provider): Wallet;
|
|
70
61
|
}
|
|
71
62
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src.ts/wallet/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src.ts/wallet/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAW9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKtD;;;;;;;;;GASG;AACH,qBAAa,MAAO,SAAQ,UAAU;;IAElC;;;OAGG;gBACS,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ;IAShE,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,QAAQ,GAAG,MAAM;IAI1C;;;;;;OAMG;IACG,OAAO,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK7D;;;;;;;;;OASG;IACH,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM;IAgBlD;;;OAGG;WACU,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAU5F;;;;;;OAMG;IACH,MAAM,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM;IAWjF;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ,GAAG,MAAM;CAc1D"}
|
|
@@ -4,13 +4,11 @@ exports.Wallet = void 0;
|
|
|
4
4
|
const index_js_1 = require("../crypto/index.js");
|
|
5
5
|
const index_js_2 = require("../utils/index.js");
|
|
6
6
|
const base_wallet_js_1 = require("./base-wallet.js");
|
|
7
|
-
|
|
8
|
-
const json_crowdsale_js_1 = require("./json-crowdsale.js");
|
|
7
|
+
//import { decryptCrowdsaleJson, isCrowdsaleJson } from "./json-crowdsale.js";
|
|
9
8
|
const json_keystore_js_1 = require("./json-keystore.js");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
9
|
+
//import { Mnemonic } from "./mnemonic.js";
|
|
10
|
+
const qcsdk = require("quantum-coin-js-sdk");
|
|
11
|
+
//import {newWallet} from "quantum-coin-js-sdk";
|
|
14
12
|
/**
|
|
15
13
|
* A **Wallet** manages a single private key which is used to sign
|
|
16
14
|
* transactions, messages and other common payloads.
|
|
@@ -43,9 +41,9 @@ class Wallet extends base_wallet_js_1.BaseWallet {
|
|
|
43
41
|
* If %%progressCallback%% is specified, it will receive periodic
|
|
44
42
|
* updates as the encryption process progreses.
|
|
45
43
|
*/
|
|
46
|
-
async encrypt(password
|
|
44
|
+
async encrypt(password) {
|
|
47
45
|
const account = { address: this.address, privateKey: this.privateKey };
|
|
48
|
-
return
|
|
46
|
+
return (0, json_keystore_js_1.encryptKeystoreJsonSync)(account, password);
|
|
49
47
|
}
|
|
50
48
|
/**
|
|
51
49
|
* Returns a [JSON Keystore Wallet](json-wallets) encryped with
|
|
@@ -63,14 +61,6 @@ class Wallet extends base_wallet_js_1.BaseWallet {
|
|
|
63
61
|
}
|
|
64
62
|
static #fromAccount(account) {
|
|
65
63
|
(0, index_js_2.assertArgument)(account, "invalid JSON wallet", "json", "[ REDACTED ]");
|
|
66
|
-
if ("mnemonic" in account && account.mnemonic && account.mnemonic.locale === "en") {
|
|
67
|
-
const mnemonic = mnemonic_js_1.Mnemonic.fromEntropy(account.mnemonic.entropy);
|
|
68
|
-
const wallet = hdwallet_js_1.HDNodeWallet.fromMnemonic(mnemonic, account.mnemonic.path);
|
|
69
|
-
if (wallet.address === account.address && wallet.privateKey === account.privateKey) {
|
|
70
|
-
return wallet;
|
|
71
|
-
}
|
|
72
|
-
console.log("WARNING: JSON mismatch address/privateKey != mnemonic; fallback onto private key");
|
|
73
|
-
}
|
|
74
64
|
const wallet = new Wallet(account.privateKey);
|
|
75
65
|
(0, index_js_2.assertArgument)(wallet.address === account.address, "address/privateKey mismatch", "json", "[ REDACTED ]");
|
|
76
66
|
return wallet;
|
|
@@ -78,25 +68,11 @@ class Wallet extends base_wallet_js_1.BaseWallet {
|
|
|
78
68
|
/**
|
|
79
69
|
* Creates (asynchronously) a **Wallet** by decrypting the %%json%%
|
|
80
70
|
* with %%password%%.
|
|
81
|
-
*
|
|
82
|
-
* If %%progress%% is provided, it is called periodically during
|
|
83
|
-
* decryption so that any UI can be updated.
|
|
84
71
|
*/
|
|
85
|
-
static async fromEncryptedJson(json, password
|
|
72
|
+
static async fromEncryptedJson(json, password) {
|
|
86
73
|
let account = null;
|
|
87
74
|
if ((0, json_keystore_js_1.isKeystoreJson)(json)) {
|
|
88
|
-
account =
|
|
89
|
-
}
|
|
90
|
-
else if ((0, json_crowdsale_js_1.isCrowdsaleJson)(json)) {
|
|
91
|
-
if (progress) {
|
|
92
|
-
progress(0);
|
|
93
|
-
await stall(0);
|
|
94
|
-
}
|
|
95
|
-
account = (0, json_crowdsale_js_1.decryptCrowdsaleJson)(json, password);
|
|
96
|
-
if (progress) {
|
|
97
|
-
progress(1);
|
|
98
|
-
await stall(0);
|
|
99
|
-
}
|
|
75
|
+
account = (0, json_keystore_js_1.decryptKeystoreJsonSync)(json, password);
|
|
100
76
|
}
|
|
101
77
|
return Wallet.#fromAccount(account);
|
|
102
78
|
}
|
|
@@ -112,36 +88,21 @@ class Wallet extends base_wallet_js_1.BaseWallet {
|
|
|
112
88
|
if ((0, json_keystore_js_1.isKeystoreJson)(json)) {
|
|
113
89
|
account = (0, json_keystore_js_1.decryptKeystoreJsonSync)(json, password);
|
|
114
90
|
}
|
|
115
|
-
else if ((0, json_crowdsale_js_1.isCrowdsaleJson)(json)) {
|
|
116
|
-
account = (0, json_crowdsale_js_1.decryptCrowdsaleJson)(json, password);
|
|
117
|
-
}
|
|
118
91
|
else {
|
|
119
92
|
(0, index_js_2.assertArgument)(false, "invalid JSON wallet", "json", "[ REDACTED ]");
|
|
120
93
|
}
|
|
121
94
|
return Wallet.#fromAccount(account);
|
|
122
95
|
}
|
|
123
96
|
/**
|
|
124
|
-
* Creates a new random [[
|
|
97
|
+
* Creates a new random [[Wallet]] using the available
|
|
125
98
|
* [cryptographic random source](randomBytes).
|
|
126
99
|
*
|
|
127
100
|
* If there is no crytographic random source, this will throw.
|
|
128
101
|
*/
|
|
129
102
|
static createRandom(provider) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
return wallet;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Creates a [[HDNodeWallet]] for %%phrase%%.
|
|
138
|
-
*/
|
|
139
|
-
static fromPhrase(phrase, provider) {
|
|
140
|
-
const wallet = hdwallet_js_1.HDNodeWallet.fromPhrase(phrase);
|
|
141
|
-
if (provider) {
|
|
142
|
-
return wallet.connect(provider);
|
|
143
|
-
}
|
|
144
|
-
return wallet;
|
|
103
|
+
let wal = qcsdk.newWallet();
|
|
104
|
+
let privKey = wal.privateKey;
|
|
105
|
+
return new Wallet((0, index_js_2.hexlify)(privKey));
|
|
145
106
|
}
|
|
146
107
|
}
|
|
147
108
|
exports.Wallet = Wallet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src.ts/wallet/wallet.ts"],"names":[],"mappings":";;;AAAA,iDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src.ts/wallet/wallet.ts"],"names":[],"mappings":";;;AAAA,iDAAgD;AAChD,gDAA2D;AAE3D,qDAA8C;AAE9C,+EAA+E;AAC/E,yDAI4B;AAC5B,2CAA2C;AAC3C,6CAA8C;AAK9C,gDAAgD;AAEhD;;;;;;;;;GASG;AACH,MAAa,MAAO,SAAQ,2BAAU;IAElC;;;OAGG;IACH,YAAY,GAAwB,EAAE,QAA0B;QAC5D,IAAI,OAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACnD,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;SACpB;QAED,IAAI,UAAU,GAAG,CAAC,OAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC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AAA,0CAAuB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SAErD;QAED,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,qBAAqB,CAAC,IAAY,EAAE,QAA6B;QACpE,IAAI,OAAO,GAA2B,IAAI,CAAC;QAC3C,IAAI,IAAA,iCAAc,EAAC,IAAI,CAAC,EAAE;YACtB,OAAO,GAAG,IAAA,0CAAuB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SACrD;aAAM;YACH,IAAA,yBAAc,EAAC,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;SACxE;QAED,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,QAA0B;QAC1C,IAAI,GAAG,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,OAAO,GAAQ,GAAG,CAAC,UAAU,CAAC;QAClC,OAAO,IAAI,MAAM,CAAC,IAAA,kBAAO,EAAC,OAAO,CAAC,CAAC,CAAC;IACxC,CAAC;CAUJ;AA7GD,wBA6GC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a normalized and checksumed address for %%address%%.
|
|
3
|
-
* This accepts non-checksum addresses, checksum addresses
|
|
4
|
-
* [[getIcapAddress]] formats.
|
|
3
|
+
* This accepts non-checksum addresses, checksum addresses formats.
|
|
5
4
|
*
|
|
6
5
|
* The checksum in Ethereum uses the capitalization (upper-case
|
|
7
6
|
* vs lower-case) of the characters within an address to encode
|
|
@@ -34,23 +33,4 @@
|
|
|
34
33
|
* //_error:
|
|
35
34
|
*/
|
|
36
35
|
export declare function getAddress(address: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* The [ICAP Address format](link-icap) format is an early checksum
|
|
39
|
-
* format which attempts to be compatible with the banking
|
|
40
|
-
* industry [IBAN format](link-wiki-iban) for bank accounts.
|
|
41
|
-
*
|
|
42
|
-
* It is no longer common or a recommended format.
|
|
43
|
-
*
|
|
44
|
-
* @example:
|
|
45
|
-
* getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
|
|
46
|
-
* //_result:
|
|
47
|
-
*
|
|
48
|
-
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
|
|
49
|
-
* //_result:
|
|
50
|
-
*
|
|
51
|
-
* // Throws an error if the ICAP checksum is wrong
|
|
52
|
-
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
|
|
53
|
-
* //_error:
|
|
54
|
-
*/
|
|
55
|
-
export declare function getIcapAddress(address: string): string;
|
|
56
36
|
//# sourceMappingURL=address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src.ts/address/address.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src.ts/address/address.ts"],"names":[],"mappings":"AAkFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA6BlD"}
|
|
@@ -70,8 +70,7 @@ function fromBase36(value) {
|
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Returns a normalized and checksumed address for %%address%%.
|
|
73
|
-
* This accepts non-checksum addresses, checksum addresses
|
|
74
|
-
* [[getIcapAddress]] formats.
|
|
73
|
+
* This accepts non-checksum addresses, checksum addresses formats.
|
|
75
74
|
*
|
|
76
75
|
* The checksum in Ethereum uses the capitalization (upper-case
|
|
77
76
|
* vs lower-case) of the characters within an address to encode
|
|
@@ -127,30 +126,4 @@ export function getAddress(address) {
|
|
|
127
126
|
}
|
|
128
127
|
assertArgument(false, "invalid address", "address", address);
|
|
129
128
|
}
|
|
130
|
-
/**
|
|
131
|
-
* The [ICAP Address format](link-icap) format is an early checksum
|
|
132
|
-
* format which attempts to be compatible with the banking
|
|
133
|
-
* industry [IBAN format](link-wiki-iban) for bank accounts.
|
|
134
|
-
*
|
|
135
|
-
* It is no longer common or a recommended format.
|
|
136
|
-
*
|
|
137
|
-
* @example:
|
|
138
|
-
* getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
|
|
139
|
-
* //_result:
|
|
140
|
-
*
|
|
141
|
-
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
|
|
142
|
-
* //_result:
|
|
143
|
-
*
|
|
144
|
-
* // Throws an error if the ICAP checksum is wrong
|
|
145
|
-
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
|
|
146
|
-
* //_error:
|
|
147
|
-
*/
|
|
148
|
-
export function getIcapAddress(address) {
|
|
149
|
-
//let base36 = _base16To36(getAddress(address).substring(2)).toUpperCase();
|
|
150
|
-
let base36 = BigInt(getAddress(address)).toString(36).toUpperCase();
|
|
151
|
-
while (base36.length < 30) {
|
|
152
|
-
base36 = "0" + base36;
|
|
153
|
-
}
|
|
154
|
-
return "XE" + ibanChecksum("XE00" + base36) + base36;
|
|
155
|
-
}
|
|
156
129
|
//# sourceMappingURL=address.js.map
|