fix names
This commit is contained in:
parent
5e49e74b22
commit
9d082ea0a0
12 changed files with 46 additions and 55 deletions
|
|
@ -292,7 +292,7 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
|
||||
- PayAdminTransactionSwap
|
||||
- auth type: __Admin__
|
||||
- input: [TransactionSwapQuoteRequest](#TransactionSwapQuoteRequest)
|
||||
- input: [PayAdminTransactionSwapRequest](#PayAdminTransactionSwapRequest)
|
||||
- output: [AdminSwapResponse](#AdminSwapResponse)
|
||||
|
||||
- PayInvoice
|
||||
|
|
@ -903,7 +903,7 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- auth type: __Admin__
|
||||
- http method: __post__
|
||||
- http route: __/api/admin/swap/transaction/pay__
|
||||
- input: [TransactionSwapQuoteRequest](#TransactionSwapQuoteRequest)
|
||||
- input: [PayAdminTransactionSwapRequest](#PayAdminTransactionSwapRequest)
|
||||
- output: [AdminSwapResponse](#AdminSwapResponse)
|
||||
|
||||
- PayAppUserInvoice
|
||||
|
|
@ -1534,6 +1534,10 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __service_fee__: _number_
|
||||
- __txId__: _string_
|
||||
|
||||
### PayAdminTransactionSwapRequest
|
||||
- __address__: _string_
|
||||
- __swap_operation_id__: _string_
|
||||
|
||||
### PayAppUserInvoiceRequest
|
||||
- __amount__: _number_
|
||||
- __debit_npub__: _string_ *this field is optional
|
||||
|
|
@ -1564,7 +1568,6 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __network_fee__: _number_
|
||||
- __operation_id__: _string_
|
||||
- __paid_at_unix__: _number_
|
||||
- __preimage__: _string_ *this field is optional
|
||||
- __service_fee__: _number_
|
||||
|
||||
### Product
|
||||
|
|
@ -1655,10 +1658,6 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __swap_operation_id__: _string_
|
||||
- __transaction_amount_sats__: _number_
|
||||
|
||||
### TransactionSwapQuoteRequest
|
||||
- __address__: _string_
|
||||
- __swap_operation_id__: _string_
|
||||
|
||||
### TransactionSwapRequest
|
||||
- __transaction_amount_sats__: _number_
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ type Client struct {
|
|||
NewProductInvoice func(query NewProductInvoice_Query) (*NewInvoiceResponse, error)
|
||||
OpenChannel func(req OpenChannelRequest) (*OpenChannelResponse, error)
|
||||
PayAddress func(req PayAddressRequest) (*PayAddressResponse, error)
|
||||
PayAdminTransactionSwap func(req TransactionSwapQuoteRequest) (*AdminSwapResponse, error)
|
||||
PayAdminTransactionSwap func(req PayAdminTransactionSwapRequest) (*AdminSwapResponse, error)
|
||||
PayAppUserInvoice func(req PayAppUserInvoiceRequest) (*PayInvoiceResponse, error)
|
||||
PayInvoice func(req PayInvoiceRequest) (*PayInvoiceResponse, error)
|
||||
PingSubProcesses func() error
|
||||
|
|
@ -1892,7 +1892,7 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
PayAdminTransactionSwap: func(req TransactionSwapQuoteRequest) (*AdminSwapResponse, error) {
|
||||
PayAdminTransactionSwap: func(req PayAdminTransactionSwapRequest) (*AdminSwapResponse, error) {
|
||||
auth, err := params.RetrieveAdminAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -559,6 +559,10 @@ type PayAddressResponse struct {
|
|||
Service_fee int64 `json:"service_fee"`
|
||||
Txid string `json:"txId"`
|
||||
}
|
||||
type PayAdminTransactionSwapRequest struct {
|
||||
Address string `json:"address"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
}
|
||||
type PayAppUserInvoiceRequest struct {
|
||||
Amount int64 `json:"amount"`
|
||||
Debit_npub string `json:"debit_npub"`
|
||||
|
|
@ -589,7 +593,6 @@ type PaymentState struct {
|
|||
Network_fee int64 `json:"network_fee"`
|
||||
Operation_id string `json:"operation_id"`
|
||||
Paid_at_unix int64 `json:"paid_at_unix"`
|
||||
Preimage string `json:"preimage"`
|
||||
Service_fee int64 `json:"service_fee"`
|
||||
}
|
||||
type Product struct {
|
||||
|
|
@ -680,10 +683,6 @@ type TransactionSwapQuote struct {
|
|||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
|
||||
}
|
||||
type TransactionSwapQuoteRequest struct {
|
||||
Address string `json:"address"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
}
|
||||
type TransactionSwapRequest struct {
|
||||
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1804,7 +1804,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => {
|
|||
authCtx = authContext
|
||||
stats.guard = process.hrtime.bigint()
|
||||
const request = req.body
|
||||
const error = Types.TransactionSwapQuoteRequestValidate(request)
|
||||
const error = Types.PayAdminTransactionSwapRequestValidate(request)
|
||||
stats.validate = process.hrtime.bigint()
|
||||
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger, { ...info, ...stats, ...authContext }, opts.metricsCallback)
|
||||
const query = req.query
|
||||
|
|
|
|||
|
|
@ -909,7 +909,7 @@ export default (params: ClientParams) => ({
|
|||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
PayAdminTransactionSwap: async (request: Types.TransactionSwapQuoteRequest): Promise<ResultError | ({ status: 'OK' }& Types.AdminSwapResponse)> => {
|
||||
PayAdminTransactionSwap: async (request: Types.PayAdminTransactionSwapRequest): Promise<ResultError | ({ status: 'OK' }& Types.AdminSwapResponse)> => {
|
||||
const auth = await params.retrieveAdminAuth()
|
||||
if (auth === null) throw new Error('retrieveAdminAuth() returned null')
|
||||
let finalRoute = '/api/admin/swap/transaction/pay'
|
||||
|
|
|
|||
|
|
@ -798,7 +798,7 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ
|
|||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
PayAdminTransactionSwap: async (request: Types.TransactionSwapQuoteRequest): Promise<ResultError | ({ status: 'OK' }& Types.AdminSwapResponse)> => {
|
||||
PayAdminTransactionSwap: async (request: Types.PayAdminTransactionSwapRequest): Promise<ResultError | ({ status: 'OK' }& Types.AdminSwapResponse)> => {
|
||||
const auth = await params.retrieveNostrAdminAuth()
|
||||
if (auth === null) throw new Error('retrieveNostrAdminAuth() returned null')
|
||||
const nostrRequest: NostrRequest = {}
|
||||
|
|
|
|||
|
|
@ -1261,7 +1261,7 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
|||
stats.guard = process.hrtime.bigint()
|
||||
authCtx = authContext
|
||||
const request = req.body
|
||||
const error = Types.TransactionSwapQuoteRequestValidate(request)
|
||||
const error = Types.PayAdminTransactionSwapRequestValidate(request)
|
||||
stats.validate = process.hrtime.bigint()
|
||||
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback)
|
||||
const response = await methods.PayAdminTransactionSwap({rpcName:'PayAdminTransactionSwap', ctx:authContext , req: request})
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ export type OpenChannel_Output = ResultError | ({ status: 'OK' } & OpenChannelRe
|
|||
export type PayAddress_Input = {rpcName:'PayAddress', req: PayAddressRequest}
|
||||
export type PayAddress_Output = ResultError | ({ status: 'OK' } & PayAddressResponse)
|
||||
|
||||
export type PayAdminTransactionSwap_Input = {rpcName:'PayAdminTransactionSwap', req: TransactionSwapQuoteRequest}
|
||||
export type PayAdminTransactionSwap_Input = {rpcName:'PayAdminTransactionSwap', req: PayAdminTransactionSwapRequest}
|
||||
export type PayAdminTransactionSwap_Output = ResultError | ({ status: 'OK' } & AdminSwapResponse)
|
||||
|
||||
export type PayAppUserInvoice_Input = {rpcName:'PayAppUserInvoice', req: PayAppUserInvoiceRequest}
|
||||
|
|
@ -3308,6 +3308,29 @@ export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddr
|
|||
return null
|
||||
}
|
||||
|
||||
export type PayAdminTransactionSwapRequest = {
|
||||
address: string
|
||||
swap_operation_id: string
|
||||
}
|
||||
export const PayAdminTransactionSwapRequestOptionalFields: [] = []
|
||||
export type PayAdminTransactionSwapRequestOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
address_CustomCheck?: (v: string) => boolean
|
||||
swap_operation_id_CustomCheck?: (v: string) => boolean
|
||||
}
|
||||
export const PayAdminTransactionSwapRequestValidate = (o?: PayAdminTransactionSwapRequest, opts: PayAdminTransactionSwapRequestOptions = {}, path: string = 'PayAdminTransactionSwapRequest::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||
|
||||
if (typeof o.address !== 'string') return new Error(`${path}.address: is not a string`)
|
||||
if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`)
|
||||
|
||||
if (typeof o.swap_operation_id !== 'string') return new Error(`${path}.swap_operation_id: is not a string`)
|
||||
if (opts.swap_operation_id_CustomCheck && !opts.swap_operation_id_CustomCheck(o.swap_operation_id)) return new Error(`${path}.swap_operation_id: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type PayAppUserInvoiceRequest = {
|
||||
amount: number
|
||||
debit_npub?: string
|
||||
|
|
@ -3456,19 +3479,16 @@ export type PaymentState = {
|
|||
network_fee: number
|
||||
operation_id: string
|
||||
paid_at_unix: number
|
||||
preimage?: string
|
||||
service_fee: number
|
||||
}
|
||||
export type PaymentStateOptionalField = 'preimage'
|
||||
export const PaymentStateOptionalFields: PaymentStateOptionalField[] = ['preimage']
|
||||
export const PaymentStateOptionalFields: [] = []
|
||||
export type PaymentStateOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: PaymentStateOptionalField[]
|
||||
checkOptionalsAreSet?: []
|
||||
amount_CustomCheck?: (v: number) => boolean
|
||||
internal_CustomCheck?: (v: boolean) => boolean
|
||||
network_fee_CustomCheck?: (v: number) => boolean
|
||||
operation_id_CustomCheck?: (v: string) => boolean
|
||||
paid_at_unix_CustomCheck?: (v: number) => boolean
|
||||
preimage_CustomCheck?: (v?: string) => boolean
|
||||
service_fee_CustomCheck?: (v: number) => boolean
|
||||
}
|
||||
export const PaymentStateValidate = (o?: PaymentState, opts: PaymentStateOptions = {}, path: string = 'PaymentState::root.'): Error | null => {
|
||||
|
|
@ -3490,9 +3510,6 @@ export const PaymentStateValidate = (o?: PaymentState, opts: PaymentStateOptions
|
|||
if (typeof o.paid_at_unix !== 'number') return new Error(`${path}.paid_at_unix: is not a number`)
|
||||
if (opts.paid_at_unix_CustomCheck && !opts.paid_at_unix_CustomCheck(o.paid_at_unix)) return new Error(`${path}.paid_at_unix: custom check failed`)
|
||||
|
||||
if ((o.preimage || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('preimage')) && typeof o.preimage !== 'string') return new Error(`${path}.preimage: is not a string`)
|
||||
if (opts.preimage_CustomCheck && !opts.preimage_CustomCheck(o.preimage)) return new Error(`${path}.preimage: custom check failed`)
|
||||
|
||||
if (typeof o.service_fee !== 'number') return new Error(`${path}.service_fee: is not a number`)
|
||||
if (opts.service_fee_CustomCheck && !opts.service_fee_CustomCheck(o.service_fee)) return new Error(`${path}.service_fee: custom check failed`)
|
||||
|
||||
|
|
@ -4013,29 +4030,6 @@ export const TransactionSwapQuoteValidate = (o?: TransactionSwapQuote, opts: Tra
|
|||
return null
|
||||
}
|
||||
|
||||
export type TransactionSwapQuoteRequest = {
|
||||
address: string
|
||||
swap_operation_id: string
|
||||
}
|
||||
export const TransactionSwapQuoteRequestOptionalFields: [] = []
|
||||
export type TransactionSwapQuoteRequestOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
address_CustomCheck?: (v: string) => boolean
|
||||
swap_operation_id_CustomCheck?: (v: string) => boolean
|
||||
}
|
||||
export const TransactionSwapQuoteRequestValidate = (o?: TransactionSwapQuoteRequest, opts: TransactionSwapQuoteRequestOptions = {}, path: string = 'TransactionSwapQuoteRequest::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||
|
||||
if (typeof o.address !== 'string') return new Error(`${path}.address: is not a string`)
|
||||
if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`)
|
||||
|
||||
if (typeof o.swap_operation_id !== 'string') return new Error(`${path}.swap_operation_id: is not a string`)
|
||||
if (opts.swap_operation_id_CustomCheck && !opts.swap_operation_id_CustomCheck(o.swap_operation_id)) return new Error(`${path}.swap_operation_id: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type TransactionSwapRequest = {
|
||||
transaction_amount_sats: number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ service LightningPub {
|
|||
option (nostr) = true;
|
||||
}
|
||||
|
||||
rpc PayAdminTransactionSwap(structs.TransactionSwapQuoteRequest) returns (structs.AdminSwapResponse) {
|
||||
rpc PayAdminTransactionSwap(structs.PayAdminTransactionSwapRequest) returns (structs.AdminSwapResponse) {
|
||||
option (auth_type) = "Admin";
|
||||
option (http_method) = "post";
|
||||
option (http_route) = "/api/admin/swap/transaction/pay";
|
||||
|
|
|
|||
|
|
@ -837,7 +837,7 @@ message TransactionSwapRequest {
|
|||
int64 transaction_amount_sats = 2;
|
||||
}
|
||||
|
||||
message TransactionSwapQuoteRequest {
|
||||
message PayAdminTransactionSwapRequest {
|
||||
string address = 1;
|
||||
string swap_operation_id = 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue