From f70b7e691c9bcb3256e2fa32ed7c4089abfc3cbf Mon Sep 17 00:00:00 2001 From: aitbc Date: Tue, 26 May 2026 14:16:13 +0200 Subject: [PATCH] fix: restructure transaction with nested payload and proper signing - Move transaction data into nested payload object - Sign only the payload, not the entire request - Submit as {"payload": {...}, "signature": "..."} - Matches RPC server expectation for nested structure - Ensures Ed25519 signature is properly included --- cli/aitbc_cli/commands/transactions.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cli/aitbc_cli/commands/transactions.py b/cli/aitbc_cli/commands/transactions.py index 46443104..f2fe4759 100644 --- a/cli/aitbc_cli/commands/transactions.py +++ b/cli/aitbc_cli/commands/transactions.py @@ -103,22 +103,26 @@ def _send_transaction_impl(from_wallet: str, to_address: str, amount: float, fee except Exception: actual_nonce = 0 - # Create transaction - # Match RPC server schema (TransactionRequest in apps/blockchain-node/src/aitbc_chain/rpc/transactions.py) - transaction = { + # Create transaction payload + # RPC expects nested structure: {"payload": {...}, "signature": "..."} + transaction_payload = { "type": "TRANSFER", "from": sender_address, "to": to_address, "amount": int(amount), "fee": int(fee), - "nonce": actual_nonce, - "payload": {} + "nonce": actual_nonce } - # Sign transaction - message = json.dumps(transaction, sort_keys=True).encode() + # Sign transaction payload + message = json.dumps(transaction_payload, sort_keys=True).encode() signature = private_key.sign(message) - transaction["signature"] = signature.hex() + + # Submit to blockchain with nested structure + transaction = { + "payload": transaction_payload, + "signature": signature.hex() + } # Submit to blockchain try: