lunalib 1.7.9__py3-none-any.whl → 1.8.0__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.
@@ -1,3 +1,4 @@
1
+ from tqdm import tqdm
1
2
  # blockchain.py - Updated version
2
3
 
3
4
  from ..storage.cache import BlockchainCache
@@ -267,12 +268,12 @@ class BlockchainManager:
267
268
  def get_blocks_range(self, start_height: int, end_height: int) -> List[Dict]:
268
269
  """Get range of blocks"""
269
270
  blocks = []
270
-
271
+
271
272
  # Check cache first
272
273
  cached_blocks = self.cache.get_block_range(start_height, end_height)
273
274
  if len(cached_blocks) == (end_height - start_height + 1):
274
275
  return cached_blocks
275
-
276
+
276
277
  try:
277
278
  response = requests.get(
278
279
  f'{self.endpoint_url}/blockchain/range?start={start_height}&end={end_height}',
@@ -286,15 +287,15 @@ class BlockchainManager:
286
287
  self.cache.save_block(height, block.get('hash', ''), block)
287
288
  else:
288
289
  # Fallback: get blocks individually
289
- for height in range(start_height, end_height + 1):
290
+ for height in tqdm(range(start_height, end_height + 1), desc="Get Blocks", leave=False):
290
291
  block = self.get_block(height)
291
292
  if block:
292
293
  blocks.append(block)
293
294
  time.sleep(0.01) # Be nice to the API
294
-
295
+
295
296
  except Exception as e:
296
297
  print(f"Get blocks range error: {e}")
297
-
298
+
298
299
  return blocks
299
300
 
300
301
  def get_mempool(self) -> List[Dict]:
@@ -322,22 +323,19 @@ class BlockchainManager:
322
323
  """Scan blockchain for transactions involving an address"""
323
324
  if end_height is None:
324
325
  end_height = self.get_blockchain_height()
325
-
326
+
326
327
  print(f"[SCAN] Scanning transactions for {address} from block {start_height} to {end_height}")
327
-
328
+
328
329
  transactions = []
329
-
330
- # Scan in batches for efficiency
331
330
  batch_size = 100
332
- for batch_start in range(start_height, end_height + 1, batch_size):
331
+ total_batches = ((end_height - start_height) // batch_size) + 1
332
+ for batch_start in tqdm(range(start_height, end_height + 1, batch_size), desc=f"Scan {address}", total=total_batches):
333
333
  batch_end = min(batch_start + batch_size - 1, end_height)
334
- print(f"[SCAN] Processing batch {batch_start}-{batch_end}...")
335
334
  blocks = self.get_blocks_range(batch_start, batch_end)
336
-
337
335
  for block in blocks:
338
336
  block_transactions = self._find_address_transactions(block, address)
339
337
  transactions.extend(block_transactions)
340
-
338
+
341
339
  print(f"[SCAN] Found {len(transactions)} total transactions for {address}")
342
340
  return transactions
343
341
 
@@ -389,11 +387,10 @@ class BlockchainManager:
389
387
  results: Dict[str, List[Dict]] = {addr: [] for addr in addresses}
390
388
 
391
389
  batch_size = 100
392
- for batch_start in range(start_height, end_height + 1, batch_size):
390
+ total_batches = ((end_height - start_height) // batch_size) + 1
391
+ for batch_start in tqdm(range(start_height, end_height + 1, batch_size), desc="Multi-Scan", total=total_batches):
393
392
  batch_end = min(batch_start + batch_size - 1, end_height)
394
- print(f"[MULTI-SCAN] Processing batch {batch_start}-{batch_end}...")
395
393
  blocks = self.get_blocks_range(batch_start, batch_end)
396
-
397
394
  for block in blocks:
398
395
  collected = self._collect_transactions_for_addresses(block, normalized_map)
399
396
  for original_addr, txs in collected.items():
lunalib/core/wallet.py CHANGED
@@ -493,8 +493,9 @@ class LunaWallet:
493
493
  confirmations = None
494
494
 
495
495
  if tx_type == "reward" or tx.get("from") == "network":
496
- # Only count as confirmed if confirmations >= 6
497
- if confirmations is not None and confirmations >= 6:
496
+ print(f"[DEBUG] reward tx: {tx}, confirmations={confirmations}")
497
+ # block_heightやcurrent_heightがNoneならとりあえず加算
498
+ if confirmations is None or confirmations >= 6:
498
499
  total_balance += amount
499
500
  elif direction == "incoming":
500
501
  total_balance += amount
@@ -503,6 +504,7 @@ class LunaWallet:
503
504
  total_balance -= amount
504
505
  total_balance -= fee
505
506
 
507
+ print(f"[DEBUG] computed confirmed balance: {total_balance}")
506
508
  return max(0.0, total_balance)
507
509
 
508
510
  def _compute_pending_totals(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lunalib
3
- Version: 1.7.9
3
+ Version: 1.8.0
4
4
  Summary: Cryptocurrency Ecosystem library (LunaLib)
5
5
  Home-page:
6
6
  Author: Ling Lin
@@ -4,13 +4,13 @@ lunalib/cli.py,sha256=SyuJIhvqld-XL9ks9XFOuyqVb44qyBUbahlqE_RDVkM,524
4
4
  lunalib/luna_lib.py,sha256=ue9Bs93xjpg7_GHSUJPKBhf8nF5YcbCIdoMIu-jDgG4,2748
5
5
  lunalib/__pycache__/__init__.cpython-310.pyc,sha256=7ltg-tl9NKRuAZE6SZHaS9jPUJRdoOnQcHnCxsRznGo,638
6
6
  lunalib/core/__init__.py,sha256=V86B0jI8snFIg8yCyd_Qoi2Tl6elQn_1cT-oeR6Ig3s,361
7
- lunalib/core/blockchain.py,sha256=yhK_PcyYuH5rAAbRZar-8DbF2kMWde7Ku2TOa1FIbrE,44530
7
+ lunalib/core/blockchain.py,sha256=9upZViBmDNmEk_pbjnsGy8NJKRklrOaHAcgxsw3bnRA,44524
8
8
  lunalib/core/crypto.py,sha256=R_f2sj7ASNnMW8Dtf2LIWTw-vCUjXD33zJPqPcPQVB8,10684
9
9
  lunalib/core/daemon.py,sha256=VhEky7-h-mwCBVFJp7DtoMkpvmGbdcbuoG9qNkbEvbg,21048
10
10
  lunalib/core/mempool.py,sha256=IfFvDUe6YRLefUqA3T0xx2ynnNh43x5RA-hdxAbTcMQ,14947
11
11
  lunalib/core/p2p.py,sha256=cj3dda05oL6W5oMsvJ_HT3U0qr1FL6DR-YI78k3InKg,13784
12
12
  lunalib/core/sm2.py,sha256=Eq8Er3XQW5rYJXwaPT5vw5NoVXbSWhyuvjoG1LMo-NQ,23454
13
- lunalib/core/wallet.py,sha256=HD5AtRQG2yFSlEdXorkNC0_mFOrPT3205PcPvYuT7q4,68927
13
+ lunalib/core/wallet.py,sha256=bXVwMEJabTXPp3KsJe-rA9Gvd0GjLlImjfYvtoxkEzY,69093
14
14
  lunalib/core/wallet_db.py,sha256=xhkhNbXPntHdb1tWXQJOlwxWBnWG5TVSFKUbvQM9YZg,2628
15
15
  lunalib/core/wallet_manager.py,sha256=KK58hrr_xF1vZ4qI6x_BJqrs9XXh5m0XbZYnZmi9yoU,26031
16
16
  lunalib/core/wallet_sync_helper.py,sha256=CGfSBXvf8vg4SGsLaxsjGwHVbD9dmfcuMrZ_CO0J5lE,6282
@@ -71,7 +71,7 @@ lunalib/transactions/__pycache__/__init__.cpython-310.pyc,sha256=BH0ASAygaGe0V88
71
71
  lunalib/transactions/__pycache__/security.cpython-310.pyc,sha256=MWrZ8pb-ybBPWNzmOjRvnikbX9miSN1M1o3AH8hh1DA,5380
72
72
  lunalib/transactions/__pycache__/transactions.cpython-310.pyc,sha256=Bq4g-Cg6YSg_xooorKorv_I56TZiTCJU713xaM29eWU,13242
73
73
  lunalib/transactions/__pycache__/validator.cpython-310.pyc,sha256=Vw9NJXbKCFROQx0hF5nMWN42kbBE4ilyHQrRrNkochE,2539
74
- lunalib-1.7.9.dist-info/METADATA,sha256=nD3w2UY6HcRSF90UPzvLZvrcL3dz6kGaNZBM_-1gaNA,797
75
- lunalib-1.7.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
76
- lunalib-1.7.9.dist-info/top_level.txt,sha256=eLcoOCtOwfvoqUu5g5CNBZB9bdhGXbTwmjuOM7i8ylw,8
77
- lunalib-1.7.9.dist-info/RECORD,,
74
+ lunalib-1.8.0.dist-info/METADATA,sha256=2o56WoFRyuTd4IBEOAIkXWUTOpd_UWAYT1CILCjtr8k,797
75
+ lunalib-1.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
76
+ lunalib-1.8.0.dist-info/top_level.txt,sha256=eLcoOCtOwfvoqUu5g5CNBZB9bdhGXbTwmjuOM7i8ylw,8
77
+ lunalib-1.8.0.dist-info/RECORD,,