From 6a3648d33cf83c7b2557e570f82e8bafe8208e87 Mon Sep 17 00:00:00 2001 From: aitbc Date: Tue, 28 Apr 2026 13:49:07 +0200 Subject: [PATCH] fix: add validation to require 'to' field for TRANSFER transactions --- apps/blockchain-node/src/aitbc_chain/rpc/router.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/blockchain-node/src/aitbc_chain/rpc/router.py b/apps/blockchain-node/src/aitbc_chain/rpc/router.py index bbec95ba..f61a6891 100755 --- a/apps/blockchain-node/src/aitbc_chain/rpc/router.py +++ b/apps/blockchain-node/src/aitbc_chain/rpc/router.py @@ -220,12 +220,11 @@ class TransactionRequest(BaseModel): if normalized not in valid_types: raise ValueError(f"unsupported transaction type: {normalized}. Valid types: {valid_types}") self.type = normalized - return self - - @model_validator(mode="after") - def validate_transfer_fields(self) -> "TransactionRequest": # type: ignore[override] + + # Require 'to' field for TRANSFER transactions if self.type == "TRANSFER" and not self.to: - raise ValueError("transaction.to is required for TRANSFER transactions") + raise ValueError("'to' field is required for TRANSFER transactions") + return self