|
11 | 11 | <a href="https://jitpack.io/#galaxyscitech/tokencore"> |
12 | 12 | <img src="https://jitpack.io/v/galaxyscitech/tokencore.svg" alt="JitPack"> |
13 | 13 | </a> |
14 | | - <a href="https://github.com/galaxyscitech/tokencore/issues"> |
15 | | - <img src="https://img.shields.io/github/issues/galaxyscitech/tokencore.svg" alt="Issues"> |
16 | | - </a> |
17 | | - <a href="https://github.com/galaxyscitech/tokencore/pulls"> |
18 | | - <img src="https://img.shields.io/github/issues-pr/galaxyscitech/tokencore.svg" alt="Pull Requests"> |
19 | | - </a> |
20 | | - <a href="https://github.com/galaxyscitech/tokencore/graphs/contributors"> |
21 | | - <img src="https://img.shields.io/github/contributors/galaxyscitech/tokencore.svg" alt="Contributors"> |
22 | | - </a> |
23 | | - <a href="LICENSE"> |
24 | | - <img src="https://img.shields.io/github/license/galaxyscitech/tokencore.svg" alt="License"> |
25 | | - </a> |
26 | 14 | </p> |
27 | 15 |
|
28 | 16 | <p align="center"> |
29 | | - <a href="#supported-chains">Supported Chains</a> • |
30 | | - <a href="#quick-start">Quick Start</a> • |
| 17 | + <a href="#quick-start-30-seconds">Quick Start (30s)</a> • |
31 | 18 | <a href="#integration">Integration</a> • |
32 | | - <a href="#offline-signing">Offline Signing</a> • |
33 | | - <a href="#contact">Contact</a> |
| 19 | + <a href="#core-features-recommended-minimum">Recommended Minimum</a> • |
| 20 | + <a href="#supported-chains">Supported Chains</a> |
34 | 21 | </p> |
35 | 22 |
|
36 | 23 | --- |
37 | 24 |
|
38 | 25 | ## Introduction |
39 | 26 |
|
40 | | -Tokencore is a lightweight Java library that provides core wallet functionality for multiple blockchains. It handles HD wallet derivation, encrypted keystore management, and offline transaction signing — making it the ideal building block for exchange backends and custodial wallet services. |
| 27 | +Tokencore is a lightweight Java library for wallet fundamentals: HD derivation, encrypted keystore management, and offline signing. |
41 | 28 |
|
42 | | -For a complete exchange wallet backend built on top of Tokencore, see [java-wallet](https://github.com/galaxyscitech/java-wallet). |
| 29 | +If your goal is "install and use immediately", start with the 30-second quick start below and only enable additional chains/features later. |
43 | 30 |
|
44 | | -## Supported Chains |
| 31 | +## Quick Start (30 seconds) |
45 | 32 |
|
46 | | -| Chain | Token Standards | Features | |
47 | | -|-------|----------------|----------| |
48 | | -| **Bitcoin** | BTC, OMNI | UTXO management, SegWit (P2WPKH) | |
49 | | -| **Ethereum** | ETH, ERC-20 | Offline signing, nonce management | |
50 | | -| **TRON** | TRX, TRC-20 | Transaction signing | |
51 | | -| **Bitcoin Cash** | BCH | CashAddr format | |
52 | | -| **Bitcoin SV** | BSV | Transaction signing | |
53 | | -| **Litecoin** | LTC | Transaction signing | |
54 | | -| **Dogecoin** | DOGE | Transaction signing | |
55 | | -| **Dash** | DASH | Transaction signing | |
56 | | -| **Filecoin** | FIL | Transaction signing | |
| 33 | +### 1) Add dependency |
| 34 | + |
| 35 | +```gradle |
| 36 | +repositories { |
| 37 | + maven { url 'https://jitpack.io' } |
| 38 | +} |
| 39 | +dependencies { |
| 40 | + implementation 'com.github.galaxyscitech:tokencore:1.3.0' |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +### 2) Copy this minimal bootstrap code |
| 45 | + |
| 46 | +```java |
| 47 | +WalletManager.storage = () -> new File("./keystore"); |
| 48 | +WalletManager.scanWallets(); |
| 49 | + |
| 50 | +String password = "change_me"; |
| 51 | +Identity identity = Identity.getCurrentIdentity(); |
| 52 | +if (identity == null) { |
| 53 | + identity = Identity.createIdentity("default", password, "", Network.MAINNET, Metadata.P2WPKH); |
| 54 | +} |
| 55 | + |
| 56 | +Wallet wallet = identity.deriveWalletByMnemonics( |
| 57 | + ChainType.ETHEREUM, |
| 58 | + password, |
| 59 | + MnemonicUtil.randomMnemonicCodes()); |
| 60 | + |
| 61 | +System.out.println("Address = " + wallet.getAddress()); |
| 62 | +``` |
| 63 | + |
| 64 | +### 3) Verify locally |
| 65 | + |
| 66 | +```bash |
| 67 | +./gradlew test |
| 68 | +``` |
57 | 69 |
|
58 | | -## Requirements |
| 70 | +## Core Features (Recommended Minimum) |
59 | 71 |
|
60 | | -- **Java** 8 or higher |
61 | | -- **Gradle** 8.5+ (included via wrapper, no manual install needed) |
| 72 | +For new integrators, keep the initial rollout small: |
| 73 | + |
| 74 | +1. **Identity + keystore only** (account generation + secure storage) |
| 75 | +2. **Single chain first** (recommend: ETH or BTC) |
| 76 | +3. **Offline signing only** (avoid online key usage) |
| 77 | +4. **No multi-chain abstraction in v1 API surface** |
| 78 | + |
| 79 | +This reduces integration complexity and speeds up first successful deployment. |
62 | 80 |
|
63 | 81 | ## Integration |
64 | 82 |
|
@@ -90,135 +108,27 @@ dependencies { |
90 | 108 | </dependency> |
91 | 109 | ``` |
92 | 110 |
|
93 | | -## Quick Start |
94 | | - |
95 | | -### 1. Initialize Keystore & Identity |
96 | | - |
97 | | -```java |
98 | | -WalletManager.storage = new KeystoreStorage() { |
99 | | - @Override |
100 | | - public File getKeystoreDir() { |
101 | | - return new File("/path/to/keystore"); |
102 | | - } |
103 | | -}; |
104 | | -WalletManager.scanWallets(); |
105 | | - |
106 | | -String password = "your_password"; |
107 | | -Identity identity = Identity.getCurrentIdentity(); |
108 | | - |
109 | | -if (identity == null) { |
110 | | - identity = Identity.createIdentity( |
111 | | - "token", password, "", Network.MAINNET, Metadata.P2WPKH); |
112 | | -} |
113 | | -``` |
114 | | - |
115 | | -### 2. Derive a Wallet |
116 | | - |
117 | | -```java |
118 | | -Identity identity = Identity.getCurrentIdentity(); |
119 | | -Wallet wallet = identity.deriveWalletByMnemonics( |
120 | | - ChainType.BITCOIN, "your_password", MnemonicUtil.randomMnemonicCodes()); |
121 | | -System.out.println(wallet.getAddress()); |
122 | | -``` |
123 | | - |
124 | | -## Offline Signing |
125 | | - |
126 | | -Offline signing creates a digital signature without ever exposing private keys to an online environment. |
127 | | - |
128 | | -### Bitcoin |
129 | | - |
130 | | -```java |
131 | | -// 1. Define transaction parameters |
132 | | -String toAddress = "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9"; |
133 | | -int changeIdx = 0; |
134 | | -long amount = 1000L; |
135 | | -long fee = 555L; |
136 | | - |
137 | | -// 2. Collect UTXOs (from your node or a third-party API) |
138 | | -ArrayList<BitcoinTransaction.UTXO> utxos = new ArrayList<>(); |
139 | | - |
140 | | -// 3. Build and sign |
141 | | -BitcoinTransaction bitcoinTransaction = new BitcoinTransaction( |
142 | | - toAddress, changeIdx, amount, fee, utxos); |
143 | | -Wallet wallet = WalletManager.findWalletByAddress( |
144 | | - ChainType.BITCOIN, "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9"); |
145 | | -TxSignResult txSignResult = bitcoinTransaction.signTransaction( |
146 | | - String.valueOf(ChainId.BITCOIN_MAINNET), "your_password", wallet); |
147 | | -System.out.println(txSignResult.getSignedTx()); |
148 | | -``` |
149 | | - |
150 | | -### Ethereum |
151 | | - |
152 | | -```java |
153 | | -EthereumTransaction tx = new EthereumTransaction( |
154 | | - BigInteger.ZERO, // nonce |
155 | | - BigInteger.valueOf(20_000_000_000L), // gasPrice |
156 | | - BigInteger.valueOf(21_000), // gasLimit |
157 | | - "0xRecipientAddress", // to |
158 | | - BigInteger.valueOf(1_000_000_000_000_000_000L), // value (1 ETH) |
159 | | - "" // data |
160 | | -); |
161 | | - |
162 | | -Wallet wallet = WalletManager.findWalletByAddress( |
163 | | - ChainType.ETHEREUM, "0xYourAddress"); |
164 | | -TxSignResult result = tx.signTransaction( |
165 | | - String.valueOf(ChainId.ETHEREUM_MAINNET), "your_password", wallet); |
166 | | -System.out.println(result.getSignedTx()); |
167 | | -``` |
168 | | - |
169 | | -### TRON |
| 111 | +## Supported Chains |
170 | 112 |
|
171 | | -```java |
172 | | -String from = "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8"; |
173 | | -String to = "TF17BgPaZYbz8oxbjhriubPDsA7ArKoLX3"; |
174 | | - |
175 | | -TronTransaction transaction = new TronTransaction(from, to, 1L); |
176 | | -Wallet wallet = WalletManager.findWalletByAddress(ChainType.TRON, from); |
177 | | -TxSignResult result = transaction.signTransaction( |
178 | | - "mainnet", "your_password", wallet); |
179 | | -System.out.println(result.getSignedTx()); |
180 | | -``` |
| 113 | +| Chain | Token Standards | Features | |
| 114 | +|-------|----------------|----------| |
| 115 | +| **Bitcoin** | BTC, OMNI | UTXO management, SegWit (P2WPKH) | |
| 116 | +| **Ethereum** | ETH, ERC-20 | Offline signing, nonce management | |
| 117 | +| **TRON** | TRX, TRC-20 | Transaction signing | |
| 118 | +| **Bitcoin Cash** | BCH | CashAddr format | |
| 119 | +| **Bitcoin SV** | BSV | Transaction signing | |
| 120 | +| **Litecoin** | LTC | Transaction signing | |
| 121 | +| **Dogecoin** | DOGE | Transaction signing | |
| 122 | +| **Dash** | DASH | Transaction signing | |
| 123 | +| **Filecoin** | FIL | Transaction signing | |
181 | 124 |
|
182 | 125 | ## Build & Test |
183 | 126 |
|
184 | 127 | ```bash |
185 | | -# Build the library |
186 | 128 | ./gradlew build |
187 | | - |
188 | | -# Run the test suite |
189 | 129 | ./gradlew test |
190 | 130 | ``` |
191 | 131 |
|
192 | | -## Project Structure |
193 | | - |
194 | | -``` |
195 | | -src/main/java/org/consenlabs/tokencore/ |
196 | | -├── wallet/ |
197 | | -│ ├── Identity.java # HD identity management |
198 | | -│ ├── Wallet.java # Wallet abstraction |
199 | | -│ ├── WalletManager.java # Wallet lifecycle & discovery |
200 | | -│ ├── address/ # Chain-specific address generation |
201 | | -│ ├── keystore/ # Encrypted keystore implementations |
202 | | -│ ├── model/ # ChainType, ChainId, Metadata, etc. |
203 | | -│ ├── network/ # Bitcoin-fork network parameters |
204 | | -│ ├── transaction/ # Offline signing per chain |
205 | | -│ └── validators/ # Address & key validation |
206 | | -└── foundation/ |
207 | | - ├── crypto/ # AES, KDF, hashing primitives |
208 | | - ├── utils/ # Mnemonic, numeric, byte helpers |
209 | | - └── rlp/ # RLP encoding (Ethereum) |
210 | | -``` |
211 | | - |
212 | 132 | ## License |
213 | 133 |
|
214 | 134 | This project is licensed under the [GNU General Public License v3.0](LICENSE). |
215 | | - |
216 | | -## Contact |
217 | | - |
218 | | -- **Telegram**: [t.me/GalaxySciTech](https://t.me/GalaxySciTech) |
219 | | -- **Website**: [galaxy.doctor](https://galaxy.doctor) |
220 | | -- **GitHub Issues**: [Report a bug](https://github.com/galaxyscitech/tokencore/issues/new) |
221 | | - |
222 | | ---- |
223 | | - |
224 | | -> **Disclaimer**: Tokencore is a functional component for digital currency operations. It is intended primarily for learning and development purposes and does not provide a complete blockchain business solution. Use at your own risk. |
0 commit comments