@@ -385,7 +385,7 @@ def get_last_block(ledger_db):
385
385
)
386
386
387
387
388
- def prepare_transactions_where (type , other_conditions = None ):
388
+ def prepare_transactions_where (type , other_conditions = None , show_unconfirmed = False ):
389
389
where = []
390
390
type_list = type .split ("," )
391
391
for transaction_type in type_list :
@@ -397,19 +397,24 @@ def prepare_transactions_where(type, other_conditions=None):
397
397
if other_conditions :
398
398
where_status .update (other_conditions )
399
399
where .append (where_status )
400
+ if not show_unconfirmed :
401
+ for cond in where :
402
+ cond ["confirmed" ] = True
400
403
return where
401
404
402
405
403
406
def get_transactions (
404
407
ledger_db ,
405
408
type : TransactionType = "all" ,
409
+ show_unconfirmed : bool = False ,
406
410
cursor : str = None ,
407
411
limit : int = 10 ,
408
412
offset : int = None ,
409
413
):
410
414
"""
411
415
Returns the list of the last ten transactions
412
416
:param str type: The type of the transaction to return
417
+ :param bool show_unconfirmed: Show unconfirmed transactions
413
418
:param str cursor: The index of the most recent transactions to return (e.g. $LAST_TX_INDEX)
414
419
:param int limit: The number of transactions to return (e.g. 2)
415
420
:param int offset: The number of lines to skip before returning results (overrides the `cursor` parameter)
@@ -421,14 +426,15 @@ def get_transactions(
421
426
last_cursor = cursor ,
422
427
limit = limit ,
423
428
offset = offset ,
424
- where = prepare_transactions_where (type ),
429
+ where = prepare_transactions_where (type , show_unconfirmed = show_unconfirmed ),
425
430
)
426
431
427
432
428
433
def get_transactions_by_block (
429
434
ledger_db ,
430
435
block_index : int ,
431
436
type : TransactionType = "all" ,
437
+ show_unconfirmed : bool = False ,
432
438
cursor : str = None ,
433
439
limit : int = 10 ,
434
440
offset : int = None ,
@@ -437,6 +443,7 @@ def get_transactions_by_block(
437
443
Returns the transactions of a block
438
444
:param int block_index: The index of the block to return (e.g. $LAST_BLOCK_INDEX)
439
445
:param str type: The type of the transaction to return
446
+ :param bool show_unconfirmed: Show unconfirmed transactions
440
447
:param str cursor: The last transaction index to return (e.g. $LAST_TX_INDEX)
441
448
:param int limit: The maximum number of transactions to return (e.g. 5)
442
449
:param int offset: The number of lines to skip before returning results (overrides the `cursor` parameter)
@@ -445,7 +452,7 @@ def get_transactions_by_block(
445
452
return select_rows (
446
453
ledger_db ,
447
454
"transactions" ,
448
- where = prepare_transactions_where (type , where ),
455
+ where = prepare_transactions_where (type , where , show_unconfirmed = show_unconfirmed ),
449
456
cursor_field = "tx_index" ,
450
457
last_cursor = cursor ,
451
458
limit = limit ,
@@ -457,6 +464,7 @@ def get_transactions_by_address(
457
464
ledger_db ,
458
465
address : str ,
459
466
type : TransactionType = "all" ,
467
+ show_unconfirmed : bool = False ,
460
468
cursor : str = None ,
461
469
limit : int = 10 ,
462
470
offset : int = None ,
@@ -465,6 +473,7 @@ def get_transactions_by_address(
465
473
Returns the transactions of an address
466
474
:param str address: The address to return (e.g. $ADDRESS_1)
467
475
:param str type: The type of the transaction to return
476
+ :param bool show_unconfirmed: Show unconfirmed transactions
468
477
:param str cursor: The last transaction index to return (e.g. $LAST_TX_INDEX)
469
478
:param int limit: The maximum number of transactions to return (e.g. 5)
470
479
:param int offset: The number of lines to skip before returning results (overrides the `cursor` parameter)
@@ -473,7 +482,7 @@ def get_transactions_by_address(
473
482
return select_rows (
474
483
ledger_db ,
475
484
"transactions" ,
476
- where = prepare_transactions_where (type , where ),
485
+ where = prepare_transactions_where (type , where , show_unconfirmed = show_unconfirmed ),
477
486
cursor_field = "tx_index" ,
478
487
last_cursor = cursor ,
479
488
limit = limit ,
@@ -485,6 +494,7 @@ def get_transactions_by_addresses(
485
494
ledger_db ,
486
495
addresses : str ,
487
496
type : TransactionType = "all" ,
497
+ show_unconfirmed : bool = False ,
488
498
cursor : str = None ,
489
499
limit : int = 100 ,
490
500
offset : int = None ,
@@ -493,6 +503,7 @@ def get_transactions_by_addresses(
493
503
Returns the transactions of a list of addresses
494
504
:param str addresses: Comma separated list of addresses to return (e.g. $ADDRESS_1,$ADDRESS_2)
495
505
:param str type: The type of the transaction to return
506
+ :param bool show_unconfirmed: Show unconfirmed transactions
496
507
:param str cursor: The last transaction index to return (e.g. $LAST_TX_INDEX)
497
508
:param int limit: The maximum number of transactions to return (e.g. 5)
498
509
:param int offset: The number of lines to skip before returning results (overrides the `cursor` parameter)
@@ -501,7 +512,7 @@ def get_transactions_by_addresses(
501
512
return select_rows (
502
513
ledger_db ,
503
514
"transactions" ,
504
- where = prepare_transactions_where (type , where ),
515
+ where = prepare_transactions_where (type , where , show_unconfirmed = show_unconfirmed ),
505
516
cursor_field = "tx_index" ,
506
517
last_cursor = cursor ,
507
518
limit = limit ,
0 commit comments