lunalib 1.5.1__py3-none-any.whl → 1.7.2__py3-none-any.whl
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.
Potentially problematic release.
This version of lunalib might be problematic. Click here for more details.
- lunalib/core/__init__.py +14 -0
- lunalib/core/blockchain.py +183 -3
- lunalib/core/daemon.py +494 -0
- lunalib/core/p2p.py +361 -0
- lunalib/core/sm2.py +723 -723
- lunalib/core/wallet.py +714 -478
- lunalib/core/wallet_manager.py +638 -638
- lunalib/core/wallet_sync_helper.py +163 -163
- lunalib/gtx/digital_bill.py +10 -2
- lunalib/gtx/genesis.py +23 -24
- lunalib/mining/__init__.py +5 -0
- lunalib/mining/cuda_manager.py +23 -28
- lunalib/mining/difficulty.py +38 -0
- lunalib/mining/miner.py +526 -17
- lunalib/storage/cache.py +13 -4
- lunalib/storage/database.py +14 -5
- lunalib/storage/encryption.py +11 -2
- lunalib/transactions/security.py +19 -10
- lunalib/transactions/transactions.py +50 -41
- lunalib-1.7.2.dist-info/METADATA +27 -0
- lunalib-1.7.2.dist-info/RECORD +33 -0
- lunalib-1.7.2.dist-info/top_level.txt +1 -0
- core/__init__.py +0 -0
- core/blockchain.py +0 -172
- core/crypto.py +0 -32
- core/wallet.py +0 -408
- gtx/__init__.py +0 -0
- gtx/bill_registry.py +0 -122
- gtx/digital_bill.py +0 -273
- gtx/genesis.py +0 -338
- lunalib/requirements.txt +0 -44
- lunalib-1.5.1.dist-info/METADATA +0 -283
- lunalib-1.5.1.dist-info/RECORD +0 -53
- lunalib-1.5.1.dist-info/entry_points.txt +0 -2
- lunalib-1.5.1.dist-info/top_level.txt +0 -6
- mining/__init__.py +0 -0
- mining/cuda_manager.py +0 -137
- mining/difficulty.py +0 -106
- mining/miner.py +0 -107
- storage/__init__.py +0 -0
- storage/cache.py +0 -148
- storage/database.py +0 -222
- storage/encryption.py +0 -105
- transactions/__init__.py +0 -0
- transactions/security.py +0 -172
- transactions/transactions.py +0 -424
- transactions/validator.py +0 -71
- {lunalib-1.5.1.dist-info → lunalib-1.7.2.dist-info}/WHEEL +0 -0
lunalib-1.5.1.dist-info/METADATA
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: lunalib
|
|
3
|
-
Version: 1.5.1
|
|
4
|
-
Summary: A Complete Cryptocurrency Wallet and Mining System
|
|
5
|
-
Home-page: https://github.com/taellinglin/LunaLib
|
|
6
|
-
Author: Ling Lin
|
|
7
|
-
Author-email: taellinglin@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Project-URL: Bug Tracker, https://github.com/taellinglin/LunaLib/issues
|
|
10
|
-
Project-URL: Documentation, https://linglin.art/docs/luna-lib
|
|
11
|
-
Project-URL: Source Code, https://github.com/taellinglin/LunaLib
|
|
12
|
-
Keywords: cryptocurrency,blockchain,wallet,mining,bitcoin,ethereum,crypto
|
|
13
|
-
Classifier: Development Status :: 4 - Beta
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
-
Classifier: Operating System :: OS Independent
|
|
17
|
-
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
-
Classifier: Topic :: Security :: Cryptography
|
|
24
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
-
Classifier: Topic :: Office/Business :: Financial
|
|
26
|
-
Requires-Python: >=3.7
|
|
27
|
-
Description-Content-Type: text/markdown
|
|
28
|
-
Requires-Dist: requests>=2.31.0
|
|
29
|
-
Requires-Dist: cryptography>=41.0.0
|
|
30
|
-
Requires-Dist: qrcode[pil]>=7.4.0
|
|
31
|
-
Requires-Dist: Pillow>=10.0.0
|
|
32
|
-
Requires-Dist: pytest>=7.4.0
|
|
33
|
-
Requires-Dist: pytest-cov>=4.1.0
|
|
34
|
-
Requires-Dist: pytest-mock>=3.11.0
|
|
35
|
-
Requires-Dist: coverage>=7.0.0
|
|
36
|
-
Requires-Dist: black>=23.0.0
|
|
37
|
-
Requires-Dist: flake8>=6.0.0
|
|
38
|
-
Requires-Dist: mypy>=1.5.0
|
|
39
|
-
Requires-Dist: isort>=5.12.0
|
|
40
|
-
Requires-Dist: bandit>=1.7.0
|
|
41
|
-
Requires-Dist: build>=0.10.0
|
|
42
|
-
Requires-Dist: twine>=4.0.0
|
|
43
|
-
Requires-Dist: sphinx>=7.0.0
|
|
44
|
-
Requires-Dist: sphinx-rtd-theme>=1.3.0
|
|
45
|
-
Requires-Dist: types-requests>=2.31.0
|
|
46
|
-
Requires-Dist: typing-extensions>=4.8.0
|
|
47
|
-
Dynamic: author
|
|
48
|
-
Dynamic: author-email
|
|
49
|
-
Dynamic: classifier
|
|
50
|
-
Dynamic: description
|
|
51
|
-
Dynamic: description-content-type
|
|
52
|
-
Dynamic: home-page
|
|
53
|
-
Dynamic: keywords
|
|
54
|
-
Dynamic: license
|
|
55
|
-
Dynamic: project-url
|
|
56
|
-
Dynamic: requires-dist
|
|
57
|
-
Dynamic: requires-python
|
|
58
|
-
Dynamic: summary
|
|
59
|
-
|
|
60
|
-
# Luna Library
|
|
61
|
-
|
|
62
|
-
**A Complete Cryptocurrency Wallet and Mining System**
|
|
63
|
-
*Developed by Ling Lin • [LingLin.Art](https://linglin.art) • LingLin.Art, LLC*
|
|
64
|
-
|
|
65
|
-
[](https://opensource.org/licenses/MIT)
|
|
66
|
-
[](https://www.python.org/downloads/)
|
|
67
|
-
[]()
|
|
68
|
-
|
|
69
|
-
## 🌟 Overview
|
|
70
|
-
|
|
71
|
-
Luna Library is a comprehensive cryptocurrency system featuring secure wallet management, GTX Genesis digital bill mining, and blockchain transaction processing. Built with security and performance in mind, it provides the foundation for cryptocurrency applications including wallets, casinos, nodes, and treasury systems.
|
|
72
|
-
|
|
73
|
-
## 🚀 Features
|
|
74
|
-
|
|
75
|
-
### 💰 Wallet Management
|
|
76
|
-
- **Secure Key Generation**: Cryptographically secure private/public key pairs
|
|
77
|
-
- **Encrypted Storage**: AES-256 encrypted wallet files with password protection
|
|
78
|
-
- **Multi-Wallet Support**: Manage multiple wallets with individual labels
|
|
79
|
-
- **Import/Export**: Backup and restore wallets using private keys
|
|
80
|
-
- **Transaction History**: Complete transaction tracking and balance management
|
|
81
|
-
|
|
82
|
-
### ⛏️ GTX Genesis Mining
|
|
83
|
-
- **Digital Bill Mining**: Mine GTX Genesis bills with denomination-based difficulty
|
|
84
|
-
- **Proof-of-Work**: Configurable difficulty (2-10 leading zeros) based on bill value
|
|
85
|
-
- **CUDA Acceleration**: GPU-accelerated mining for improved performance
|
|
86
|
-
- **Bill Registry**: Track mined bills with verification URLs and metadata
|
|
87
|
-
- **1:1 Luna Value**: Each GTX bill denomination equals equivalent Luna value
|
|
88
|
-
|
|
89
|
-
### 🔗 Blockchain Integration
|
|
90
|
-
- **Network Connectivity**: Connect to Luna blockchain nodes
|
|
91
|
-
- **Transaction Broadcasting**: Send signed transactions to the network
|
|
92
|
-
- **Blockchain Scanning**: Efficient blockchain scanning for address activity
|
|
93
|
-
- **Mempool Monitoring**: Real-time transaction pool monitoring
|
|
94
|
-
- **Caching System**: Optimized caching for improved performance
|
|
95
|
-
|
|
96
|
-
### 🔒 Security & Validation
|
|
97
|
-
- **Cryptographic Signing**: Secure transaction signing with ECDSA
|
|
98
|
-
- **Transaction Validation**: Comprehensive security validation for all transaction types
|
|
99
|
-
- **Anti-Spam Protection**: Rate limiting and blacklisting capabilities
|
|
100
|
-
- **Risk Assessment**: Transaction risk level evaluation
|
|
101
|
-
- **Network Security**: Protection against malicious activities
|
|
102
|
-
|
|
103
|
-
## 📦 Installation
|
|
104
|
-
|
|
105
|
-
### Prerequisites
|
|
106
|
-
- Python 3.7 or higher
|
|
107
|
-
- pip (Python package manager)
|
|
108
|
-
|
|
109
|
-
### Install from Source
|
|
110
|
-
|
|
111
|
-
1. **Clone the repository**:
|
|
112
|
-
```bash
|
|
113
|
-
git clone https://github.com/linglin-art/luna_lib.git
|
|
114
|
-
cd luna_lib
|
|
115
|
-
```
|
|
116
|
-
2. **Install Requirements**
|
|
117
|
-
```bash
|
|
118
|
-
pip install -r requirements.txt
|
|
119
|
-
```
|
|
120
|
-
3. **Install with Pip**
|
|
121
|
-
```bash
|
|
122
|
-
pip install -e .
|
|
123
|
-
```
|
|
124
|
-
Optional: **CUDA Support**
|
|
125
|
-
```bash
|
|
126
|
-
Optional: CUDA Support
|
|
127
|
-
|
|
128
|
-
For GPU-accelerated mining, install CUDA dependencies:
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
## Basic Usage:
|
|
133
|
-
|
|
134
|
-
```python
|
|
135
|
-
from luna_lib import LunaWallet, GenesisMiner, GTXGenesis
|
|
136
|
-
|
|
137
|
-
# Create a new wallet
|
|
138
|
-
wallet = LunaWallet()
|
|
139
|
-
wallet_data = wallet.create_wallet("My Wallet", "secure_password")
|
|
140
|
-
|
|
141
|
-
print(f"Wallet created: {wallet_data['address']}")
|
|
142
|
-
|
|
143
|
-
# Initialize miner
|
|
144
|
-
miner = GenesisMiner()
|
|
145
|
-
|
|
146
|
-
# Mine a GTX $1000 bill
|
|
147
|
-
bill = miner.mine_bill(1000, wallet_data['address'])
|
|
148
|
-
|
|
149
|
-
if bill['success']:
|
|
150
|
-
print(f"✅ Mined GTX ${bill['denomination']:,} bill!")
|
|
151
|
-
print(f"💰 Luna value: {bill['luna_value']:,}")
|
|
152
|
-
print(f"🔗 Verification: {bill.get('verification_url', 'N/A')}")
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## Advanced Usage
|
|
156
|
-
```python
|
|
157
|
-
from luna_lib import GTXGenesis, BlockchainManager
|
|
158
|
-
from luna_lib.gtx.bill_registry import BillRegistry
|
|
159
|
-
|
|
160
|
-
# Check GTX portfolio
|
|
161
|
-
gtx = GTXGenesis()
|
|
162
|
-
portfolio = gtx.get_user_portfolio(wallet_data['address'])
|
|
163
|
-
|
|
164
|
-
print(f"Total GTX bills: {portfolio['total_bills']}")
|
|
165
|
-
print(f"Total Luna value: {portfolio['total_luna_value']:,}")
|
|
166
|
-
|
|
167
|
-
# Scan blockchain for transactions
|
|
168
|
-
blockchain = BlockchainManager()
|
|
169
|
-
transactions = blockchain.scan_transactions_for_address(wallet_data['address'])
|
|
170
|
-
|
|
171
|
-
print(f"Found {len(transactions)} transactions")
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
## Project Structure
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
luna_lib/
|
|
178
|
-
├── core/ # Core wallet and blockchain functionality
|
|
179
|
-
│ ├── wallet.py # Wallet management
|
|
180
|
-
│ ├── blockchain.py # Blockchain interactions
|
|
181
|
-
│ └── crypto.py # Cryptographic operations
|
|
182
|
-
├── mining/ # Mining-related components
|
|
183
|
-
│ ├── miner.py # Genesis bill miner
|
|
184
|
-
│ ├── difficulty.py # Difficulty calculations
|
|
185
|
-
│ └── cuda_manager.py # GPU acceleration
|
|
186
|
-
├── gtx/ # GTX Genesis system
|
|
187
|
-
│ ├── genesis.py # Main GTX manager
|
|
188
|
-
│ ├── digital_bill.py # Digital bill representation
|
|
189
|
-
│ └── bill_registry.py # Bill database
|
|
190
|
-
├── transactions/ # Transaction processing
|
|
191
|
-
│ ├── transaction.py # Transaction creation
|
|
192
|
-
│ ├── security.py # Security validation
|
|
193
|
-
│ └── validator.py # Transaction validation
|
|
194
|
-
└── storage/ # Data storage
|
|
195
|
-
├── database.py # Wallet database
|
|
196
|
-
├── cache.py # Blockchain cache
|
|
197
|
-
└── encryption.py # Encryption utilities
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
# **API Reference**
|
|
202
|
-
Core Classes
|
|
203
|
-
|
|
204
|
-
LunaWallet: Main wallet management class
|
|
205
|
-
|
|
206
|
-
GenesisMiner: GTX Genesis bill mining
|
|
207
|
-
|
|
208
|
-
GTXGenesis: GTX bill management and verification
|
|
209
|
-
|
|
210
|
-
BlockchainManager: Blockchain interactions
|
|
211
|
-
|
|
212
|
-
TransactionManager: Transaction creation and signing
|
|
213
|
-
|
|
214
|
-
## ***Key Methods***
|
|
215
|
-
### **Wallet Management**
|
|
216
|
-
```python
|
|
217
|
-
wallet.create_wallet(label, password) # Create new wallet
|
|
218
|
-
wallet.unlock_wallet(address, password) # Unlock existing wallet
|
|
219
|
-
wallet.export_private_key(address, password) # Export private key
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## ***Mining***
|
|
223
|
-
```python
|
|
224
|
-
miner.mine_bill(denomination, address) # Mine single bill
|
|
225
|
-
miner.start_auto_mining(denominations, address) # Auto-mine multiple bills
|
|
226
|
-
miner.stop_mining() # Stop mining operations
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
## **GTX Management**
|
|
230
|
-
|
|
231
|
-
```python
|
|
232
|
-
gtx.verify_bill(bill_serial) # Verify bill authenticity
|
|
233
|
-
gtx.get_user_portfolio(address) # Get user's GTX portfolio
|
|
234
|
-
gtx.transfer_bill(bill_serial, from_addr, to_addr, priv_key) # Transfer bill
|
|
235
|
-
```
|
|
236
|
-
# Configuration
|
|
237
|
-
## **Environment Variables**
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
export LUNA_ENDPOINT_URL="https://bank.linglin.art" # Blockchain endpoint
|
|
241
|
-
export LUNA_DATA_DIR="$HOME/.luna_wallet" # Data directory
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
## **Bill Denominations**
|
|
245
|
-
|
|
246
|
-
Supported GTX Genesis bill denominations:
|
|
247
|
-
```bash
|
|
248
|
-
$1 (Difficulty: 2 zeros)
|
|
249
|
-
$10 (Difficulty: 3 zeros)
|
|
250
|
-
$100 (Difficulty: 4 zeros)
|
|
251
|
-
$1,000 (Difficulty: 5 zeros)
|
|
252
|
-
$10,000 (Difficulty: 6 zeros)
|
|
253
|
-
$100,000 (Difficulty: 7 zeros)
|
|
254
|
-
$1,000,000 (Difficulty: 8 zeros)
|
|
255
|
-
$10,000,000 (Difficulty: 9 zeros)
|
|
256
|
-
$100,000,000 (Difficulty: 10 zeros)
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### **Contributing**
|
|
260
|
-
|
|
261
|
-
We welcome contributions! Please see our Contributing Guidelines for details.
|
|
262
|
-
|
|
263
|
-
- Fork the repository
|
|
264
|
-
|
|
265
|
-
- Create a feature branch (git checkout -b feature/amazing-feature)
|
|
266
|
-
|
|
267
|
-
- Commit your changes (git commit -m 'Add amazing feature')
|
|
268
|
-
|
|
269
|
-
- Push to the branch (git push origin feature/amazing-feature)
|
|
270
|
-
|
|
271
|
-
- Open a Pull Request
|
|
272
|
-
|
|
273
|
-
## License
|
|
274
|
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
275
|
-
|
|
276
|
-
### Support
|
|
277
|
-
|
|
278
|
-
Email: taellinglin@gmail.com
|
|
279
|
-
Website: LingLin.Art
|
|
280
|
-
|
|
281
|
-
Built with ❤️ by Ling Lin and the LingLin.Art, LLC team
|
|
282
|
-
|
|
283
|
-
Luna Library • Empowering the future of digital currency • LingLin.Art
|
lunalib-1.5.1.dist-info/RECORD
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
core/blockchain.py,sha256=KHlw1KsBUd1wkmxDunyyJiZMOlUx-Vr4wiDTl8YXdlo,6711
|
|
3
|
-
core/crypto.py,sha256=rBqSbr12Lh_0FdaYQ6XqLA4k8zdZb6MJs-eAjauwm1Q,1202
|
|
4
|
-
core/wallet.py,sha256=lyOfnaFZ1lms03AffERqYoBoonHQxB1Jb-MrUXMzZSU,16558
|
|
5
|
-
gtx/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
gtx/bill_registry.py,sha256=J1TivYIzmJEVQHNJrZxqOOEbUSlJs7rQIXfSA90ztL4,4333
|
|
7
|
-
gtx/digital_bill.py,sha256=EnQvAztMNE9uHuxXWmShEpNl084y-clHagK5s1Amvpc,10614
|
|
8
|
-
gtx/genesis.py,sha256=U6CEWcLAR1kb0CfhNQyFMIzh350OeQNNnWxycVJpPWc,15353
|
|
9
|
-
lunalib/__init__.py,sha256=fEvoHvfcC6ilDGQrhXaVmcdB4yDmuijxz6YZHkjbuBg,527
|
|
10
|
-
lunalib/cli.py,sha256=SyuJIhvqld-XL9ks9XFOuyqVb44qyBUbahlqE_RDVkM,524
|
|
11
|
-
lunalib/luna_lib.py,sha256=ue9Bs93xjpg7_GHSUJPKBhf8nF5YcbCIdoMIu-jDgG4,2748
|
|
12
|
-
lunalib/requirements.txt,sha256=3vNUgubGo8tCgeq5HwdGQcwrABxKthSlYsVp_76ckzw,1576
|
|
13
|
-
lunalib/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
lunalib/core/blockchain.py,sha256=gnlYSU1CIaa38bxByfKHlMpt8GMYpvib0EboVfNESek,36568
|
|
15
|
-
lunalib/core/crypto.py,sha256=R_f2sj7ASNnMW8Dtf2LIWTw-vCUjXD33zJPqPcPQVB8,10684
|
|
16
|
-
lunalib/core/mempool.py,sha256=itYFGQEuUde0Xh6WXcEz_n8hDsNhxkEAlRQ5g_Qiygg,14845
|
|
17
|
-
lunalib/core/sm2.py,sha256=8GHbJkrEwil_yoemUaDWAbcY_gm7Ld2WC7SpzUkpcRU,24177
|
|
18
|
-
lunalib/core/wallet.py,sha256=RNrEI7_tsaJOLcCJoTy_lLj22bc_bJtoO7iR3C3u7Ls,57435
|
|
19
|
-
lunalib/core/wallet_manager.py,sha256=ZyIy4OUaKv6kKmD3-jLof4vyhV-4opNmFk5ZWcLJAm0,26669
|
|
20
|
-
lunalib/core/wallet_sync_helper.py,sha256=hdZLUObaOVX7el5o9Nua2zUhOvEhAhdpbUNRpxnNwUw,6445
|
|
21
|
-
lunalib/gtx/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
lunalib/gtx/bill_registry.py,sha256=J1TivYIzmJEVQHNJrZxqOOEbUSlJs7rQIXfSA90ztL4,4333
|
|
23
|
-
lunalib/gtx/digital_bill.py,sha256=EnQvAztMNE9uHuxXWmShEpNl084y-clHagK5s1Amvpc,10614
|
|
24
|
-
lunalib/gtx/genesis.py,sha256=Mic48kI93fzMoz3Zm8xXGk8MXqUhfpLsNFLs8-ZJdCE,15939
|
|
25
|
-
lunalib/mining/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
lunalib/mining/cuda_manager.py,sha256=PUnmVvpu98OTZNdKIIYpVXnY__Ng4pHyZoh8wU-tDCM,5174
|
|
27
|
-
lunalib/mining/difficulty.py,sha256=tzIYmdcm1Xr9-8wyTwwkXJvJoGDyE77o_nu9d81VGvI,3927
|
|
28
|
-
lunalib/mining/miner.py,sha256=rH7Bhm378Rro4FlLqts3qYemHormtFnvz-R9SgJ0eu4,27520
|
|
29
|
-
lunalib/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
lunalib/storage/cache.py,sha256=1lNAeUop7ZanyjDUBSLJR6B0ATe6c_Kj0NAU9PAG2P0,4997
|
|
31
|
-
lunalib/storage/database.py,sha256=TjK9xUE8QRsUn3EqNHny1qyddUVlgTJFzhNCw8td7IM,7859
|
|
32
|
-
lunalib/storage/encryption.py,sha256=i_99Qk3I_gAZXwx00tL2Gy5mcALaDUC8olXZJUPAqMw,4054
|
|
33
|
-
lunalib/transactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
-
lunalib/transactions/security.py,sha256=jX4Eh4igQtiwVDhmoDGcm1tae2DRVS-JyLrRnn-n200,9924
|
|
35
|
-
lunalib/transactions/transactions.py,sha256=3kLOILnuN54seif17zMxx8NH8vkDPDTI_Rdtv4FDKmc,17611
|
|
36
|
-
lunalib/transactions/validator.py,sha256=FQ-jVjj8VoVTlq65blB_hprAwJOtpc2peYdQk_L2xmg,2730
|
|
37
|
-
mining/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
-
mining/cuda_manager.py,sha256=PUnmVvpu98OTZNdKIIYpVXnY__Ng4pHyZoh8wU-tDCM,5174
|
|
39
|
-
mining/difficulty.py,sha256=tzIYmdcm1Xr9-8wyTwwkXJvJoGDyE77o_nu9d81VGvI,3927
|
|
40
|
-
mining/miner.py,sha256=-Zlu6jWmW4YcFZDTz_sw_ZkvdXM-69gE89aOO7VWs2A,3800
|
|
41
|
-
storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
|
-
storage/cache.py,sha256=1lNAeUop7ZanyjDUBSLJR6B0ATe6c_Kj0NAU9PAG2P0,4997
|
|
43
|
-
storage/database.py,sha256=TjK9xUE8QRsUn3EqNHny1qyddUVlgTJFzhNCw8td7IM,7859
|
|
44
|
-
storage/encryption.py,sha256=i_99Qk3I_gAZXwx00tL2Gy5mcALaDUC8olXZJUPAqMw,4054
|
|
45
|
-
transactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
|
-
transactions/security.py,sha256=j23f2xjSaslQDD83_skdTSTL6FGEFD91D8xOaD6gf_M,6716
|
|
47
|
-
transactions/transactions.py,sha256=NiNshlf6RFFbmxgRzpYy7K1btUJpHtI1Kx747D_xRjw,17667
|
|
48
|
-
transactions/validator.py,sha256=FQ-jVjj8VoVTlq65blB_hprAwJOtpc2peYdQk_L2xmg,2730
|
|
49
|
-
lunalib-1.5.1.dist-info/METADATA,sha256=Win-29gD351YAShOlGVfUfD6ACp0DKms6ILIhkC91pY,9689
|
|
50
|
-
lunalib-1.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
51
|
-
lunalib-1.5.1.dist-info/entry_points.txt,sha256=bdt2wU-9FZOkmQ2pSy46WrxJSkpRPhVDkRFL1K_kakQ,49
|
|
52
|
-
lunalib-1.5.1.dist-info/top_level.txt,sha256=jEsGPJDTyYkwfmrSSw1GvJ1UxcPvChzv0s6xx-PvaXg,45
|
|
53
|
-
lunalib-1.5.1.dist-info/RECORD,,
|
mining/__init__.py
DELETED
|
File without changes
|
mining/cuda_manager.py
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import time
|
|
2
|
-
from typing import Optional, Dict, Any
|
|
3
|
-
import hashlib
|
|
4
|
-
import json
|
|
5
|
-
|
|
6
|
-
try:
|
|
7
|
-
import cupy as cp
|
|
8
|
-
CUDA_AVAILABLE = True
|
|
9
|
-
except ImportError:
|
|
10
|
-
CUDA_AVAILABLE = False
|
|
11
|
-
cp = None
|
|
12
|
-
|
|
13
|
-
class CUDAManager:
|
|
14
|
-
"""Manages CUDA acceleration for mining operations"""
|
|
15
|
-
|
|
16
|
-
def __init__(self):
|
|
17
|
-
self.cuda_available = self._check_cuda()
|
|
18
|
-
self.device = None
|
|
19
|
-
|
|
20
|
-
if self.cuda_available:
|
|
21
|
-
self._initialize_cuda()
|
|
22
|
-
|
|
23
|
-
def _check_cuda(self) -> bool:
|
|
24
|
-
"""Check if CUDA is available"""
|
|
25
|
-
try:
|
|
26
|
-
if not CUDA_AVAILABLE:
|
|
27
|
-
return False
|
|
28
|
-
|
|
29
|
-
if cp.cuda.runtime.getDeviceCount() > 0:
|
|
30
|
-
print("✅ CUDA is available for accelerated mining")
|
|
31
|
-
return True
|
|
32
|
-
else:
|
|
33
|
-
print("❌ CUDA drivers found but no GPU available")
|
|
34
|
-
return False
|
|
35
|
-
except Exception as e:
|
|
36
|
-
print(f"❌ CUDA check failed: {e}")
|
|
37
|
-
return False
|
|
38
|
-
|
|
39
|
-
def _initialize_cuda(self):
|
|
40
|
-
"""Initialize CUDA device"""
|
|
41
|
-
try:
|
|
42
|
-
self.device = cp.cuda.Device(0)
|
|
43
|
-
self.device.use()
|
|
44
|
-
print(f"✅ Using CUDA device: {cp.cuda.runtime.getDeviceProperties(0)['name']}")
|
|
45
|
-
except Exception as e:
|
|
46
|
-
print(f"❌ CUDA initialization failed: {e}")
|
|
47
|
-
self.cuda_available = False
|
|
48
|
-
|
|
49
|
-
def cuda_mine_batch(self, mining_data: Dict, difficulty: int, batch_size: int = 100000) -> Optional[Dict]:
|
|
50
|
-
"""Mine using CUDA acceleration"""
|
|
51
|
-
if not self.cuda_available:
|
|
52
|
-
return None
|
|
53
|
-
|
|
54
|
-
try:
|
|
55
|
-
target = "0" * difficulty
|
|
56
|
-
nonce_start = 0
|
|
57
|
-
start_time = time.time()
|
|
58
|
-
|
|
59
|
-
while True:
|
|
60
|
-
# Prepare batch data for GPU
|
|
61
|
-
nonces = cp.arange(nonce_start, nonce_start + batch_size, dtype=cp.uint64)
|
|
62
|
-
mining_strings = self._prepare_mining_batch(mining_data, nonces)
|
|
63
|
-
|
|
64
|
-
# Compute hashes on GPU
|
|
65
|
-
hashes = self._compute_hashes_gpu(mining_strings)
|
|
66
|
-
|
|
67
|
-
# Check for successful hash
|
|
68
|
-
for i, hash_hex in enumerate(hashes):
|
|
69
|
-
if hash_hex.startswith(target):
|
|
70
|
-
mining_time = time.time() - start_time
|
|
71
|
-
successful_nonce = nonce_start + i
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
"success": True,
|
|
75
|
-
"hash": hash_hex,
|
|
76
|
-
"nonce": int(successful_nonce),
|
|
77
|
-
"mining_time": mining_time,
|
|
78
|
-
"method": "cuda"
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
nonce_start += batch_size
|
|
82
|
-
|
|
83
|
-
# Progress update
|
|
84
|
-
if nonce_start % (batch_size * 10) == 0:
|
|
85
|
-
current_time = time.time()
|
|
86
|
-
hashrate = nonce_start / (current_time - start_time)
|
|
87
|
-
print(f"⏳ CUDA: {nonce_start:,} attempts | {hashrate:,.0f} H/s")
|
|
88
|
-
|
|
89
|
-
except Exception as e:
|
|
90
|
-
print(f"CUDA mining error: {e}")
|
|
91
|
-
|
|
92
|
-
return None
|
|
93
|
-
|
|
94
|
-
def _prepare_mining_batch(self, mining_data: Dict, nonces) -> Any:
|
|
95
|
-
"""Prepare batch mining data for GPU"""
|
|
96
|
-
mining_strings = []
|
|
97
|
-
|
|
98
|
-
for nonce in nonces:
|
|
99
|
-
mining_data["nonce"] = int(nonce)
|
|
100
|
-
data_string = json.dumps(mining_data, sort_keys=True)
|
|
101
|
-
mining_strings.append(data_string.encode())
|
|
102
|
-
|
|
103
|
-
return cp.array(mining_strings)
|
|
104
|
-
|
|
105
|
-
def _compute_hashes_gpu(self, mining_strings) -> list:
|
|
106
|
-
"""Compute SHA256 hashes on GPU"""
|
|
107
|
-
# Convert to CuPy array if needed
|
|
108
|
-
if not isinstance(mining_strings, cp.ndarray):
|
|
109
|
-
mining_strings = cp.array(mining_strings)
|
|
110
|
-
|
|
111
|
-
# This is a simplified implementation
|
|
112
|
-
# In a real implementation, you'd use proper CUDA kernels
|
|
113
|
-
hashes = []
|
|
114
|
-
for data in mining_strings:
|
|
115
|
-
# For now, fall back to CPU hashing
|
|
116
|
-
# A real implementation would use CUDA-accelerated hashing
|
|
117
|
-
hash_obj = hashlib.sha256(data.tobytes())
|
|
118
|
-
hashes.append(hash_obj.hexdigest())
|
|
119
|
-
|
|
120
|
-
return hashes
|
|
121
|
-
|
|
122
|
-
def get_cuda_info(self) -> Dict[str, Any]:
|
|
123
|
-
"""Get CUDA device information"""
|
|
124
|
-
if not self.cuda_available:
|
|
125
|
-
return {"available": False}
|
|
126
|
-
|
|
127
|
-
try:
|
|
128
|
-
props = cp.cuda.runtime.getDeviceProperties(0)
|
|
129
|
-
return {
|
|
130
|
-
"available": True,
|
|
131
|
-
"device_name": props.get('name', 'Unknown'),
|
|
132
|
-
"compute_capability": f"{props.get('major', 0)}.{props.get('minor', 0)}",
|
|
133
|
-
"total_memory": props.get('totalGlobalMem', 0),
|
|
134
|
-
"multiprocessors": props.get('multiProcessorCount', 0)
|
|
135
|
-
}
|
|
136
|
-
except Exception as e:
|
|
137
|
-
return {"available": False, "error": str(e)}
|
mining/difficulty.py
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# difficulty.py
|
|
2
|
-
class DifficultySystem:
|
|
3
|
-
"""9-tier difficulty system for mining and transactions"""
|
|
4
|
-
|
|
5
|
-
def get_bill_difficulty(self, denomination):
|
|
6
|
-
"""Get mining difficulty based on bill denomination - 9 tiers"""
|
|
7
|
-
if denomination <= 0:
|
|
8
|
-
return 1 # Handle negative/zero amounts
|
|
9
|
-
elif denomination <= 1:
|
|
10
|
-
return 1 # Trivial
|
|
11
|
-
elif denomination <= 10:
|
|
12
|
-
return 2 # Very Easy
|
|
13
|
-
elif denomination <= 100:
|
|
14
|
-
return 3 # Easy
|
|
15
|
-
elif denomination <= 1000:
|
|
16
|
-
return 4 # Moderate
|
|
17
|
-
elif denomination <= 10000:
|
|
18
|
-
return 5 # Standard
|
|
19
|
-
elif denomination <= 100000:
|
|
20
|
-
return 6 # Challenging
|
|
21
|
-
elif denomination <= 1000000:
|
|
22
|
-
return 7 # Hard
|
|
23
|
-
elif denomination <= 10000000:
|
|
24
|
-
return 8 # Very Hard
|
|
25
|
-
else:
|
|
26
|
-
return 9 # Extreme
|
|
27
|
-
|
|
28
|
-
def get_transaction_difficulty(self, amount):
|
|
29
|
-
"""Get transaction difficulty based on amount - 9 tiers"""
|
|
30
|
-
if amount <= 0:
|
|
31
|
-
return 1 # Handle negative/zero amounts
|
|
32
|
-
elif amount <= 0.001:
|
|
33
|
-
return 1 # Trivial
|
|
34
|
-
elif amount <= 0.01:
|
|
35
|
-
return 2 # Very Easy
|
|
36
|
-
elif amount <= 0.1:
|
|
37
|
-
return 3 # Easy
|
|
38
|
-
elif amount <= 1.0:
|
|
39
|
-
return 4 # Moderate
|
|
40
|
-
elif amount <= 10.0:
|
|
41
|
-
return 5 # Standard
|
|
42
|
-
elif amount <= 100.0:
|
|
43
|
-
return 6 # Challenging
|
|
44
|
-
elif amount <= 1000.0:
|
|
45
|
-
return 7 # Hard
|
|
46
|
-
elif amount <= 10000.0:
|
|
47
|
-
return 8 # Very Hard
|
|
48
|
-
else:
|
|
49
|
-
return 9 # Extreme
|
|
50
|
-
|
|
51
|
-
def calculate_mining_reward(self, denomination, mining_time):
|
|
52
|
-
"""Calculate mining reward with time-based bonus"""
|
|
53
|
-
if denomination <= 0:
|
|
54
|
-
return 0
|
|
55
|
-
|
|
56
|
-
base_reward = denomination # Full denomination as base reward
|
|
57
|
-
|
|
58
|
-
# Time bonus - faster mining gets higher reward
|
|
59
|
-
if mining_time < 10:
|
|
60
|
-
time_bonus = 0.5 # 50% bonus for very fast mining
|
|
61
|
-
elif mining_time < 30:
|
|
62
|
-
time_bonus = 0.2 # 20% bonus for fast mining
|
|
63
|
-
else:
|
|
64
|
-
time_bonus = 0.0 # No bonus for slow mining
|
|
65
|
-
|
|
66
|
-
return base_reward * (1 + time_bonus)
|
|
67
|
-
|
|
68
|
-
def get_difficulty_name(self, difficulty_level):
|
|
69
|
-
"""Get human-readable name for difficulty level"""
|
|
70
|
-
names = {
|
|
71
|
-
1: "Trivial",
|
|
72
|
-
2: "Very Easy",
|
|
73
|
-
3: "Easy",
|
|
74
|
-
4: "Moderate",
|
|
75
|
-
5: "Standard",
|
|
76
|
-
6: "Challenging",
|
|
77
|
-
7: "Hard",
|
|
78
|
-
8: "Very Hard",
|
|
79
|
-
9: "Extreme"
|
|
80
|
-
}
|
|
81
|
-
return names.get(difficulty_level, "Unknown")
|
|
82
|
-
|
|
83
|
-
def get_difficulty_color(self, difficulty_level):
|
|
84
|
-
"""Get color representation for difficulty level"""
|
|
85
|
-
colors = {
|
|
86
|
-
1: "🟢", # Green - Trivial
|
|
87
|
-
2: "🟢", # Green - Very Easy
|
|
88
|
-
3: "🟡", # Yellow - Easy
|
|
89
|
-
4: "🟡", # Yellow - Moderate
|
|
90
|
-
5: "🟠", # Orange - Standard
|
|
91
|
-
6: "🟠", # Orange - Challenging
|
|
92
|
-
7: "🔴", # Red - Hard
|
|
93
|
-
8: "🔴", # Red - Very Hard
|
|
94
|
-
9: "💀" # Skull - Extreme
|
|
95
|
-
}
|
|
96
|
-
return colors.get(difficulty_level, "⚫")
|
|
97
|
-
|
|
98
|
-
def get_expected_mining_time(self, difficulty_level, hashrate=1000000):
|
|
99
|
-
"""Get expected mining time in seconds based on difficulty and hashrate"""
|
|
100
|
-
if difficulty_level < 1 or difficulty_level > 9:
|
|
101
|
-
return float('inf')
|
|
102
|
-
|
|
103
|
-
# Rough estimate: each difficulty level increases time by ~16x
|
|
104
|
-
base_time = 0.1 # base time for difficulty 1
|
|
105
|
-
time_multiplier = 16 ** (difficulty_level - 1)
|
|
106
|
-
return base_time * time_multiplier / max(1, hashrate / 1000000)
|