diff --git a/hathor/transaction/base_transaction.py b/hathor/transaction/base_transaction.py index 79104f3d5..68d94ead2 100644 --- a/hathor/transaction/base_transaction.py +++ b/hathor/transaction/base_transaction.py @@ -820,6 +820,13 @@ def serialize_output(tx: BaseTransaction, tx_out: TxOutput) -> dict[str, Any]: 'parents': [], } + # A nano contract tx must be confirmed by one block at least + # to be considered "executed" + if meta.first_block is not None: + ret['first_block'] = meta.first_block.hex() + else: + ret['first_block'] = None + for parent in self.parents: ret['parents'].append(parent.hex()) diff --git a/hathor/transaction/resources/dashboard.py b/hathor/transaction/resources/dashboard.py index 47f366a8e..07add5d21 100644 --- a/hathor/transaction/resources/dashboard.py +++ b/hathor/transaction/resources/dashboard.py @@ -152,7 +152,8 @@ def render_GET(self, request): ], 'inputs': [], 'outputs': [], - 'tokens': [] + 'tokens': [], + 'first_block': None, }, { 'tx_id': ('00002b3be4e3876e67b5e090d76dcd71' @@ -166,7 +167,9 @@ def render_GET(self, request): ], 'inputs': [], 'outputs': [], - 'tokens': [] + 'tokens': [], + 'first_block': ('000005af290a55b079014a0be3246479' + 'e84eeb635f02010dbf3e5f3414a85bbb') } ], 'blocks': [ @@ -189,7 +192,9 @@ def render_GET(self, request): 'script': 'dqkUixvdsajkV6vO+9Jjgjbaheqn016IrA==' } ], - 'tokens': [] + 'tokens': [], + 'first_block': ('000005af290a55b079014a0be3246479' + 'e84eeb635f02010dbf3e5f3414a85bbb') }, { 'tx_id': ('00035e46a20d0ecbda0dc6fdcaa243e9' @@ -210,7 +215,9 @@ def render_GET(self, request): 'script': 'dqkUdNQbj29Md1xsAYinK+RsDJCCB7eIrA==' } ], - 'tokens': [] + 'tokens': [], + 'first_block': ('000005af290a55b079014a0be3246479' + 'e84eeb635f02010dbf3e5f3414a85bbb') }, { 'tx_id': ('000133cc80b625b1babbd454edc3474e' @@ -231,7 +238,8 @@ def render_GET(self, request): 'script': 'dqkU0AoLEAX+1b36s+VyaMc9bkj/5byIrA==' } ], - 'tokens': [] + 'tokens': [], + 'first_block': None } ] } diff --git a/hathor/transaction/resources/transaction.py b/hathor/transaction/resources/transaction.py index 796030c0d..816185438 100644 --- a/hathor/transaction/resources/transaction.py +++ b/hathor/transaction/resources/transaction.py @@ -465,6 +465,7 @@ def get_list_tx(self, request): ], 'tokens': [], 'height': 12345, + 'first_block': None }, { 'tx_id': ('00000b8792cb13e8adb51cc7d866541f' @@ -496,7 +497,9 @@ def get_list_tx(self, request): 'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA==' } ], - 'tokens': [] + 'tokens': [], + 'first_block': ('000005af290a55b079014a0be3246479' + 'e84eeb635f02010dbf3e5f3414a85bbb') } ], 'has_more': True diff --git a/hathor/wallet/resources/thin_wallet/address_history.py b/hathor/wallet/resources/thin_wallet/address_history.py index 044494bb0..e7e231e71 100644 --- a/hathor/wallet/resources/thin_wallet/address_history.py +++ b/hathor/wallet/resources/thin_wallet/address_history.py @@ -321,8 +321,10 @@ def get_address_history(self, addresses: list[str], ref_hash: Optional[str]) -> }, "token": "00" } - ] - } + ], + "first_block": ("000005af290a55b079014a0be3246479" + "e84eeb635f02010dbf3e5f3414a85bbb") + } ] } }, diff --git a/hathor/wallet/resources/thin_wallet/token_history.py b/hathor/wallet/resources/thin_wallet/token_history.py index a68cf4077..603a6c7f6 100644 --- a/hathor/wallet/resources/thin_wallet/token_history.py +++ b/hathor/wallet/resources/thin_wallet/token_history.py @@ -243,7 +243,8 @@ def render_GET(self, request: Request) -> bytes: 'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA==' } ], - 'tokens': [] + 'tokens': [], + 'first_block': None }, { 'tx_id': ('00000b8792cb13e8adb51cc7d866541f' @@ -276,7 +277,9 @@ def render_GET(self, request: Request) -> bytes: 'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA==' } ], - 'tokens': [] + 'tokens': [], + 'first_block': ('000005af290a55b079014a0be3246479' + 'e84eeb635f02010dbf3e5f3414a85bbb') } ], 'has_more': True