feat(send): smart source selection by gift-card config - #1042
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
ab0fef6 to
e5f4721
Compare
e5f4721 to
0dc3ee5
Compare
351b5e1 to
181d9fe
Compare
0dc3ee5 to
11cf64a
Compare
11cf64a to
849f56d
Compare
849f56d to
10c2f27
Compare
10c2f27 to
3dd677c
Compare
3dd677c to
e1ccad3
Compare
| const initialAccount = useAccountOrDefault(accountId); | ||
| const accountIdParam = searchParams.get('accountId'); | ||
| const initialAccount = useAccountOrDefault( | ||
| loaderData.initialAccountId ?? accountIdParam, |
There was a problem hiding this comment.
What are all the places that accountIdParam will be set from the app? I'm wondering because it will inform which one has priority
There was a problem hiding this comment.
Two places: gift-card-details Send and offer-details Pay buttons. Both pass the currently-viewed account. The picker overriding it is correct — closed-loop mints can only pay invoices matching their config, so if the picker swaps to a different offer/gift-card it's because the original couldn't have paid the invoice anyway. If nothing matches, accountIdParam wins via the defaultAccount fallback.
e1ccad3 to
aaacb13
Compare
aaacb13 to
f9a56fd
Compare
181d9fe to
4811b73
Compare
f9a56fd to
df22b65
Compare
df22b65 to
712ad16
Compare
jbojcic1
left a comment
There was a problem hiding this comment.
this is all still pretty confusing to me
712ad16 to
a6b8a71
Compare
a6b8a71 to
b9b849f
Compare
b9b849f to
4bd8513
Compare
how about now? I only changed app/routes/_protected.send.tsx and made |
much better now |
| const isAllowedDestination = ( | ||
| config: NonNullable<GiftCardInfo['validPaymentDestinations']>, | ||
| ): boolean => { | ||
| if (description && config.descriptions.includes(description)) return true; |
There was a problem hiding this comment.
so if both description and node pubkeyes are set in the config, it is enough to just match the description?
6ae5ab3 to
06c61ce
Compare
Adds validPaymentDestinations: { descriptions, nodePubkeys } to the
gift-card config schema and a findMatchingOfferOrGiftCardAccount helper
that uses it to preselect the right cashu account for an incoming
BOLT11 invoice. Priority: offer > gift-card > default.
Selection happens in the send route loader (no first-render flash) and
on every paste/scan via the send store. Both populated lists in
validPaymentDestinations are required checks (AND); an empty list means
the dimension is unconstrained; both empty means the mint is
unconfigured and never matches.
To support pubkey matching, decodeBolt11 now recovers the payee node
key from the invoice signature — the n tag is optional in BOLT11 and
rarely included. Recovery uses a manual 5→8 bit packer to produce the
canonical preimage, since @scure/base's strict bech32.fromWords rejects
the partial trailing byte that real-world invoices commonly have.
nodePubkeys are normalized to lowercase at zod parse time.
Supersedes #1025. Production VITE_GIFT_CARDS must add
validPaymentDestinations to every entry before this deploys, or vite
will throw at startup.
06c61ce to
cbe7cba
Compare
Adds
validPaymentDestinations: { descriptions, nodePubkeys }to gift-card config and apickSendAccounthelper that uses it to preselect the right cashu account for an incoming BOLT11 invoice. Priority:offer>gift-card> default. Selection happens in the route loader (no first-render flash) and on every paste/scan via the send store.Supersedes #1025.