Skip to content

Commit c363a08

Browse files
committed
feat: add first_block to the to_json_extended method of base transaction class
1 parent 8dc9833 commit c363a08

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

hathor/transaction/base_transaction.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,14 @@ def serialize_output(tx: BaseTransaction, tx_out: TxOutput) -> dict[str, Any]:
820820
'parents': [],
821821
}
822822

823+
if not self.is_block:
824+
# A nano contract tx must be confirmed by one block at least
825+
# to be considered "executed"
826+
if meta.first_block is not None:
827+
ret['first_block'] = meta.first_block.hex()
828+
else:
829+
ret['first_block'] = None
830+
823831
for parent in self.parents:
824832
ret['parents'].append(parent.hex())
825833

hathor/transaction/resources/dashboard.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def render_GET(self, request):
152152
],
153153
'inputs': [],
154154
'outputs': [],
155-
'tokens': []
155+
'tokens': [],
156+
'first_block': None,
156157
},
157158
{
158159
'tx_id': ('00002b3be4e3876e67b5e090d76dcd71'
@@ -166,7 +167,9 @@ def render_GET(self, request):
166167
],
167168
'inputs': [],
168169
'outputs': [],
169-
'tokens': []
170+
'tokens': [],
171+
'first_block': ('000005af290a55b079014a0be3246479'
172+
'e84eeb635f02010dbf3e5f3414a85bbb')
170173
}
171174
],
172175
'blocks': [

hathor/transaction/resources/transaction.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ def get_list_tx(self, request):
465465
],
466466
'tokens': [],
467467
'height': 12345,
468+
'first_block': None
468469
},
469470
{
470471
'tx_id': ('00000b8792cb13e8adb51cc7d866541f'
@@ -496,7 +497,9 @@ def get_list_tx(self, request):
496497
'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA=='
497498
}
498499
],
499-
'tokens': []
500+
'tokens': [],
501+
'first_block': ('000005af290a55b079014a0be3246479'
502+
'e84eeb635f02010dbf3e5f3414a85bbb')
500503
}
501504
],
502505
'has_more': True

hathor/wallet/resources/thin_wallet/address_history.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,10 @@ def get_address_history(self, addresses: list[str], ref_hash: Optional[str]) ->
321321
},
322322
"token": "00"
323323
}
324-
]
325-
}
324+
],
325+
"first_block": ("000005af290a55b079014a0be3246479"
326+
"e84eeb635f02010dbf3e5f3414a85bbb")
327+
}
326328
]
327329
}
328330
},

hathor/wallet/resources/thin_wallet/token_history.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ def render_GET(self, request: Request) -> bytes:
243243
'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA=='
244244
}
245245
],
246-
'tokens': []
246+
'tokens': [],
247+
'first_block': None
247248
},
248249
{
249250
'tx_id': ('00000b8792cb13e8adb51cc7d866541f'
@@ -276,7 +277,9 @@ def render_GET(self, request: Request) -> bytes:
276277
'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA=='
277278
}
278279
],
279-
'tokens': []
280+
'tokens': [],
281+
'first_block': ('000005af290a55b079014a0be3246479'
282+
'e84eeb635f02010dbf3e5f3414a85bbb')
280283
}
281284
],
282285
'has_more': True

0 commit comments

Comments
 (0)