fix: prioritize top-level value field over payload.amount in transaction submission
Some checks failed
Integration Tests / test-service-integration (push) Waiting to run
Blockchain Synchronization Verification / sync-verification (push) Failing after 10s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 6s
P2P Network Verification / p2p-verification (push) Successful in 1s
Python Tests / test-python (push) Failing after 9s
Security Scanning / security-scan (push) Successful in 1m48s
Some checks failed
Integration Tests / test-service-integration (push) Waiting to run
Blockchain Synchronization Verification / sync-verification (push) Failing after 10s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 6s
P2P Network Verification / p2p-verification (push) Successful in 1s
Python Tests / test-python (push) Failing after 9s
Security Scanning / security-scan (push) Successful in 1m48s
Added logic to use tx_data.value when present instead of payload.amount for transaction amount field. Updated comment to clarify payload.amount is a fallback value.
This commit is contained in:
@@ -301,7 +301,7 @@ async def submit_transaction(tx_data: TransactionRequest) -> Dict[str, Any]:
|
|||||||
tx_data_dict = {
|
tx_data_dict = {
|
||||||
"from": tx_data.sender,
|
"from": tx_data.sender,
|
||||||
"to": tx_data.payload.get("to"), # Get to from payload (required field)
|
"to": tx_data.payload.get("to"), # Get to from payload (required field)
|
||||||
"amount": tx_data.payload.get("amount", 0), # Get amount from payload
|
"amount": tx_data.payload.get("amount", 0), # Get amount from payload (fallback)
|
||||||
"fee": tx_data.fee,
|
"fee": tx_data.fee,
|
||||||
"nonce": tx_data.nonce,
|
"nonce": tx_data.nonce,
|
||||||
"payload": tx_data.payload,
|
"payload": tx_data.payload,
|
||||||
@@ -309,6 +309,10 @@ async def submit_transaction(tx_data: TransactionRequest) -> Dict[str, Any]:
|
|||||||
"signature": tx_data.sig
|
"signature": tx_data.sig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If value is provided at top level, use it instead of payload.amount
|
||||||
|
if hasattr(tx_data, 'value') and tx_data.value is not None:
|
||||||
|
tx_data_dict["amount"] = tx_data.value
|
||||||
|
|
||||||
tx_data_dict = _normalize_transaction_data(tx_data_dict, chain_id)
|
tx_data_dict = _normalize_transaction_data(tx_data_dict, chain_id)
|
||||||
_validate_transaction_admission(tx_data_dict, mempool)
|
_validate_transaction_admission(tx_data_dict, mempool)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user