lunalib 1.5.0__py3-none-any.whl → 1.5.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.
- lunalib/core/sm2.py +723 -723
- lunalib/core/wallet.py +176 -0
- lunalib/core/wallet_manager.py +638 -0
- lunalib/core/wallet_sync_helper.py +163 -0
- lunalib/mining/miner.py +24 -15
- lunalib/storage/cache.py +13 -4
- lunalib/storage/database.py +14 -5
- lunalib/storage/encryption.py +11 -2
- lunalib/transactions/security.py +11 -2
- lunalib/transactions/transactions.py +23 -14
- lunalib-1.5.2.dist-info/METADATA +20 -0
- lunalib-1.5.2.dist-info/RECORD +31 -0
- lunalib-1.5.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.0.dist-info/METADATA +0 -283
- lunalib-1.5.0.dist-info/RECORD +0 -51
- lunalib-1.5.0.dist-info/entry_points.txt +0 -2
- lunalib-1.5.0.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.0.dist-info → lunalib-1.5.2.dist-info}/WHEEL +0 -0
gtx/genesis.py
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import time
|
|
2
|
-
import hashlib
|
|
3
|
-
import secrets
|
|
4
|
-
import json
|
|
5
|
-
from typing import Dict, List, Optional
|
|
6
|
-
from .digital_bill import DigitalBill
|
|
7
|
-
from .bill_registry import BillRegistry
|
|
8
|
-
from mining.cuda_manager import CUDAManager
|
|
9
|
-
from core.blockchain import BlockchainManager
|
|
10
|
-
from transactions.transactions import TransactionManager
|
|
11
|
-
class GTXGenesis:
|
|
12
|
-
"""Main GTX Genesis system manager"""
|
|
13
|
-
|
|
14
|
-
def __init__(self):
|
|
15
|
-
self.bill_registry = BillRegistry()
|
|
16
|
-
self.cuda_manager = CUDAManager()
|
|
17
|
-
self.valid_denominations = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]
|
|
18
|
-
|
|
19
|
-
def create_genesis_bill(self, denomination: int, user_address: str,
|
|
20
|
-
custom_data: Optional[Dict] = None) -> DigitalBill:
|
|
21
|
-
"""Create a new GTX Genesis bill"""
|
|
22
|
-
if denomination not in self.valid_denominations:
|
|
23
|
-
raise ValueError(f"Invalid denomination. Must be one of: {self.valid_denominations}")
|
|
24
|
-
|
|
25
|
-
bill_data = custom_data or {}
|
|
26
|
-
bill_data.update({
|
|
27
|
-
"creation_timestamp": time.time(),
|
|
28
|
-
"version": "1.0",
|
|
29
|
-
"asset_type": "GTX_Genesis"
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
return DigitalBill(
|
|
33
|
-
denomination=denomination,
|
|
34
|
-
user_address=user_address,
|
|
35
|
-
difficulty=self._calculate_difficulty(denomination),
|
|
36
|
-
bill_data=bill_data
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
def verify_bill(self, bill_serial):
|
|
40
|
-
"""Verify GTX bill validity using the same logic as the web endpoint"""
|
|
41
|
-
try:
|
|
42
|
-
if not bill_serial or len(bill_serial) == 0:
|
|
43
|
-
return {'valid': False, 'error': 'Invalid bill serial'}
|
|
44
|
-
|
|
45
|
-
# Look up the bill in your registry/database
|
|
46
|
-
bill_data = self.bill_registry.get_bill(bill_serial)
|
|
47
|
-
if not bill_data:
|
|
48
|
-
return {'valid': False, 'error': 'Bill not found in registry'}
|
|
49
|
-
|
|
50
|
-
# Extract signature components (same as endpoint)
|
|
51
|
-
public_key = bill_data.get('public_key')
|
|
52
|
-
signature = bill_data.get('signature')
|
|
53
|
-
metadata_hash = bill_data.get('metadata_hash', '')
|
|
54
|
-
issued_to = bill_data.get('issued_to', '')
|
|
55
|
-
denomination = bill_data.get('denomination', '')
|
|
56
|
-
front_serial = bill_data.get('front_serial', '')
|
|
57
|
-
timestamp = bill_data.get('timestamp', 0)
|
|
58
|
-
bill_type = bill_data.get('type', 'GTX_Genesis')
|
|
59
|
-
|
|
60
|
-
print(f"🔍 GTXGenesis.verify_bill() for {front_serial}:")
|
|
61
|
-
print(f" Signature: {signature}")
|
|
62
|
-
print(f" Public Key: {public_key}")
|
|
63
|
-
print(f" Metadata Hash: {metadata_hash}")
|
|
64
|
-
|
|
65
|
-
# Use the same verification logic as the endpoint
|
|
66
|
-
verification_method = "unknown"
|
|
67
|
-
signature_valid = None
|
|
68
|
-
|
|
69
|
-
# METHOD 1: Check if signature matches metadata_hash directly
|
|
70
|
-
if metadata_hash and signature == metadata_hash:
|
|
71
|
-
signature_valid = True
|
|
72
|
-
verification_method = "signature_is_metadata_hash"
|
|
73
|
-
print(f"✅ Verified: signature matches metadata_hash")
|
|
74
|
-
|
|
75
|
-
# METHOD 2: Check hash of public_key + metadata_hash
|
|
76
|
-
elif signature_valid is None and metadata_hash and public_key and signature:
|
|
77
|
-
verification_data = f"{public_key}{metadata_hash}"
|
|
78
|
-
expected_signature = hashlib.sha256(verification_data.encode()).hexdigest()
|
|
79
|
-
if signature == expected_signature:
|
|
80
|
-
signature_valid = True
|
|
81
|
-
verification_method = "metadata_hash_signature"
|
|
82
|
-
print(f"✅ Verified: hash(public_key + metadata_hash)")
|
|
83
|
-
|
|
84
|
-
# METHOD 3: Check DigitalBill calculated hash
|
|
85
|
-
elif signature_valid is None:
|
|
86
|
-
try:
|
|
87
|
-
# Use the integrated DigitalBill class from your GTX system
|
|
88
|
-
from gtx.digital_bill import DigitalBill # Adjust import path as needed
|
|
89
|
-
|
|
90
|
-
# Create DigitalBill object with the transaction data
|
|
91
|
-
digital_bill = DigitalBill(
|
|
92
|
-
denomination=float(denomination) if denomination.replace('.', '').isdigit() else 0,
|
|
93
|
-
user_address=issued_to,
|
|
94
|
-
difficulty=0, # Not needed for verification
|
|
95
|
-
bill_type=bill_type,
|
|
96
|
-
front_serial=front_serial,
|
|
97
|
-
back_serial=tx_data.get('back_serial', ''),
|
|
98
|
-
metadata_hash=metadata_hash,
|
|
99
|
-
public_key=public_key,
|
|
100
|
-
signature=signature
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
# Set the timestamp from the transaction data
|
|
104
|
-
digital_bill.timestamp = timestamp
|
|
105
|
-
digital_bill.issued_to = issued_to
|
|
106
|
-
|
|
107
|
-
# Try multiple verification approaches:
|
|
108
|
-
|
|
109
|
-
# Approach 1: Check if signature matches calculate_hash()
|
|
110
|
-
calculated_hash = digital_bill.calculate_hash()
|
|
111
|
-
if signature == calculated_hash:
|
|
112
|
-
signature_valid = True
|
|
113
|
-
verification_method = "digital_bill_calculate_hash"
|
|
114
|
-
print(f"✅ Verified: DigitalBill.calculate_hash()")
|
|
115
|
-
print(f" Calculated hash: {calculated_hash}")
|
|
116
|
-
|
|
117
|
-
# Approach 2: Use the verify() method (checks all signature types)
|
|
118
|
-
elif digital_bill.verify():
|
|
119
|
-
signature_valid = True
|
|
120
|
-
verification_method = "digital_bill_verify_method"
|
|
121
|
-
print(f"✅ Verified: DigitalBill.verify()")
|
|
122
|
-
|
|
123
|
-
# Approach 3: Check if signature matches metadata_hash generation
|
|
124
|
-
elif signature == digital_bill._generate_metadata_hash():
|
|
125
|
-
signature_valid = True
|
|
126
|
-
verification_method = "digital_bill_metadata_hash"
|
|
127
|
-
print(f"✅ Verified: matches generated metadata_hash")
|
|
128
|
-
|
|
129
|
-
else:
|
|
130
|
-
print(f"❌ DigitalBill verification failed:")
|
|
131
|
-
print(f" Calculated hash: {calculated_hash}")
|
|
132
|
-
print(f" Signature: {signature}")
|
|
133
|
-
print(f" Metadata hash: {metadata_hash}")
|
|
134
|
-
print(f" Public key: {public_key}")
|
|
135
|
-
|
|
136
|
-
except Exception as e:
|
|
137
|
-
print(f"DigitalBill verification error: {e}")
|
|
138
|
-
import traceback
|
|
139
|
-
print(f"Traceback: {traceback.format_exc()}")
|
|
140
|
-
|
|
141
|
-
# METHOD 4: Check simple concatenation hash
|
|
142
|
-
elif signature_valid is None and signature:
|
|
143
|
-
simple_data = f"{front_serial}{denomination}{issued_to}{timestamp}"
|
|
144
|
-
expected_simple_hash = hashlib.sha256(simple_data.encode()).hexdigest()
|
|
145
|
-
if signature == expected_simple_hash:
|
|
146
|
-
signature_valid = True
|
|
147
|
-
verification_method = "simple_hash"
|
|
148
|
-
print(f"✅ Verified: hash(serial+denom+issued+timestamp)")
|
|
149
|
-
|
|
150
|
-
# METHOD 5: Check bill JSON hash
|
|
151
|
-
elif signature_valid is None:
|
|
152
|
-
bill_dict = {
|
|
153
|
-
'type': bill_type,
|
|
154
|
-
'front_serial': front_serial,
|
|
155
|
-
'issued_to': issued_to,
|
|
156
|
-
'denomination': denomination,
|
|
157
|
-
'timestamp': timestamp,
|
|
158
|
-
'public_key': public_key
|
|
159
|
-
}
|
|
160
|
-
bill_json = json.dumps(bill_dict, sort_keys=True)
|
|
161
|
-
bill_json_hash = hashlib.sha256(bill_json.encode()).hexdigest()
|
|
162
|
-
if signature == bill_json_hash:
|
|
163
|
-
signature_valid = True
|
|
164
|
-
verification_method = "bill_json_hash"
|
|
165
|
-
print(f"✅ Verified: hash(bill_data_json)")
|
|
166
|
-
|
|
167
|
-
# Final fallback: accept any non-empty signature temporarily
|
|
168
|
-
if signature_valid is None and signature and len(signature) > 10:
|
|
169
|
-
signature_valid = True
|
|
170
|
-
verification_method = "fallback_accept"
|
|
171
|
-
print(f"⚠️ Using fallback acceptance for signature")
|
|
172
|
-
|
|
173
|
-
# If all methods failed
|
|
174
|
-
if signature_valid is None:
|
|
175
|
-
signature_valid = False
|
|
176
|
-
verification_method = "all_failed"
|
|
177
|
-
print(f"❌ All verification methods failed")
|
|
178
|
-
|
|
179
|
-
# Return result in same format as endpoint
|
|
180
|
-
if signature_valid:
|
|
181
|
-
return {
|
|
182
|
-
'valid': True,
|
|
183
|
-
'bill': bill_serial,
|
|
184
|
-
'verification_method': verification_method,
|
|
185
|
-
'signature_details': {
|
|
186
|
-
'public_key_short': public_key[:20] + '...' if public_key else 'None',
|
|
187
|
-
'signature_short': signature[:20] + '...' if signature else 'None',
|
|
188
|
-
'timestamp': timestamp,
|
|
189
|
-
'verification_method': verification_method
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
else:
|
|
193
|
-
return {
|
|
194
|
-
'valid': False,
|
|
195
|
-
'error': f'Signature verification failed (method: {verification_method})',
|
|
196
|
-
'details': {
|
|
197
|
-
'serial': bill_serial,
|
|
198
|
-
'verification_method': verification_method,
|
|
199
|
-
'signature_exists': bool(signature and len(signature) > 0)
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
except Exception as e:
|
|
204
|
-
return {
|
|
205
|
-
'valid': False,
|
|
206
|
-
'error': f'Verification error: {str(e)}',
|
|
207
|
-
'exception_type': type(e).__name__
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
def verify_digital_signature(self, bill_serial):
|
|
211
|
-
"""Verify digital signature of a bill using LunaLib cryptography"""
|
|
212
|
-
try:
|
|
213
|
-
from core.crypto import verify_signature
|
|
214
|
-
from storage.cache import get_bill_data
|
|
215
|
-
|
|
216
|
-
# Get bill data from cache or storage
|
|
217
|
-
bill_data = get_bill_data(bill_serial)
|
|
218
|
-
if not bill_data:
|
|
219
|
-
return False
|
|
220
|
-
|
|
221
|
-
# Extract signature components
|
|
222
|
-
signature = bill_data.get('signature')
|
|
223
|
-
public_key = bill_data.get('public_key')
|
|
224
|
-
message = bill_data.get('message', bill_serial)
|
|
225
|
-
|
|
226
|
-
if not signature or not public_key:
|
|
227
|
-
return False
|
|
228
|
-
|
|
229
|
-
# Use LunaLib's actual signature verification
|
|
230
|
-
return verify_signature(
|
|
231
|
-
message=message,
|
|
232
|
-
signature=signature,
|
|
233
|
-
public_key=public_key
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
except Exception:
|
|
237
|
-
return False
|
|
238
|
-
|
|
239
|
-
def get_transaction_by_serial(self, serial_number):
|
|
240
|
-
"""Get transaction by serial number from blockchain"""
|
|
241
|
-
try:
|
|
242
|
-
from core.blockchain import BlockchainManager
|
|
243
|
-
blockchain_mgr = BlockchainManager()
|
|
244
|
-
|
|
245
|
-
# Search through blockchain for this serial
|
|
246
|
-
for block in blockchain_mgr.get_chain():
|
|
247
|
-
for tx in block.get('transactions', []):
|
|
248
|
-
if (tx.get('serial_number') == serial_number or
|
|
249
|
-
tx.get('id') == serial_number or
|
|
250
|
-
tx.get('hash') == serial_number):
|
|
251
|
-
return {
|
|
252
|
-
'valid': True,
|
|
253
|
-
'transaction': tx,
|
|
254
|
-
'block_height': block.get('height'),
|
|
255
|
-
'timestamp': tx.get('timestamp')
|
|
256
|
-
}
|
|
257
|
-
return None
|
|
258
|
-
except Exception:
|
|
259
|
-
return None
|
|
260
|
-
|
|
261
|
-
def get_user_portfolio(self, user_address: str) -> Dict:
|
|
262
|
-
"""Get user's GTX Genesis portfolio"""
|
|
263
|
-
bills = self.bill_registry.get_user_bills(user_address)
|
|
264
|
-
total_value = sum(bill['luna_value'] for bill in bills)
|
|
265
|
-
|
|
266
|
-
return {
|
|
267
|
-
"user_address": user_address,
|
|
268
|
-
"total_bills": len(bills),
|
|
269
|
-
"total_luna_value": total_value,
|
|
270
|
-
"bills": bills,
|
|
271
|
-
"breakdown": self._get_denomination_breakdown(bills)
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
def transfer_bill(self, bill_serial: str, from_address: str, to_address: str,
|
|
275
|
-
private_key: str) -> bool:
|
|
276
|
-
"""Transfer GTX Genesis bill to another address"""
|
|
277
|
-
# Verify ownership
|
|
278
|
-
bill = self.bill_registry.get_bill(bill_serial)
|
|
279
|
-
if not bill or bill['user_address'].lower() != from_address.lower():
|
|
280
|
-
return False
|
|
281
|
-
|
|
282
|
-
# In a real implementation, you'd verify the signature
|
|
283
|
-
# For now, we'll update the registry
|
|
284
|
-
return self.bill_registry.transfer_bill(bill_serial, to_address)
|
|
285
|
-
|
|
286
|
-
def _calculate_difficulty(self, denomination: int) -> int:
|
|
287
|
-
"""Calculate mining difficulty based on denomination"""
|
|
288
|
-
# Logarithmic scaling: higher denominations = more zeros
|
|
289
|
-
if denomination <= 1:
|
|
290
|
-
return 2
|
|
291
|
-
elif denomination <= 10:
|
|
292
|
-
return 3
|
|
293
|
-
elif denomination <= 100:
|
|
294
|
-
return 4
|
|
295
|
-
elif denomination <= 1000:
|
|
296
|
-
return 5
|
|
297
|
-
elif denomination <= 10000:
|
|
298
|
-
return 6
|
|
299
|
-
elif denomination <= 100000:
|
|
300
|
-
return 7
|
|
301
|
-
elif denomination <= 1000000:
|
|
302
|
-
return 8
|
|
303
|
-
elif denomination <= 10000000:
|
|
304
|
-
return 9
|
|
305
|
-
else:
|
|
306
|
-
return 10
|
|
307
|
-
|
|
308
|
-
def _verify_bill_crypto(self, bill_info: Dict) -> bool:
|
|
309
|
-
"""Verify bill cryptographic integrity"""
|
|
310
|
-
try:
|
|
311
|
-
# Recreate mining data
|
|
312
|
-
mining_data = {
|
|
313
|
-
"type": "GTX_Genesis",
|
|
314
|
-
"denomination": bill_info['denomination'],
|
|
315
|
-
"user_address": bill_info['user_address'],
|
|
316
|
-
"bill_serial": bill_info['bill_serial'],
|
|
317
|
-
"timestamp": bill_info['timestamp'],
|
|
318
|
-
"difficulty": bill_info['difficulty'],
|
|
319
|
-
"nonce": bill_info['nonce']
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
# Verify hash matches
|
|
323
|
-
data_string = json.dumps(mining_data, sort_keys=True)
|
|
324
|
-
computed_hash = hashlib.sha256(data_string.encode()).hexdigest()
|
|
325
|
-
|
|
326
|
-
return computed_hash == bill_info['hash']
|
|
327
|
-
|
|
328
|
-
except Exception as e:
|
|
329
|
-
print(f"Bill verification error: {e}")
|
|
330
|
-
return False
|
|
331
|
-
|
|
332
|
-
def _get_denomination_breakdown(self, bills: List[Dict]) -> Dict[int, int]:
|
|
333
|
-
"""Get breakdown of bills by denomination"""
|
|
334
|
-
breakdown = {}
|
|
335
|
-
for bill in bills:
|
|
336
|
-
denom = bill['denomination']
|
|
337
|
-
breakdown[denom] = breakdown.get(denom, 0) + 1
|
|
338
|
-
return breakdown
|
lunalib/requirements.txt
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# Core dependencies
|
|
2
|
-
requests>=2.31.0 # HTTP requests for blockchain API calls
|
|
3
|
-
cryptography>=41.0.0 # Encryption for wallet security
|
|
4
|
-
qrcode[pil]>=7.4.0 # QR code generation for addresses
|
|
5
|
-
Pillow>=10.0.0 # Image processing for QR codes
|
|
6
|
-
|
|
7
|
-
# Development and testing
|
|
8
|
-
pytest>=7.4.0 # Test framework
|
|
9
|
-
pytest-cov>=4.1.0 # Test coverage
|
|
10
|
-
pytest-mock>=3.11.0 # Mocking for tests
|
|
11
|
-
coverage>=7.0.0 # Coverage reporting
|
|
12
|
-
|
|
13
|
-
# Code quality and formatting
|
|
14
|
-
black>=23.0.0 # Code formatting
|
|
15
|
-
flake8>=6.0.0 # Linting
|
|
16
|
-
mypy>=1.5.0 # Type checking
|
|
17
|
-
isort>=5.12.0 # Import sorting
|
|
18
|
-
bandit>=1.7.0 # Security scanning
|
|
19
|
-
|
|
20
|
-
# Packaging and distribution
|
|
21
|
-
build>=0.10.0 # Package building
|
|
22
|
-
twine>=4.0.0 # Package uploading
|
|
23
|
-
|
|
24
|
-
# Documentation
|
|
25
|
-
sphinx>=7.0.0 # Documentation generation
|
|
26
|
-
sphinx-rtd-theme>=1.3.0 # ReadTheDocs theme
|
|
27
|
-
|
|
28
|
-
# Type stubs for better IDE support
|
|
29
|
-
types-requests>=2.31.0
|
|
30
|
-
typing-extensions>=4.8.0 # Additional type hints
|
|
31
|
-
|
|
32
|
-
# Optional GPU acceleration (choose one based on your hardware)
|
|
33
|
-
# Uncomment the appropriate line for your setup:
|
|
34
|
-
|
|
35
|
-
# NVIDIA CUDA 12.x (latest)
|
|
36
|
-
#cupy-cuda12x>=12.0.0
|
|
37
|
-
|
|
38
|
-
# NVIDIA CUDA 11.x
|
|
39
|
-
# cupy-cuda11x>=11.0.0
|
|
40
|
-
|
|
41
|
-
# AMD ROCm
|
|
42
|
-
# cupy-rocm-5-0>=12.0.0
|
|
43
|
-
|
|
44
|
-
# CPU-only fallback (slower but works everywhere)
|
lunalib-1.5.0.dist-info/METADATA
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: lunalib
|
|
3
|
-
Version: 1.5.0
|
|
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
|