Skip to content

Commit

Permalink
fix order of sorted_merkle_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
lollerfirst committed Sep 21, 2024
1 parent 2b8fa8b commit 39aa849
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cashu/core/crypto/dlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def sorted_merkle_hash(left: bytes, right: bytes) -> bytes:
'''Sorts `left` and `right` in non-ascending order and
computes the hash of their concatenation
'''
if left < right:
if right < left:
left, right = right, left
return sha256(left+right).digest()

Expand Down
12 changes: 6 additions & 6 deletions cashu/mint/db/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,16 @@ async def _verify_and_update_dlc_payouts(
eligible_amount = dlc.debts[payout.pubkey]

# Verify the amount of the blind messages is LEQ than the eligible amount
if blind_messages_amount > eligible_amount:
if blind_messages_amount != eligible_amount:
raise DlcPayoutFail(detail=f"amount requested ({blind_messages_amount}) is bigger than eligible amount ({eligible_amount})")

# Discriminate what to do next based on whether the requested amount is exact or less
if blind_messages_amount == eligible_amount:
del dlc.debts[payout.pubkey]
else:
dlc.debts[payout.pubkey] -= blind_messages_amount
# Remove the payout from the map
del dlc.debts[payout.pubkey]

# Update the database
await self.crud.set_dlc_settled_and_debts(dlc.dlc_root, json.dumps(dlc.debts), self.db, conn)

# Append payout to verified results
verified.append(payout)
except (CashuError, Exception) as e:
errors.append(DlcPayout(
Expand Down

0 comments on commit 39aa849

Please sign in to comment.