zaps in nip69

This commit is contained in:
boufni95 2024-10-07 17:09:47 +00:00
parent 45f4f01bce
commit c909ad3172
8 changed files with 25 additions and 12 deletions

View file

@ -976,6 +976,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

@ -342,6 +342,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

@ -1949,12 +1949,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')
@ -1966,6 +1969,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{