Skip to content

Transaction Validation

Leo Cornelius edited this page Apr 8, 2021 · 2 revisions

Old method:

  • Get an account of the sender
  • Get the txn count of the sender
  • Check transaction type is supported
  • Check the extra field is all alphanumeric
  • check the nonce == got txn count of the sender
  • check the hash of the transaction is correct
  • check the amount is over 1
  • Check the size of extra for each type:
    • Normal: 100
    • Fullnode reg: 296
    • Username reg: 298
  • Check the txn has a receiver
  • Check gas for each type of transaction and that max gas > gas used:
    • Normal: 20 + (60 * length of extra)
    • Message: 20 + (100 * length of extra)
    • Claim: Don't check gas
    • Other: 20
  • If unlock time != 0, check timestamp < unlock time
  • If type= username reg check amount > username_burn_amount
  • Check timestamp is not more than transaction_timestamp_max_offset in the future
  • if the access key is empty:
    • if type != claim check account balance > amount + fee
    • Check the extra size is not over 100 (DUPLICATE: SHOULD NOT HAVE BEEN RECHECKED)
    • Check the sender account exists
    • Check the signature is valid
  • Else:
    • Try to find the access key in the sender's account
    • if the type of transaction is not claim check that the access keys allowance is above the amount + fee
    • Try to decode the access key
    • Check the signature using a decoded access key

New:

  • Check the public key of the sender, if the username get the public key
  • get the account of the sender
  • Check hash of the transaction
  • Check for duplicate hash
  • Check signature of the transaction
  • Check to receive account exists
  • Check the account transaction count == nonce
  • Check extra is alphanumerical
  • Check gas price >= min_gas_price (1)
  • Match type:
    • Normal:
      • Check extra size is < 100
      • Check amount is over 1
      • Check the sender.balance > (amount + fee)
      • Get receiver account
      • Check the (max_balance - receiver.balance) > amount
      • Check gas >= 20 + (60 * length of extra)
      • Check gas <= max_gas
      • If unlock time != 0, check timestamp < unlock time
    • Claim:
      • Check - Check extra size is < 100
      • Check amount is over 1
      • Check the (max_balance - sender.balance) > amount
      • Check unlock time == 0
    • Fullnode registration:
      • Check extra len = 296
      • Check the registration is correct
      • Check gas > 316
      • Check gas <= max gas
      • Check unlock time = 0
    • Username registration:
      • Check extra len = 298
      • Check the registration is correct
      • Check gas > 318
      • Check gas <= max gas
      • Check unlock time = 0
    • Message:
      • Check extra size is < 1000
      • Check amount = 0
      • Check the sender.balance > fee
      • Check gas >= 20 + (250 * length of extra)
      • Check gas <= max_gas
      • Check unlock time = 0
    • Block Account:
      • Check extra size = public_key_len
      • Check amount = 0
      • Check the sender.balance > fee
      • Get receiver account
      • Check gas >= 20
      • Check gas <= max_gas
      • Check unlock time = 0
      • Check the account being blocked is not already blocked by sender
    • Unblock Account:
      • Check extra size = public_key_len
      • Check amount = 0
      • Check the sender.balance > fee
      • Get receiver account
      • Check gas >= 20
      • Check gas <= max_gas
      • Check unlock time = 0
      • Check the account being blocked is blocked by sender
    • Other:
      • unsupported transaction type
  • Check timestamp is not more than transaction_timestamp_max_offset in the future
  • if the access key is empty:
    • Check the signature is valid
  • Else:
    • Try to find the access key in the sender's account
    • if the type of transaction is not claim check that the access keys allowance is above the amount + fee
    • Try to decode the access key
    • Check the signature using a decoded access key
Clone this wiki locally