@neuraiproject/neurai-key 2.8.5 → 2.8.7
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/LICENSE +1 -1
- package/README.md +32 -1
- package/coins/xna-legacy.js +82 -0
- package/coins/xna.js +82 -0
- package/dist/NeuraiKey.js +459 -3713
- package/dist/main.js +173 -3
- package/dist/main.js.map +1 -1
- package/dist/module.js +173 -4
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/index.ts +19 -2
- package/package.json +5 -6
- package/test.js +15 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@ Generate Neurai addresses from a mnemonic phrase following the standards BIP32,
|
|
|
4
4
|
|
|
5
5
|
That is, use your 12 words to get addresses for Neurai mainnet and testnet.
|
|
6
6
|
|
|
7
|
+
**NPM**: https://www.npmjs.com/package/@neuraiproject/neurai-key
|
|
8
|
+
**CDN**: https://cdn.jsdelivr.net/npm/@neuraiproject/neurai-key@2.8.5/dist/NeuraiKey.js
|
|
9
|
+
|
|
7
10
|
## Features
|
|
8
11
|
|
|
9
12
|
- ✅ Generate HD wallets from mnemonic phrases (BIP39)
|
|
@@ -11,8 +14,22 @@ That is, use your 12 words to get addresses for Neurai mainnet and testnet.
|
|
|
11
14
|
- ✅ Support for passphrase (25th word) for additional security
|
|
12
15
|
- ✅ Multi-language mnemonic support (English, Spanish, French, Italian, etc.)
|
|
13
16
|
- ✅ Mainnet and Testnet support for Neurai (XNA)
|
|
17
|
+
- ✅ Support for both XNA (BIP44: 1900) and XNA Legacy (BIP44: 0) networks
|
|
14
18
|
- ✅ Convert raw public keys into Neurai mainnet or testnet addresses
|
|
15
19
|
|
|
20
|
+
## Network Types
|
|
21
|
+
|
|
22
|
+
This library supports two Neurai network configurations:
|
|
23
|
+
|
|
24
|
+
- **`xna` / `xna-test`**: Current Neurai standard (BIP44 coin type: 1900)
|
|
25
|
+
- **`xna-legacy` / `xna-legacy-test`**: Legacy Neurai addresses (BIP44 coin type: 0)
|
|
26
|
+
|
|
27
|
+
The main difference is the BIP44 derivation path:
|
|
28
|
+
- **XNA**: `m/44'/1900'/0'/0/0` (recommended for new wallets)
|
|
29
|
+
- **XNA Legacy**: `m/44'/0'/0'/0/0` (for compatibility with older wallets)
|
|
30
|
+
|
|
31
|
+
**Note**: Using different network types will generate completely different addresses from the same mnemonic.
|
|
32
|
+
|
|
16
33
|
|
|
17
34
|
## Example get external and internal (change) addresses by path
|
|
18
35
|
|
|
@@ -28,7 +45,7 @@ import NeuraiKey from "@neuraiproject/neurai-key";
|
|
|
28
45
|
const mnemonic = NeuraiKey.generateMnemonic();
|
|
29
46
|
const ACCOUNT = 0; //default is zero
|
|
30
47
|
const POSITION = 1; //the second address for this wallet
|
|
31
|
-
const network = "xna"; //or xna-test for testnet
|
|
48
|
+
const network = "xna"; //or xna-test for testnet, xna-legacy for legacy addresses
|
|
32
49
|
const addressPair = NeuraiKey.getAddressPair(
|
|
33
50
|
network,
|
|
34
51
|
mnemonic,
|
|
@@ -163,6 +180,20 @@ console.log(testAddress); // tPXGaMRNwZuV1UKSrD9gABPscrJWUmedQ9
|
|
|
163
180
|
|
|
164
181
|
`publicKeyToAddress` throws if the key length is not 33 or 65 bytes so invalid inputs are surfaced immediately.
|
|
165
182
|
|
|
183
|
+
## Get public key from WIF
|
|
184
|
+
|
|
185
|
+
If you have a private key in Wallet Import Format (WIF) and want the corresponding compressed public key:
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
import NeuraiKey from "@neuraiproject/neurai-key";
|
|
189
|
+
|
|
190
|
+
const network = "xna"; // or "xna-test"
|
|
191
|
+
const wif = "KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq";
|
|
192
|
+
|
|
193
|
+
const pubkeyHex = NeuraiKey.getPubkeyByWIF(network, wif);
|
|
194
|
+
console.log(pubkeyHex);
|
|
195
|
+
```
|
|
196
|
+
|
|
166
197
|
## How to import into your project
|
|
167
198
|
|
|
168
199
|
### ES6 module
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neurai Legacy (XNA-LEGACY) chain configuration data
|
|
3
|
+
* This replaces the dependency on @hyperbitjs/chains with only the data needed for Neurai Legacy
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const xnaLegacy = {
|
|
7
|
+
mainnet: {
|
|
8
|
+
name: "Neurai",
|
|
9
|
+
unit: "XNA",
|
|
10
|
+
symbol: "xna",
|
|
11
|
+
decimalPlaces: 100000000,
|
|
12
|
+
messagePrefix: "Neurai Signed Message:\n",
|
|
13
|
+
confirmations: 6,
|
|
14
|
+
website: "https://neurai.org/",
|
|
15
|
+
projectUrl: "https://github.com/NeuraiProject",
|
|
16
|
+
id: "94C49B3B-2C88-4408-B566-3D277C596778",
|
|
17
|
+
network: "mainnet",
|
|
18
|
+
hashGenesisBlock: "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806",
|
|
19
|
+
port: 19000,
|
|
20
|
+
portRpc: 19001,
|
|
21
|
+
protocol: {
|
|
22
|
+
magic: 1381320014
|
|
23
|
+
},
|
|
24
|
+
seedsDns: [
|
|
25
|
+
"seed1.neurai.org",
|
|
26
|
+
"seed2.neurai.org",
|
|
27
|
+
"neurai-ipv4.neuraiexplorer.com"
|
|
28
|
+
],
|
|
29
|
+
versions: {
|
|
30
|
+
bip32: {
|
|
31
|
+
private: 76066276,
|
|
32
|
+
public: 76067358
|
|
33
|
+
},
|
|
34
|
+
bip44: 0,
|
|
35
|
+
private: 128,
|
|
36
|
+
public: 53,
|
|
37
|
+
scripthash: 117
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
testnet: {
|
|
41
|
+
name: "Neurai",
|
|
42
|
+
unit: "XNA",
|
|
43
|
+
symbol: "xna",
|
|
44
|
+
decimalPlaces: 100000000,
|
|
45
|
+
messagePrefix: "Neurai Signed Message:\n",
|
|
46
|
+
confirmations: 6,
|
|
47
|
+
website: "https://neurai.org/",
|
|
48
|
+
projectUrl: "https://github.com/NeuraiProject",
|
|
49
|
+
id: "1EB2ACBA-E8E0-4970-BB20-37DA4B70F6A6",
|
|
50
|
+
network: "testnet",
|
|
51
|
+
hashGenesisBlock: "0000006af8b8297448605b0283473ec712f9768f81cc7eae6269b875dee3b0cf",
|
|
52
|
+
port: 19100,
|
|
53
|
+
portRpc: 19101,
|
|
54
|
+
protocol: {
|
|
55
|
+
magic: 1313166674
|
|
56
|
+
},
|
|
57
|
+
seedsDns: [
|
|
58
|
+
"testnet1.neuracrypt.org",
|
|
59
|
+
"testnet2.neuracrypt.org",
|
|
60
|
+
"testnet3.neuracrypt.org"
|
|
61
|
+
],
|
|
62
|
+
versions: {
|
|
63
|
+
bip32: {
|
|
64
|
+
private: 70615956,
|
|
65
|
+
public: 70617039
|
|
66
|
+
},
|
|
67
|
+
bip44: 1,
|
|
68
|
+
private: 239,
|
|
69
|
+
public: 127,
|
|
70
|
+
scripthash: 196
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const chains = {
|
|
76
|
+
"xna-legacy": xnaLegacy
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
xnaLegacy,
|
|
81
|
+
chains
|
|
82
|
+
};
|
package/coins/xna.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neurai (XNA) chain configuration data
|
|
3
|
+
* This replaces the dependency on @hyperbitjs/chains with only the data needed for Neurai
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const xna = {
|
|
7
|
+
mainnet: {
|
|
8
|
+
name: "Neurai",
|
|
9
|
+
unit: "XNA",
|
|
10
|
+
symbol: "xna",
|
|
11
|
+
decimalPlaces: 100000000,
|
|
12
|
+
messagePrefix: "Neurai Signed Message:\n",
|
|
13
|
+
confirmations: 6,
|
|
14
|
+
website: "https://neurai.org/",
|
|
15
|
+
projectUrl: "https://github.com/NeuraiProject",
|
|
16
|
+
id: "94C49B3B-2C88-4408-B566-3D277C596778",
|
|
17
|
+
network: "mainnet",
|
|
18
|
+
hashGenesisBlock: "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806",
|
|
19
|
+
port: 19000,
|
|
20
|
+
portRpc: 19001,
|
|
21
|
+
protocol: {
|
|
22
|
+
magic: 1381320014
|
|
23
|
+
},
|
|
24
|
+
seedsDns: [
|
|
25
|
+
"seed1.neurai.org",
|
|
26
|
+
"seed2.neurai.org",
|
|
27
|
+
"neurai-ipv4.neuraiexplorer.com"
|
|
28
|
+
],
|
|
29
|
+
versions: {
|
|
30
|
+
bip32: {
|
|
31
|
+
private: 76066276,
|
|
32
|
+
public: 76067358
|
|
33
|
+
},
|
|
34
|
+
bip44: 1900,
|
|
35
|
+
private: 128,
|
|
36
|
+
public: 53,
|
|
37
|
+
scripthash: 117
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
testnet: {
|
|
41
|
+
name: "Neurai",
|
|
42
|
+
unit: "XNA",
|
|
43
|
+
symbol: "xna",
|
|
44
|
+
decimalPlaces: 100000000,
|
|
45
|
+
messagePrefix: "Neurai Signed Message:\n",
|
|
46
|
+
confirmations: 6,
|
|
47
|
+
website: "https://neurai.org/",
|
|
48
|
+
projectUrl: "https://github.com/NeuraiProject",
|
|
49
|
+
id: "1EB2ACBA-E8E0-4970-BB20-37DA4B70F6A6",
|
|
50
|
+
network: "testnet",
|
|
51
|
+
hashGenesisBlock: "0000006af8b8297448605b0283473ec712f9768f81cc7eae6269b875dee3b0cf",
|
|
52
|
+
port: 19100,
|
|
53
|
+
portRpc: 19101,
|
|
54
|
+
protocol: {
|
|
55
|
+
magic: 1313166674
|
|
56
|
+
},
|
|
57
|
+
seedsDns: [
|
|
58
|
+
"testnet1.neuracrypt.org",
|
|
59
|
+
"testnet2.neuracrypt.org",
|
|
60
|
+
"testnet3.neuracrypt.org"
|
|
61
|
+
],
|
|
62
|
+
versions: {
|
|
63
|
+
bip32: {
|
|
64
|
+
private: 70615956,
|
|
65
|
+
public: 70617039
|
|
66
|
+
},
|
|
67
|
+
bip44: 1,
|
|
68
|
+
private: 239,
|
|
69
|
+
public: 127,
|
|
70
|
+
scripthash: 196
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const chains = {
|
|
76
|
+
xna
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
xna,
|
|
81
|
+
chains
|
|
82
|
+
};
|