Skip to content

Conversation

@sachinBitgo
Copy link
Contributor

@sachinBitgo sachinBitgo commented Sep 23, 2025

COIN-3579

📋 Summary
This PR implements comprehensive transaction verification functionality for TRON (TRX) transfers in the BitGo SDK. The changes add robust validation for TransferContract transactions to ensure transaction integrity and security.

🔧 Changes Made

Core Implementation

  • Added verifyTransaction method in trx.ts to validate transaction parameters against the prebuild transaction
  • Implemented validateTransferContract for specific validation of native TRX transfers
  • Created generateRawDataHex utility in utils.ts for proper protobuf encoding of transaction data
  • Added getHexFromBase64 helper for base64 to hex conversion

Key Features

✅ Parameter validation: Ensures required fields (txParams, txPrebuild, wallet) are present
✅ Address validation: Validates owner and destination addresses using Base58 encoding
✅ Amount verification: Confirms transaction amounts match between client request and prebuild
✅ Address matching: Verifies destination addresses match recipient addresses
✅ Contract structure validation: Ensures proper TransferContract parameter structure

Error Handling

  • Comprehensive error messages for missing or invalid parameters
  • Specific validation for different failure scenarios
  • Debug logging for transaction verification failures

🧪 Testing

  • Added comprehensive test suite (verifyTransaction.ts)
  • Parameter validation tests: Missing txParams, wallet, txPrebuild scenarios
  • Contract validation tests: Valid and invalid TransferContract scenarios
  • Edge case testing: Missing addresses, amounts, and mismatched values
  • Updated test resources with corrected address values

kamleshmugdiya
kamleshmugdiya previously approved these changes Sep 29, 2025
Copy link
Contributor

@kamleshmugdiya kamleshmugdiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

nvjsr
nvjsr previously approved these changes Sep 29, 2025
Copy link
Contributor

@nvjsr nvjsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sachinBitgo sachinBitgo merged commit f386a91 into master Oct 3, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants