Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save Reveal Info #801

Closed
wants to merge 2 commits into from
Closed

Save Reveal Info #801

wants to merge 2 commits into from

Conversation

beaurancourt
Copy link

This PR adds a cloudflare worker connected to a D1 Database who persists and retrieves TBTC deposit reveal information.

We want to have this so that we can avoid making the user save and keep a recovery JSON file.

Note: the scope of this PR is just the happy-path implementation; no validation or edge-case handling is included.

Tagging @Shadowfiend @lukasz-zimnoch @tomaszslabon for review.

Testing:

  1. Bootstrap the database: yarn reload_db:local
  2. (in a different terminal) run the dev server: yarn dev
  3. Check the bootstrap data:
❯ curl localhost:8787/deposits/0xalice | jq '.'

[
  {
    "address": "0xalice",
    "revealInfo": {
      "depositor": {
        "identifierHex": "27343e0410acd8cf711d079c57811fe8c0666df2"
      },
      "blindingFactor": "32cd0d8907411467",
      "walletPublicKeyHash": "03b74d6893ad46dfdd01b9e0e3b3385f4fce2d1e",
      "refundPublicKeyHash": "be94fbd152b1c9f396a5e2dce4f536de0cddac1e",
      "refundLocktime": "6ebe3b65",
      "btcRecoveryAddress": "2NAcvrJF3oDpjC5nuqhJvLrsvEtXwQ1W65n"
    },
    "metadata": {},
    "application": "mezo",
    "insertedAt": 1710964575
  }
]
  1. create a deposit.json to insert data with (feel free to delete after testing)
❯ cat deposit.json

{
  "address": "0xalice",
  "revealInfo": {
    "depositor": {
      "identifierHex": "1111111111111111111111111111111111111111"
    },
    "blindingFactor": "2222222222222222",
    "walletPublicKeyHash": "3333333333333333333333333333333333333333",
    "refundPublicKeyHash": "4444444444444444444444444444444444444444",
    "refundLocktime": "55555555",
    "btcRecoveryAddress": "66666666666666666666666666666666666"
  },
  "metadata": {},
  "application": "mezo"
}
  1. Insert the data:
curl -H"Content-Type: application/json" --data @deposit.json http://localhost:8787/deposits

{"success":true}
  1. Check to see if your data was inserted:
❯ curl localhost:8787/deposits/0xalice | jq '.'

[
  {
    "address": "0xalice",
    "revealInfo": {
      "depositor": {
        "identifierHex": "27343e0410acd8cf711d079c57811fe8c0666df2"
      },
      "blindingFactor": "32cd0d8907411467",
      "walletPublicKeyHash": "03b74d6893ad46dfdd01b9e0e3b3385f4fce2d1e",
      "refundPublicKeyHash": "be94fbd152b1c9f396a5e2dce4f536de0cddac1e",
      "refundLocktime": "6ebe3b65",
      "btcRecoveryAddress": "2NAcvrJF3oDpjC5nuqhJvLrsvEtXwQ1W65n"
    },
    "metadata": {},
    "application": "mezo",
    "insertedAt": 1710964575
  },
  {
    "address": "0xalice",
    "revealInfo": {
      "depositor": {
        "identifierHex": "1111111111111111111111111111111111111111"
      },
      "blindingFactor": "2222222222222222",
      "walletPublicKeyHash": "3333333333333333333333333333333333333333",
      "refundPublicKeyHash": "4444444444444444444444444444444444444444",
      "refundLocktime": "55555555",
      "btcRecoveryAddress": "66666666666666666666666666666666666"
    },
    "metadata": {},
    "application": "mezo",
    "insertedAt": 1710964777
  }
]

We create a new sub-folder, `infrastructure`, and a new worker in that folder,
`tbtc-deposit-reveals` that is in charge of persisting and retrieving deposit
reveal information.

It uses cloudflare D1 as it's persistence backend.
@beaurancourt
Copy link
Author

ended up moving this to another repo

@beaurancourt beaurancourt deleted the save-reveal-info branch March 21, 2024 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant