fix: move transaction fields to top level (not nested in payload)
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
CLI Tests / test-cli (push) Has been cancelled

- 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
This commit is contained in:
aitbc
2026-05-26 14:44:00 +02:00
parent 8ad9f6c425
commit 755d5bdeaf

View File

@@ -104,25 +104,21 @@ def _send_transaction_impl(from_wallet: str, to_address: str, amount: float, fee
actual_nonce = 0 actual_nonce = 0
# Create transaction payload # Create transaction payload
# RPC expects nested structure: {"payload": {...}, "signature": "..."} # RPC expects all fields at top level, with payload as additional free-form object
transaction_payload = { transaction = {
"type": "TRANSFER",
"from": sender_address, "from": sender_address,
"to": to_address, "to": to_address,
"amount": int(amount), "amount": int(amount),
"fee": int(fee), "fee": int(fee),
"nonce": actual_nonce "nonce": actual_nonce,
"type": "TRANSFER",
"payload": {}
} }
# Sign transaction payload # Sign transaction
message = json.dumps(transaction_payload, sort_keys=True).encode() message = json.dumps(transaction, sort_keys=True).encode()
signature = private_key.sign(message) # cryptography library returns just signature bytes signature = private_key.sign(message) # cryptography library returns just signature bytes
transaction["signature"] = signature.hex()
# Submit to blockchain with nested structure
transaction = {
"payload": transaction_payload,
"signature": signature.hex()
}
# Submit to blockchain # Submit to blockchain
try: try: