stakwork / sphinx-tribes

Backend for sphinx tribes and bounties. The bounty platform pays out in bitcoin. Sign up with Sphinx Chat, complete a bounty, and earn bitcoin! Go to our website for available bounties.
https://community.sphinx.chat/bounties
33 stars 60 forks source link

Prevent double payments when paying a bounty #1177

Closed ecurrencyhodler closed 9 months ago

ecurrencyhodler commented 10 months ago

Describe the bug I clicked "pay bounty" button for this bounty to kev by opening it up from my profile: https://community.sphinx.chat/bounty/919

The first time I clicked, nothing happened. So I copied the link and pasted it into another window. Then when I clicked "pay bounty" it worked.

Later kevin revealed he got 200k sats when he should've gotten only 100k. Thankfully this was correctly logged in the org, but the payments are tied to the same bounty

Screenshot 2023-12-23 at 9 16 27 AM

Expected behavior A bounty should only be able to be paid once. We will address this in two ways:

  1. When we tap to pay a bounty, grey out the pay button and make it unclickable until we get a response. If it fails, then make it blue again. If it succeeds, then mark bounty as paid. This should include a component test.
  2. Prevent backend from paying out if it's already been paid out unless it's been mark as unpaid. Make the endpoint synchronous instead of an async endpoint.

Desktop (please complete the following information):

Acceptance Criteria

ecurrencyhodler commented 9 months ago

Let's close this when we implement the backend restriction.