Skip to content

Commit 77baf90

Browse files
committed
Checking ERC20 contract address as well
1 parent 45e018b commit 77baf90

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

pretix_eth/management/commands/confirm_payments.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,22 @@ def confirm_payments_for_event(self, event: Event, no_dry_run, log_verbosity=0):
115115
# ETH
116116
payment_amount = w3.eth.getTransaction(signed_message.transaction_hash).value
117117
receipt_reciever = receipt.to.lower()
118+
correct_recipient = receipt_reciever == signed_message.recipient_address.lower()
119+
118120
else:
119121
# DAI
120122
contract = w3.eth.contract(address=token.ADDRESS, abi=TOKEN_ABI)
121123
transaction_details = contract.events.Transfer().processReceipt(receipt)[0].args
122124
payment_amount = transaction_details.value
125+
# check that the payment happened on the right contract address
126+
correct_contract = token.ADDRESS.lower() == receipt.to.lower()
123127
# take recipient address from the topics, not from the "from" field, as that's the contract address
124128
receipt_reciever = receipt.logs[0].topics[2][12:].hex().lower()
129+
correct_recipient = correct_contract and (receipt_reciever == signed_message.recipient_address.lower())
130+
125131

126132
receipt_sender = getattr(receipt, 'from').lower()
127133
correct_sender = receipt_sender == signed_message.sender_address.lower()
128-
correct_recipient = receipt_reciever == signed_message.recipient_address.lower()
129134

130135
if not (correct_sender and correct_recipient):
131136
logger.warning(

0 commit comments

Comments
 (0)