diff options
Diffstat (limited to 'src/routes/(static)/docs')
| -rw-r--r-- | src/routes/(static)/docs/+page.server.ts | 5 | ||||
| -rw-r--r-- | src/routes/(static)/docs/+page.svelte | 64 |
2 files changed, 56 insertions, 13 deletions
diff --git a/src/routes/(static)/docs/+page.server.ts b/src/routes/(static)/docs/+page.server.ts index 86f95824..93ba544c 100644 --- a/src/routes/(static)/docs/+page.server.ts +++ b/src/routes/(static)/docs/+page.server.ts @@ -1,4 +1,7 @@ +import { auth, get } from "$lib/utils"; export const load = async ({ cookies }) => { const token = cookies.get("token"); - return { token }; + let ro; + if (token) ro = await get("/ro", auth(cookies)); + return { ro, token }; }; diff --git a/src/routes/(static)/docs/+page.svelte b/src/routes/(static)/docs/+page.svelte index 7ac6e013..7cf7e2cb 100644 --- a/src/routes/(static)/docs/+page.svelte +++ b/src/routes/(static)/docs/+page.svelte @@ -7,7 +7,7 @@ let { data } = $props(); - let { user, token } = data; + let { user, ro, token } = data; let api = PUBLIC_DOMAIN.includes("localhost") ? `${PUBLIC_COINOS_URL}` @@ -16,6 +16,8 @@ let tokenSample = token ? `export token="${token}"` : `export token=<your auth token>`; + + let roSample = `export token="${ro}"`; </script> {#snippet cp(something)} @@ -59,7 +61,7 @@ or get one from the /login endpoint. {/if} - Save it in a variable called <b>$token</b> to run the examples. + Save it in a variable called <b>$token</b> to run the examples. It gives full access to your account so keep it safe. </p> <div @@ -69,6 +71,19 @@ {@render cp(tokenSample)} </div> + {#if ro} + <p class="text-secondary"> + This read-only token has permission to create invoices and fetch + payments but can't be used to make withdrawals + </p> + <div + class="bg-primary text-primary-content rounded-lg p-4 flex gap-4 items-center" + > + <div class="w-full break-all">{roSample}</div> + {@render cp(roSample)} + </div> + {/if} + <h2 class="text-2xl">POST /register</h2> <p class="text-secondary"> Register a new user account with a username and password @@ -92,9 +107,13 @@ <div class="font-bold">display</div> <div class="col-span-2">string - spaces allowed</div> <div class="font-bold">currency</div> - <div class="col-span-2">string - three-letter ISO currency code e.g. CAD or USD</div> + <div class="col-span-2"> + string - three-letter ISO currency code e.g. CAD or USD + </div> <div class="font-bold">language</div> - <div class="col-span-2">string - two-letter language code e.g. en, fr, es</div> + <div class="col-span-2"> + string - two-letter language code e.g. en, fr, es + </div> </div> <Code sample="update" /> @@ -105,16 +124,22 @@ <div class="text-secondary"> <div>Request params</div> <div class="grid grid-cols-3 ml-2"> - <div class="font-bold">type</div> + <div class="font-bold">type (string, default: lightning)</div> <div class="col-span-2">bitcoin or lightning</div> - <div class="font-bold">amount</div> - <div class="col-span-2">amount in satoshis</div> - <div class="font-bold">webhook</div> + <div class="font-bold">fiat (boolean, default: false)</div> + <div class="col-span-2"> + whether the amount is denominated in satoshis or local currency + </div> + <div class="font-bold">amount (numeric)</div> + <div class="col-span-2">amount to be paid</div> + <div class="font-bold">webhook (string, optional)</div> <div class="col-span-2"> - (optional) endpoint to hit when the invoice is paid + remote endpoint to call when the invoice is paid + </div> + <div class="font-bold">secret (string, optional)</div> + <div class="col-span-2"> + a secret value passed to the webhook to authenticate the request </div> - <div class="font-bold">secret</div> - <div class="col-span-2">a secret for the webhook to check</div> </div> </div> @@ -137,8 +162,23 @@ </p> <Code sample="fetchInvoice" /> + <h2 class="text-2xl">POST /lightning/quote</h2> + <p class="text-secondary"> + Find out what a lightning payment will cost before sending it. The routing + fee comes from querying the route ahead of time and is exact; pass it as + <b>fee</b> to POST /payments. Pass <b>amount</b> for an amountless invoice, + or <b>max</b> to solve for the largest amount whose amount + fees uses the + whole balance. + </p> + <Code sample="quote" /> + <p>Sample response</p> + <Code sample="quoteResponse" /> + <h2 class="text-2xl">POST /payments</h2> - <p class="text-secondary">Send a lightning payment</p> + <p class="text-secondary"> + Send a lightning payment. <b>fee</b> caps the routing fee; if omitted, the + route is quoted and the exact fee used. + </p> <Code sample="lightning" /> <p class="text-secondary">Send an internal payment to another user</p> |
