refund swap info
This commit is contained in:
parent
b08e7c134a
commit
680cca6852
11 changed files with 74 additions and 9 deletions
|
|
@ -1431,6 +1431,9 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __failure_reason__: _string_ *this field is optional
|
||||
- __operation_payment__: _[UserOperation](#UserOperation)_ *this field is optional
|
||||
- __quote__: _[InvoiceSwapQuote](#InvoiceSwapQuote)_
|
||||
- __refund_address__: _string_ *this field is optional
|
||||
- __refund_at_unix__: _number_ *this field is optional
|
||||
- __refund_tx_id__: _string_ *this field is optional
|
||||
|
||||
### InvoiceSwapQuote
|
||||
- __address__: _string_
|
||||
|
|
|
|||
|
|
@ -391,6 +391,9 @@ type InvoiceSwapOperation struct {
|
|||
Failure_reason string `json:"failure_reason"`
|
||||
Operation_payment *UserOperation `json:"operation_payment"`
|
||||
Quote *InvoiceSwapQuote `json:"quote"`
|
||||
Refund_address string `json:"refund_address"`
|
||||
Refund_at_unix int64 `json:"refund_at_unix"`
|
||||
Refund_tx_id string `json:"refund_tx_id"`
|
||||
}
|
||||
type InvoiceSwapQuote struct {
|
||||
Address string `json:"address"`
|
||||
|
|
|
|||
|
|
@ -2270,15 +2270,21 @@ export type InvoiceSwapOperation = {
|
|||
failure_reason?: string
|
||||
operation_payment?: UserOperation
|
||||
quote: InvoiceSwapQuote
|
||||
refund_address?: string
|
||||
refund_at_unix?: number
|
||||
refund_tx_id?: string
|
||||
}
|
||||
export type InvoiceSwapOperationOptionalField = 'completed_at_unix' | 'failure_reason' | 'operation_payment'
|
||||
export const InvoiceSwapOperationOptionalFields: InvoiceSwapOperationOptionalField[] = ['completed_at_unix', 'failure_reason', 'operation_payment']
|
||||
export type InvoiceSwapOperationOptionalField = 'completed_at_unix' | 'failure_reason' | 'operation_payment' | 'refund_address' | 'refund_at_unix' | 'refund_tx_id'
|
||||
export const InvoiceSwapOperationOptionalFields: InvoiceSwapOperationOptionalField[] = ['completed_at_unix', 'failure_reason', 'operation_payment', 'refund_address', 'refund_at_unix', 'refund_tx_id']
|
||||
export type InvoiceSwapOperationOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: InvoiceSwapOperationOptionalField[]
|
||||
completed_at_unix_CustomCheck?: (v?: number) => boolean
|
||||
failure_reason_CustomCheck?: (v?: string) => boolean
|
||||
operation_payment_Options?: UserOperationOptions
|
||||
quote_Options?: InvoiceSwapQuoteOptions
|
||||
refund_address_CustomCheck?: (v?: string) => boolean
|
||||
refund_at_unix_CustomCheck?: (v?: number) => boolean
|
||||
refund_tx_id_CustomCheck?: (v?: string) => boolean
|
||||
}
|
||||
export const InvoiceSwapOperationValidate = (o?: InvoiceSwapOperation, opts: InvoiceSwapOperationOptions = {}, path: string = 'InvoiceSwapOperation::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
|
|
@ -2300,6 +2306,15 @@ export const InvoiceSwapOperationValidate = (o?: InvoiceSwapOperation, opts: Inv
|
|||
if (quoteErr !== null) return quoteErr
|
||||
|
||||
|
||||
if ((o.refund_address || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('refund_address')) && typeof o.refund_address !== 'string') return new Error(`${path}.refund_address: is not a string`)
|
||||
if (opts.refund_address_CustomCheck && !opts.refund_address_CustomCheck(o.refund_address)) return new Error(`${path}.refund_address: custom check failed`)
|
||||
|
||||
if ((o.refund_at_unix || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('refund_at_unix')) && typeof o.refund_at_unix !== 'number') return new Error(`${path}.refund_at_unix: is not a number`)
|
||||
if (opts.refund_at_unix_CustomCheck && !opts.refund_at_unix_CustomCheck(o.refund_at_unix)) return new Error(`${path}.refund_at_unix: custom check failed`)
|
||||
|
||||
if ((o.refund_tx_id || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('refund_tx_id')) && typeof o.refund_tx_id !== 'string') return new Error(`${path}.refund_tx_id: is not a string`)
|
||||
if (opts.refund_tx_id_CustomCheck && !opts.refund_tx_id_CustomCheck(o.refund_tx_id)) return new Error(`${path}.refund_tx_id: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -926,6 +926,10 @@ message InvoiceSwapOperation {
|
|||
optional UserOperation operation_payment = 2;
|
||||
optional string failure_reason = 3;
|
||||
optional int64 completed_at_unix = 6;
|
||||
|
||||
optional string refund_address = 7;
|
||||
optional int64 refund_at_unix = 8;
|
||||
optional string refund_tx_id = 9;
|
||||
}
|
||||
|
||||
message InvoiceSwapsList {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue