From 755d5bdeaf21adadac566183707c814909451564 Mon Sep 17 00:00:00 2001 From: aitbc Date: Tue, 26 May 2026 14:44:00 +0200 Subject: [PATCH] fix: move transaction fields to top level (not nested in payload) - RPC expects from, to, amount, fee, nonce, type, signature at top level - Payload is additional free-form object, not container for all fields - Fixes validation error: missing field 'from' at body level - Matches TransactionRequest OpenAPI schema --- cli/aitbc_cli/commands/transactions.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/cli/aitbc_cli/commands/transactions.py b/cli/aitbc_cli/commands/transactions.py index 05851fe9..9f00a716 100644 --- a/cli/aitbc_cli/commands/transactions.py +++ b/cli/aitbc_cli/commands/transactions.py @@ -104,25 +104,21 @@ def _send_transaction_impl(from_wallet: str, to_address: str, amount: float, fee actual_nonce = 0 # Create transaction payload - # RPC expects nested structure: {"payload": {...}, "signature": "..."} - transaction_payload = { - "type": "TRANSFER", + # RPC expects all fields at top level, with payload as additional free-form object + transaction = { "from": sender_address, "to": to_address, "amount": int(amount), "fee": int(fee), - "nonce": actual_nonce + "nonce": actual_nonce, + "type": "TRANSFER", + "payload": {} } - # Sign transaction payload - message = json.dumps(transaction_payload, sort_keys=True).encode() + # Sign transaction + message = json.dumps(transaction, sort_keys=True).encode() signature = private_key.sign(message) # cryptography library returns just signature bytes - - # Submit to blockchain with nested structure - transaction = { - "payload": transaction_payload, - "signature": signature.hex() - } + transaction["signature"] = signature.hex() # Submit to blockchain try: