tetsuo-blockchain-wallet 1.2.3 → 1.2.5

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 CHANGED
@@ -1,424 +1,460 @@
1
- # TETSUO Wallet SDK
1
+ # TETSUO Blockchain Wallet SDK
2
2
 
3
- A comprehensive TypeScript SDK for creating and managing TETSUO blockchain wallets. This package provides tools for wallet generation, transaction building, signing, and blockchain interaction.
3
+ [![npm version](https://img.shields.io/npm/v/tetsuo-blockchain-wallet.svg)](https://www.npmjs.com/package/tetsuo-blockchain-wallet)
4
+ [![npm downloads](https://img.shields.io/npm/dm/tetsuo-blockchain-wallet.svg)](https://www.npmjs.com/package/tetsuo-blockchain-wallet)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![GitHub](https://img.shields.io/badge/GitHub-tetsuonpmwallet-blue.svg)](https://github.com/Pavelevich/tetsuonpmwallet)
4
7
 
5
- ## Features
8
+ ```
9
+ ████████╗███████╗████████╗███████╗██╗ ██╗ ██████╗ ██╗ ██╗ █████╗ ██╗ ██╗ ███████╗████████╗
10
+ ╚══██╔══╝██╔════╝╚══██╔══╝██╔════╝██║ ██║██╔═══██╗ ██║ ██║██╔══██╗██║ ██║ ██╔════╝╚══██╔══╝
11
+ ██║ █████╗ ██║ ███████╗██║ ██║██║ ██║ ██║ █╗ ██║███████║██║ ██║ █████╗ ██║
12
+ ██║ ██╔══╝ ██║ ╚════██║██║ ██║██║ ██║ ██║███╗██║██╔══██║██║ ██║ ██╔══╝ ██║
13
+ ██║ ███████╗ ██║ ███████║╚██████╔╝╚██████╔╝ ╚███╔███╔╝██║ ██║███████╗███████╗███████╗ ██║
14
+ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═╝
15
+ ```
6
16
 
7
- **Wallet Management**
8
- - Generate wallets with BIP39 mnemonics
9
- - Import wallets from existing mnemonics or private keys
10
- - Secure key derivation using PBKDF2
11
- - Public key and address generation
12
-
13
- ✅ **Transaction Operations**
14
- - Build unsigned transactions
15
- - Select UTXOs automatically
16
- - Calculate fees dynamically
17
- - Create transaction hex payloads
18
-
19
- ✅ **Address Management**
20
- - Generate TETSUO addresses from public keys
21
- - Validate address format and checksums
22
- - Extract address information
23
-
24
- ✅ **Blockchain Interaction**
25
- - RPC client for network communication
26
- - Get balance and transaction history
27
- - Fetch UTXOs for address
28
- - Broadcast signed transactions
29
- - Estimate network fees
30
-
31
- ✅ **Cryptography**
32
- - SHA256 and RIPEMD160 hashing
33
- - Base58 and Base58Check encoding
34
- - ECDSA signing with secp256k1
35
- - Random key generation
17
+ **Secure Blockchain Wallet • Client-Side Signing • Zero Trust Architecture**
36
18
 
37
- ## Installation
19
+ A **production-ready** TypeScript SDK for building and managing TETSUO blockchain wallets. Provides secure wallet generation, transaction signing, and blockchain interaction with client-side signing for maximum security.
38
20
 
39
- ```bash
40
- npm install tetsuo-blockchain-wallet
41
- ```
21
+ ## Table of Contents
42
22
 
43
- ## CLI Usage
23
+ - [Features](#features)
24
+ - [Installation](#installation)
25
+ - [Quick Start](#quick-start)
26
+ - [CLI Usage](#cli-usage)
27
+ - [API Reference](#api-reference)
28
+ - [Security](#security)
29
+ - [Examples](#examples)
30
+ - [Development](#development)
31
+ - [Contributing](#contributing)
32
+ - [License](#license)
44
33
 
45
- The package includes an interactive CLI tool for managing wallets:
34
+ ## Features
46
35
 
47
- ```bash
48
- tetsuo
49
- ```
36
+ ### 🔐 Wallet Management
37
+ - **BIP39 Mnemonics**: Generate 12-word recovery phrases for wallet backup
38
+ - **Multiple Import Methods**: Import from mnemonics or private keys
39
+ - **Secure Key Derivation**: Secp256k1 elliptic curve cryptography
40
+ - **Local Wallet Storage**: Encrypted wallet data at `~/.tetsuo/wallets.json`
41
+
42
+ ### 💱 Transaction Operations
43
+ - **Client-Side Signing**: All transactions signed locally (never share private keys)
44
+ - **Automatic UTXO Selection**: Smart coin selection algorithm
45
+ - **Dynamic Fee Calculation**: Accurate fee estimation based on network
46
+ - **Transaction Building**: Complete transaction hex generation
47
+
48
+ ### 📍 Address Management
49
+ - **TETSUO Address Generation**: From public keys with proper checksums
50
+ - **Address Validation**: Format and checksum verification
51
+ - **Hash160 Support**: Extract address information
52
+
53
+ ### 🌐 Blockchain Interaction
54
+ - **RPC Client**: Full-featured network communication
55
+ - **Balance Queries**: Get balance in TETSUO
56
+ - **UTXO Fetching**: For transaction input selection
57
+ - **Transaction Broadcasting**: Publish signed transactions
58
+ - **Fee Estimation**: Network-based fee calculation
59
+
60
+ ### 🔒 Cryptography
61
+ - **SHA256 & RIPEMD160**: Standard blockchain hashing
62
+ - **Base58Check Encoding**: Bitcoin-compatible address encoding
63
+ - **ECDSA Signing**: Secp256k1 signature generation
64
+ - **Secure Random**: Cryptographically secure key generation
50
65
 
51
- ### Available Commands
66
+ ## Installation
52
67
 
53
- ```
54
- /create-wallet - Create a new wallet with BIP39 mnemonic
55
- /import-wallet - Import wallet from mnemonic or private key
56
- /list-wallets - Display all stored wallets
57
- /select-wallet - Select active wallet for operations
58
- /balance - Check wallet balance
59
- /transactions - View transaction history
60
- /receive - Display receiving address
61
- /send - Send TETSUO to another address
62
- /wallet-data - View detailed wallet information
63
- /delete-wallet - Delete a wallet
64
- /exit - Exit the CLI
68
+ ```bash
69
+ npm install -g tetsuo-blockchain-wallet
65
70
  ```
66
71
 
67
- ### Example CLI Workflow
72
+ Or for programmatic use:
68
73
 
69
74
  ```bash
70
- # Start the CLI
71
- $ tetsuo
72
-
73
- # Create a new wallet
74
- Command: /create-wallet
75
- Wallet name: my-wallet
76
- ⏳ Generating wallet...
77
- ✓ Wallet created successfully!
78
- 📝 Mnemonic (BACKUP THIS):
79
- word1 word2 word3 ... word12
80
- 📍 Address:
81
- T1234567890abcdefghijklmnopqrstuvwxyz
82
-
83
- # Check balance
84
- Command: /balance
85
- ⏳ Fetching balance...
86
- 💰 Balance:
87
- 5.50000000 TETSUO
88
-
89
- # View transactions
90
- Command: /transactions
91
- 📋 Transaction History:
92
- ─────────────────────────────────────────────────────────────────────────────
93
- ↓ RECEIVE | 5.50 TETSUO | 2024-01-01T12:00:00Z
94
- ↑ SEND | 2.00 TETSUO | 2023-12-31T10:30:00Z
95
- ─────────────────────────────────────────────────────────────────────────────
96
-
97
- # Show receive address
98
- Command: /receive
99
- 📍 Receive Address:
100
- T1234567890abcdefghijklmnopqrstuvwxyz
101
- Share this address to receive TETSUO
75
+ npm install tetsuo-blockchain-wallet
102
76
  ```
103
77
 
104
- ### Environment Variables
78
+ ## Quick Start
79
+
80
+ ### Interactive CLI (Easiest)
105
81
 
106
82
  ```bash
107
- # Set custom RPC endpoint (default: http://localhost:8080)
108
- export TETSUO_RPC_URL=http://your-rpc-server:8080
109
83
  tetsuo
110
84
  ```
111
85
 
112
- ### Wallet Storage
113
-
114
- Wallets are stored locally in:
86
+ Then use commands like:
115
87
  ```
116
- ~/.tetsuo/wallets.json
88
+ /create-wallet - Create new wallet
89
+ /balance - Check balance
90
+ /send - Send TETSUO tokens
91
+ /list-wallets - View all wallets
92
+ /exit - Exit program
117
93
  ```
118
94
 
119
- Each wallet stores:
120
- - Name
121
- - Address
122
- - Public Key
123
- - Private Key (encrypted recommended for production)
124
- - Mnemonic (if available)
125
- - Creation timestamp
126
-
127
- ## Quick Start
128
-
129
95
  ### Programmatic API
130
96
 
131
- ### Generate a New Wallet
132
-
133
97
  ```typescript
134
- import { generateWallet } from 'tetsuo-blockchain-wallet';
98
+ import {
99
+ generateWallet,
100
+ createRPCClient,
101
+ buildTransaction,
102
+ signTransaction,
103
+ createTransactionHex
104
+ } from 'tetsuo-blockchain-wallet';
135
105
 
106
+ // Create wallet
136
107
  const wallet = await generateWallet();
137
-
138
- console.log('Mnemonic:', wallet.mnemonic);
139
108
  console.log('Address:', wallet.address);
140
- console.log('Private Key:', wallet.privateKey);
141
- ```
142
-
143
- ### Import Wallet from Mnemonic
144
-
145
- ```typescript
146
- import { importFromMnemonic } from 'tetsuo-blockchain-wallet';
147
-
148
- const mnemonic = 'word1 word2 word3 ... word12';
149
- const wallet = await importFromMnemonic(mnemonic);
109
+ console.log('Backup mnemonic:', wallet.mnemonic);
110
+
111
+ // Get balance
112
+ const rpc = createRPCClient('https://tetsuoarena.com');
113
+ const balance = await rpc.getBalance(wallet.address);
114
+ console.log('Balance:', balance, 'TETSUO');
115
+
116
+ // Send transaction
117
+ const utxos = await rpc.getUTXOs(wallet.address);
118
+ const { inputs, outputs } = buildTransaction(
119
+ wallet.address,
120
+ 'T1234567890abcdefghijklmnopqrstuvwxyz',
121
+ 1.5, // 1.5 TETSUO
122
+ utxos,
123
+ wallet.address
124
+ );
150
125
 
151
- console.log('Address:', wallet.address);
126
+ const txHex = createTransactionHex(inputs, outputs);
127
+ const signedTx = signTransaction(txHex, wallet.privateKey, inputs, utxos);
128
+ const txid = await rpc.broadcastTransaction(signedTx);
129
+ console.log('Sent! TXID:', txid);
152
130
  ```
153
131
 
154
- ### Import Wallet from Private Key
155
-
156
- ```typescript
157
- import { importFromPrivateKey } from 'tetsuo-blockchain-wallet';
132
+ ## CLI Usage
158
133
 
159
- const privateKey = '0000000000000000000000000000000000000000000000000000000000000001';
160
- const wallet = importFromPrivateKey(privateKey);
134
+ ### Start the CLI
161
135
 
162
- console.log('Address:', wallet.address);
136
+ ```bash
137
+ tetsuo
163
138
  ```
164
139
 
165
- ### Get Balance
140
+ ### Available Commands
166
141
 
167
- ```typescript
168
- import { createRPCClient } from 'tetsuo-blockchain-wallet';
142
+ | Command | Description |
143
+ |---------|-------------|
144
+ | `/create-wallet` | Create new wallet with BIP39 mnemonic |
145
+ | `/import-wallet` | Import from existing mnemonic or private key |
146
+ | `/list-wallets` | Display all stored wallets |
147
+ | `/select-wallet` | Choose active wallet for operations |
148
+ | `/balance` | Check current wallet balance |
149
+ | `/transactions` | View transaction history |
150
+ | `/receive` | Display receiving address |
151
+ | `/send` | Send TETSUO to another address |
152
+ | `/wallet-data` | View detailed wallet information |
153
+ | `/delete-wallet` | Remove wallet from storage |
154
+ | `/config` | Configure RPC endpoint |
155
+ | `/exit` | Quit the CLI |
156
+
157
+ ### Example Workflow
169
158
 
170
- const rpc = createRPCClient('http://localhost:8080');
171
- const balance = await rpc.getBalance('TYourAddressHere');
159
+ ```bash
160
+ $ tetsuo
172
161
 
173
- console.log('Balance (TETSUO):', balance);
162
+ [...] Generating wallet...
163
+ [OK] Wallet created successfully!
164
+ [NOTE] Mnemonic (BACKUP THIS):
165
+ word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12
166
+
167
+ [ADDR] Address:
168
+ TAbcdefghijklmnopqrstuvwxyz1234567890
169
+
170
+ $ /balance
171
+ [...] Fetching balance...
172
+ [BALANCE] Balance Information:
173
+ ──────────────────────────────────────────────────
174
+ Wallet: my-wallet
175
+ Address: TAbcdefghijklmnopqrstuvwxyz1234567890
176
+ Balance: 10.50000000 TETSUO
177
+ ──────────────────────────────────────────────────
178
+
179
+ $ /send
180
+ Recipient address: T1111111111111111111111111111111111111111
181
+ Amount (TETSUO): 5
182
+
183
+ [...] Preparing transaction...
184
+ [HISTORY] Transaction Details:
185
+ ────────────────────────────────────────────────────────────
186
+ From: TAbcdefghijklmnopqrstuvwxyz1234567890
187
+ To: T1111111111111111111111111111111111111111
188
+ Amount: 5.00000000 TETSUO
189
+ Fee: 0.00025000 TETSUO
190
+ Total: 5.00025000 TETSUO
191
+ ────────────────────────────────────────────────────────────
192
+
193
+ Confirm transaction? (yes/no): yes
194
+
195
+ [...] Signing transaction...
196
+ [OK] Transaction sent successfully!
197
+
198
+ [INFO] Transaction Info:
199
+ TXID: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6...
174
200
  ```
175
201
 
176
- ### Build and Sign Transaction
177
-
178
- ```typescript
179
- import {
180
- buildTransaction,
181
- createTransactionHex,
182
- signTransaction,
183
- createRPCClient
184
- } from 'tetsuo-blockchain-wallet';
185
-
186
- const rpc = createRPCClient('http://localhost:8080');
202
+ ### Configuration
187
203
 
188
- // Get UTXOs
189
- const utxos = await rpc.getUTXOs(fromAddress);
190
-
191
- // Build transaction
192
- const { inputs, outputs, fee } = buildTransaction(
193
- fromAddress,
194
- toAddress,
195
- 0.5, // 0.5 TETSUO
196
- utxos,
197
- changeAddress
198
- );
199
-
200
- // Create transaction hex
201
- const unsignedTx = createTransactionHex(inputs, outputs);
202
-
203
- // Sign transaction
204
- const signature = signTransaction(unsignedTx, privateKey, inputs);
204
+ ```bash
205
+ # Custom RPC endpoint
206
+ export TETSUO_RPC_URL=https://your-rpc-server.com
207
+ tetsuo
205
208
 
206
- // Broadcast
207
- const txid = await rpc.broadcastTransaction(signature);
208
- console.log('Transaction sent:', txid);
209
+ # Default RPC (if not set)
210
+ # https://tetsuoarena.com
209
211
  ```
210
212
 
211
- ### Validate Address
212
-
213
- ```typescript
214
- import { isValidAddress, validateAddress } from 'tetsuo-blockchain-wallet';
215
-
216
- const address = 'TYourAddressHere';
217
-
218
- // Check if valid
219
- if (isValidAddress(address)) {
220
- console.log('Valid address');
221
- }
213
+ ### Wallet Storage
222
214
 
223
- // Or throw error if invalid
224
- try {
225
- validateAddress(address);
226
- } catch (error) {
227
- console.error('Invalid address');
228
- }
215
+ Wallets are stored locally at:
216
+ ```
217
+ ~/.tetsuo/wallets.json
229
218
  ```
230
219
 
220
+ Each wallet contains:
221
+ - Name (user-defined)
222
+ - Address (TETSUO blockchain address)
223
+ - Public Key (compressed format)
224
+ - Private Key (hex format, handle with care!)
225
+ - Mnemonic (if wallet was generated)
226
+ - Creation timestamp
227
+
231
228
  ## API Reference
232
229
 
233
230
  ### Wallet Functions
234
231
 
235
- #### `generateWallet(): Promise<GeneratedWallet>`
236
- Generate a new wallet with a random mnemonic.
232
+ #### `generateWallet(): Promise<Wallet>`
233
+ Generate new wallet with random BIP39 mnemonic.
237
234
 
238
- **Returns:**
239
235
  ```typescript
240
- {
241
- mnemonic: string; // 12-word BIP39 phrase
242
- privateKey: string; // 64-char hex string
243
- publicKey: string; // Compressed public key
244
- address: string; // TETSUO address
245
- }
236
+ const wallet = await generateWallet();
237
+ // {
238
+ // mnemonic: "word1 word2 ... word12",
239
+ // privateKey: "abcd1234...",
240
+ // publicKey: "02abcd1234...",
241
+ // address: "TAbcdef..."
242
+ // }
246
243
  ```
247
244
 
248
- #### `importFromMnemonic(mnemonic: string): Promise<GeneratedWallet>`
249
- Import wallet from existing mnemonic phrase.
250
-
251
- **Throws:** `WalletError` if mnemonic is invalid.
252
-
253
- #### `importFromPrivateKey(privateKeyHex: string): ImportedWallet`
254
- Import wallet from private key.
245
+ #### `importFromMnemonic(mnemonic: string): Promise<Wallet>`
246
+ Import wallet from 12-word BIP39 mnemonic.
255
247
 
256
- **Parameters:**
257
- - `privateKeyHex`: 64-character hex string (32 bytes)
248
+ ```typescript
249
+ const wallet = await importFromMnemonic(
250
+ 'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12'
251
+ );
252
+ ```
258
253
 
259
- **Throws:** `WalletError` if private key is invalid.
254
+ #### `importFromPrivateKey(privateKey: string): Wallet`
255
+ Import wallet from 64-character hex private key.
260
256
 
261
- #### `derivePublicKey(privateKeyHex: string): string`
262
- Derive public key from private key.
257
+ ```typescript
258
+ const wallet = importFromPrivateKey('abcd1234...0000');
259
+ ```
263
260
 
264
261
  #### `isValidMnemonic(mnemonic: string): boolean`
265
- Validate a BIP39 mnemonic phrase.
262
+ Validate BIP39 mnemonic phrase.
266
263
 
267
- ### Address Functions
264
+ #### `derivePublicKey(privateKey: string): string`
265
+ Derive compressed public key from private key.
268
266
 
269
- #### `generateAddress(publicKeyHex: string): string`
270
- Generate TETSUO address from public key.
267
+ ### Address Functions
271
268
 
272
269
  #### `isValidAddress(address: string): boolean`
273
- Check if address format is valid.
270
+ Check if TETSUO address format is valid.
274
271
 
275
272
  #### `validateAddress(address: string): string`
276
- Validate address and throw error if invalid.
273
+ Validate address or throw error.
277
274
 
278
- **Throws:** `InvalidAddressError` if address is invalid.
279
-
280
- #### `addressToHash160(address: string): Buffer`
281
- Extract HASH160 from address.
275
+ #### `generateAddress(publicKey: string): string`
276
+ Generate TETSUO address from public key.
282
277
 
283
278
  ### Transaction Functions
284
279
 
285
- #### `buildTransaction(fromAddress, toAddress, amount, utxos, changeAddress): TransactionData`
286
- Build unsigned transaction.
280
+ #### `buildTransaction(fromAddr, toAddr, amount, utxos, changeAddr): TransactionData`
281
+ Build unsigned transaction with automatic UTXO selection.
287
282
 
288
- **Parameters:**
289
- - `fromAddress`: Sender's TETSUO address
290
- - `toAddress`: Recipient's TETSUO address
291
- - `amount`: Amount in TETSUO (decimal)
292
- - `utxos`: Array of available UTXOs
293
- - `changeAddress`: Address for change output
294
-
295
- **Returns:**
296
283
  ```typescript
297
- {
298
- inputs: TransactionInput[];
299
- outputs: TransactionOutput[];
300
- fee: number; // in satoshis
301
- }
284
+ const txData = buildTransaction(
285
+ 'TFrom...',
286
+ 'TTo...',
287
+ 1.5, // TETSUO amount
288
+ utxos,
289
+ 'TChangeAddr...'
290
+ );
291
+ // Returns: { inputs, outputs, fee }
302
292
  ```
303
293
 
304
- **Throws:** `InsufficientFundsError` if not enough balance.
305
-
306
294
  #### `createTransactionHex(inputs, outputs): string`
307
295
  Create transaction hex from inputs and outputs.
308
296
 
309
- #### `signTransaction(txHex, privateKey, inputs): string`
310
- Sign transaction and return signed hex.
297
+ #### `signTransaction(txHex, privateKey, inputs, utxos): string`
298
+ Sign transaction with private key. Returns signed transaction hex.
311
299
 
312
300
  #### `estimateFee(inputCount, outputCount): number`
313
- Estimate transaction fee (in satoshis).
314
-
315
- #### `estimateTransactionSize(inputCount, outputCount): number`
316
- Estimate transaction size (in bytes).
301
+ Estimate transaction fee in satoshis.
317
302
 
318
303
  ### RPC Client
319
304
 
320
- #### `createRPCClient(networkUrl?: string): TetsuoRPC`
305
+ #### `createRPCClient(url?: string): RPC`
321
306
  Create RPC client instance.
322
307
 
323
- **Parameters:**
324
- - `networkUrl`: Optional, defaults to `http://localhost:8080`
308
+ ```typescript
309
+ const rpc = createRPCClient('https://tetsuoarena.com');
310
+ ```
325
311
 
326
312
  #### `rpc.getBalance(address: string): Promise<number>`
327
313
  Get balance in TETSUO.
328
314
 
329
- #### `rpc.getDetailedBalance(address: string): Promise<Balance>`
330
- Get balance with confirmed/unconfirmed breakdown.
331
-
332
315
  #### `rpc.getUTXOs(address: string): Promise<UTXO[]>`
333
- Get list of unspent transaction outputs.
316
+ Get unspent transaction outputs for address.
334
317
 
335
318
  #### `rpc.getTransactionHistory(address: string): Promise<Transaction[]>`
336
319
  Get transaction history for address.
337
320
 
338
- #### `rpc.broadcastTransaction(transactionHex: string): Promise<string>`
339
- Broadcast signed transaction. Returns transaction ID.
321
+ #### `rpc.broadcastTransaction(txHex: string): Promise<string>`
322
+ Broadcast signed transaction. Returns TXID.
340
323
 
341
- #### `rpc.getBlockchainInfo(): Promise<BlockchainInfo>`
342
- Get blockchain information.
324
+ #### `rpc.ping(): Promise<boolean>`
325
+ Health check for RPC endpoint.
343
326
 
344
- #### `rpc.estimateFee(inputCount, outputCount): Promise<number>`
345
- Estimate network fee.
327
+ ## Security
346
328
 
347
- #### `rpc.validateAddress(address: string): Promise<boolean>`
348
- Check if address is valid on network.
329
+ ### 🔒 Critical Security Guidelines
349
330
 
350
- #### `rpc.ping(): Promise<boolean>`
351
- Health check for RPC endpoint.
331
+ **Private Keys**
332
+ - Never expose private keys
333
+ - Never share mnemonics
334
+ - Back up mnemonics offline only
335
+ - Consider using hardware wallets for large amounts
336
+
337
+ **Network Security**
338
+ - Always use HTTPS for RPC endpoints in production
339
+ - Verify RPC endpoint authenticity
340
+ - Use verified blockchain explorers
341
+ - Never paste private keys into unsecured apps
342
+
343
+ **Client-Side Signing**
344
+ - This SDK signs transactions **on your device only**
345
+ - Private keys never leave your computer
346
+ - Broadcast-only servers can't steal funds
347
+ - Always verify transaction details before confirming
348
+
349
+ **Best Practices**
350
+ ```typescript
351
+ // ✓ GOOD: Small test transaction first
352
+ const testTx = buildTransaction(from, to, 0.01, utxos, from);
353
+
354
+ // ✓ GOOD: Verify amounts before signing
355
+ console.log('Sending:', amount, 'to:', toAddress);
356
+
357
+ // ✗ BAD: Never log private keys
358
+ console.log(wallet.privateKey); // DON'T DO THIS
359
+
360
+ // ✗ BAD: Never send to unverified addresses
361
+ const address = userInput; // Verify first!
362
+ ```
363
+
364
+ ## Examples
365
+
366
+ ### Example 1: Create and Export Wallet
367
+
368
+ ```typescript
369
+ import { generateWallet } from 'tetsuo-blockchain-wallet';
352
370
 
353
- ### Crypto Functions
371
+ const wallet = await generateWallet();
354
372
 
355
- #### `sha256(data: string | Buffer): Buffer`
356
- Compute SHA256 hash.
373
+ console.log('📝 SAVE THIS MNEMONIC SECURELY:');
374
+ console.log(wallet.mnemonic);
357
375
 
358
- #### `doubleSha256(data: string | Buffer): Buffer`
359
- Compute double SHA256 (SHA256(SHA256(data))).
376
+ console.log('Your Address:', wallet.address);
377
+ console.log('Share this address to receive TETSUO');
378
+ ```
360
379
 
361
- #### `ripemd160(data: Buffer): Buffer`
362
- Compute RIPEMD160 hash.
380
+ ### Example 2: Check Balance
363
381
 
364
- #### `hash160(data: Buffer): Buffer`
365
- Compute HASH160 (RIPEMD160(SHA256(data))).
382
+ ```typescript
383
+ import { createRPCClient } from 'tetsuo-blockchain-wallet';
366
384
 
367
- #### `toHex(data: Buffer | string): string`
368
- Convert buffer or string to hex.
385
+ const rpc = createRPCClient('https://tetsuoarena.com');
386
+ const balance = await rpc.getBalance('TYourAddressHere');
387
+ console.log(`Balance: ${balance} TETSUO`);
388
+ ```
369
389
 
370
- #### `fromHex(hex: string): Buffer`
371
- Convert hex string to buffer.
390
+ ### Example 3: Send Transaction
372
391
 
373
- #### `toBase58(buffer: Buffer): string`
374
- Encode buffer to base58.
392
+ ```typescript
393
+ import {
394
+ createRPCClient,
395
+ buildTransaction,
396
+ createTransactionHex,
397
+ signTransaction,
398
+ importFromMnemonic
399
+ } from 'tetsuo-blockchain-wallet';
400
+
401
+ // Import wallet
402
+ const mnemonic = 'word1 word2 ... word12';
403
+ const wallet = await importFromMnemonic(mnemonic);
375
404
 
376
- #### `fromBase58(str: string): Buffer`
377
- Decode base58 string to buffer.
405
+ // Setup
406
+ const rpc = createRPCClient('https://tetsuoarena.com');
407
+ const recipientAddress = 'TRecipientAddressHere';
408
+ const amountTetsuo = 2.5;
409
+
410
+ // Get UTXOs
411
+ const utxos = await rpc.getUTXOs(wallet.address);
378
412
 
379
- #### `base58check(data: Buffer): string`
380
- Encode with base58check (base58 + checksum).
413
+ // Build transaction
414
+ const { inputs, outputs, fee } = buildTransaction(
415
+ wallet.address,
416
+ recipientAddress,
417
+ amountTetsuo,
418
+ utxos,
419
+ wallet.address // change address
420
+ );
381
421
 
382
- #### `base58checkDecode(encoded: string): Buffer`
383
- Decode base58check string.
422
+ // Sign and broadcast
423
+ const txHex = createTransactionHex(inputs, outputs);
424
+ const signedTx = signTransaction(txHex, wallet.privateKey, inputs, utxos);
425
+ const txid = await rpc.broadcastTransaction(signedTx);
384
426
 
385
- ## Error Handling
427
+ console.log(`✓ Transaction sent!`);
428
+ console.log(`TXID: ${txid}`);
429
+ console.log(`Explorer: https://tetsuoarena.com/tx/${txid}`);
430
+ ```
386
431
 
387
- The SDK provides custom error classes:
432
+ ### Example 4: Error Handling
388
433
 
389
434
  ```typescript
390
435
  import {
391
- WalletError,
392
436
  InvalidAddressError,
393
437
  InsufficientFundsError,
394
- RPCError
438
+ RPCError,
439
+ WalletError
395
440
  } from 'tetsuo-blockchain-wallet';
396
441
 
397
442
  try {
398
- // ... wallet operations
443
+ const wallet = await generateWallet();
444
+ // ... transaction logic
399
445
  } catch (error) {
400
446
  if (error instanceof InvalidAddressError) {
401
- console.error('Invalid address format');
447
+ console.error('Invalid recipient address');
402
448
  } else if (error instanceof InsufficientFundsError) {
403
- console.error('Not enough balance to send transaction');
449
+ console.error('Not enough balance');
404
450
  } else if (error instanceof RPCError) {
405
451
  console.error('Network error:', error.message);
406
452
  } else if (error instanceof WalletError) {
407
- console.error('Wallet operation failed:', error.message);
453
+ console.error('Wallet error:', error.message);
408
454
  }
409
455
  }
410
456
  ```
411
457
 
412
- ## Security Considerations
413
-
414
- ⚠️ **Important Security Notes:**
415
-
416
- 1. **Private Keys**: Never share your private keys. They are equivalent to your money.
417
- 2. **Mnemonics**: Backup your mnemonic phrase offline. Whoever has your mnemonic can access all funds.
418
- 3. **Network**: Always use HTTPS for RPC connections in production.
419
- 4. **Validation**: Always validate addresses before sending transactions.
420
- 5. **Testing**: Test with small amounts first before sending large transactions.
421
-
422
458
  ## Development
423
459
 
424
460
  ### Build
@@ -427,40 +463,77 @@ try {
427
463
  npm run build
428
464
  ```
429
465
 
430
- ### Run Tests
466
+ Compiles TypeScript to JavaScript in `dist/` directory.
467
+
468
+ ### Tests
431
469
 
432
470
  ```bash
433
471
  npm test
434
472
  ```
435
473
 
474
+ Run full test suite with Jest.
475
+
436
476
  ### Watch Mode
437
477
 
438
478
  ```bash
439
479
  npm run dev
440
480
  ```
441
481
 
482
+ Auto-recompile TypeScript on file changes.
483
+
484
+ ### Clean
485
+
486
+ ```bash
487
+ npm run clean
488
+ ```
489
+
490
+ Remove compiled files and coverage reports.
491
+
492
+ ## Recent Updates
493
+
494
+ ### Version 1.2.4 ✨
495
+ - **Fixed critical endianness bug** in transaction encoding (vout, sequence fields)
496
+ - **Removed emojis** from CLI for professional interface
497
+ - **Added ASCII art header** to wallet CLI
498
+ - Improved terminal output clarity
499
+
500
+ ### Version 1.2.3
501
+ - Client-side signing fully functional
502
+ - TETSUO-specific transaction format fixes (sequence 0xffffffff, SIGHASH_ALL)
503
+
504
+ ### Version 1.2.2
505
+ - Secp256k1 key derivation improvements
506
+ - Legacy HMAC wallet support (deprecated)
507
+
442
508
  ## Contributing
443
509
 
444
- Contributions are welcome! Please ensure:
445
- - Code follows TypeScript best practices
446
- - All tests pass
447
- - New features include tests
448
- - Documentation is updated
510
+ Contributions welcome! Please:
449
511
 
450
- ## License
512
+ 1. Fork the repository
513
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
514
+ 3. Commit changes (`git commit -m 'Add amazing feature'`)
515
+ 4. Push to branch (`git push origin feature/amazing-feature`)
516
+ 5. Open a Pull Request
451
517
 
452
- MIT
518
+ Requirements:
519
+ - Follow TypeScript best practices
520
+ - Add tests for new features
521
+ - Update documentation
522
+ - All tests must pass
453
523
 
454
524
  ## Support
455
525
 
456
- For issues, questions, or suggestions, please open an issue on GitHub.
526
+ - **Issues**: [GitHub Issues](https://github.com/Pavelevich/tetsuonpmwallet/issues)
527
+ - **Discussions**: [GitHub Discussions](https://github.com/Pavelevich/tetsuonpmwallet/discussions)
528
+
529
+ ## License
530
+
531
+ MIT License - see LICENSE file for details
532
+
533
+ ## Disclaimer
534
+
535
+ This software is provided "as is" without warranty. The authors are not responsible for lost funds or security breaches. Always test with small amounts first and follow security best practices.
457
536
 
458
- ## Changelog
537
+ ---
459
538
 
460
- ### Version 1.0.0
461
- - Initial release
462
- - Wallet generation and import
463
- - Transaction building and signing
464
- - Address validation and generation
465
- - RPC client for blockchain interaction
466
- - Comprehensive test suite
539
+ **Made with ❤️ for the TETSUO blockchain community**