Skip to content

Commit

Permalink
invalidate multiple concurrent accepts from the same address
Browse files Browse the repository at this point in the history
  • Loading branch information
grazcoin committed Mar 12, 2014
1 parent cad5aca commit 08b46cc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions msc_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,28 @@ def check_mastercoin_transaction(t, index=-1):
mark_tx_invalid(tx_hash, 'accept offer for closed sell offer')
return False

# invalidate accept for addresses that already have a running accept from that address
try:
bids_hash_list=bids_dict[sell_offer_tx['tx_hash']]
for b_hash in bids_hash_list:
b = tx_dict[b_hash][-1]
try:
payment_expired=b['payment_expired']
except KeyError:
payment_expired=False
try:
payment_done=b['payment_done']
except KeyError:
payment_expired=False

if not (payment_expired or payment_done) and b['from_address']==t['from_address']:
info('invalidate accept since a running bid for sell offer from that address exists '+t['tx_hash'])
mark_tx_invalid(tx_hash, 'sell offer has already a running accept from that address')
return False
debug('no bids from '+t['from_address']+' on sell offer yet')
except KeyError:
debug('no bids yet on sell offer yet')

# amount accepted is min between requested and offer
amount_accepted=min(float(accept_amount_requested),float(amount_available))

Expand Down

0 comments on commit 08b46cc

Please sign in to comment.