Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. let depositDivisor = 10
  2. let heightUnit = 1000
  3. let finalHeight = 100000
  4. match tx {
  5. case e : TransferTransaction =>
  6. #извлекаем высоту транзакции по ID транзакции в седьмом пруфе
  7. #extracting the height of the transaction by the transaction ID, which is in the seventh proof
  8.  
  9. let depositHeight = extract(transactionHeightById(e.proofs[7]))
  10.  
  11. #извлекаем транзакцию депозита
  12. #extracting the deposit transaction
  13.  
  14. let purchaseTx = transactionById(e.proofs[7])
  15. match purchaseTx {
  16. case deposit : TransferTransaction =>
  17. let correctSender = deposit.sender == e.sender
  18. #убеждаемся, что пользователь переводит себе корректную сумму депозита + проценты
  19. #checking that the user transfers to himself the correct sum of the deposit and the interest
  20.  
  21. let correctAmount = deposit.amount + deposit.amount / depositDivisor * (height - depositHeight) / heightUnit == e.amount
  22. let correctProof = extract(getBinary(this, toBase58String(deposit.id))) == e.id
  23. correctSender && correctProof && correctAmount
  24. case _ => false
  25. }
  26. && finalHeight <= height
  27. case _ => sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement