Merge pull request #764 from shocknet/debits

zaps in nip69
This commit is contained in:
Justin (shocknet) 2024-10-16 12:17:54 -04:00 committed by GitHub
commit 30d7942fce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 31 additions and 14 deletions

View file

@ -989,6 +989,7 @@ The nostr server will send back a message response, and inside the body there wi
### NewInvoiceRequest
- __amountSats__: _number_
- __memo__: _string_
- __zap__: _string_ *this field is optional
### NewInvoiceResponse
- __invoice__: _string_

View file

@ -348,6 +348,7 @@ type NewAddressResponse struct {
type NewInvoiceRequest struct {
Amountsats int64 `json:"amountSats"`
Memo string `json:"memo"`
Zap string `json:"zap"`
}
type NewInvoiceResponse struct {
Invoice string `json:"invoice"`

View file

@ -1990,12 +1990,15 @@ export const NewAddressResponseValidate = (o?: NewAddressResponse, opts: NewAddr
export type NewInvoiceRequest = {
amountSats: number
memo: string
zap?: string
}
export const NewInvoiceRequestOptionalFields: [] = []
export type NewInvoiceRequestOptionalField = 'zap'
export const NewInvoiceRequestOptionalFields: NewInvoiceRequestOptionalField[] = ['zap']
export type NewInvoiceRequestOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
checkOptionalsAreSet?: NewInvoiceRequestOptionalField[]
amountSats_CustomCheck?: (v: number) => boolean
memo_CustomCheck?: (v: string) => boolean
zap_CustomCheck?: (v?: string) => boolean
}
export const NewInvoiceRequestValidate = (o?: NewInvoiceRequest, opts: NewInvoiceRequestOptions = {}, path: string = 'NewInvoiceRequest::root.'): Error | null => {
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
@ -2007,6 +2010,9 @@ export const NewInvoiceRequestValidate = (o?: NewInvoiceRequest, opts: NewInvoic
if (typeof o.memo !== 'string') return new Error(`${path}.memo: is not a string`)
if (opts.memo_CustomCheck && !opts.memo_CustomCheck(o.memo)) return new Error(`${path}.memo: custom check failed`)
if ((o.zap || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('zap')) && typeof o.zap !== 'string') return new Error(`${path}.zap: is not a string`)
if (opts.zap_CustomCheck && !opts.zap_CustomCheck(o.zap)) return new Error(`${path}.zap: custom check failed`)
return null
}

View file

@ -270,6 +270,7 @@ message PayAddressResponse{
message NewInvoiceRequest{
int64 amountSats = 1;
string memo = 2;
optional string zap = 3;
}
message NewInvoiceResponse{