add pub fee to quote
This commit is contained in:
parent
c1e698a3af
commit
9b5d5e4105
5 changed files with 31 additions and 9 deletions
|
|
@ -1570,6 +1570,8 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
### TransactionSwapQuote
|
||||
- __chain_fee_sats__: _number_
|
||||
- __invoice_amount_sats__: _number_
|
||||
- __routing_fee_reserve_sats__: _number_
|
||||
- __service_fee_sats__: _number_
|
||||
- __swap_fee_sats__: _number_
|
||||
- __swap_operation_id__: _string_
|
||||
- __transaction_amount_sats__: _number_
|
||||
|
|
|
|||
|
|
@ -643,6 +643,8 @@ type SingleMetricReq struct {
|
|||
type TransactionSwapQuote struct {
|
||||
Chain_fee_sats int64 `json:"chain_fee_sats"`
|
||||
Invoice_amount_sats int64 `json:"invoice_amount_sats"`
|
||||
Routing_fee_reserve_sats int64 `json:"routing_fee_reserve_sats"`
|
||||
Service_fee_sats int64 `json:"service_fee_sats"`
|
||||
Swap_fee_sats int64 `json:"swap_fee_sats"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
|
||||
|
|
|
|||
|
|
@ -3757,6 +3757,8 @@ export const SingleMetricReqValidate = (o?: SingleMetricReq, opts: SingleMetricR
|
|||
export type TransactionSwapQuote = {
|
||||
chain_fee_sats: number
|
||||
invoice_amount_sats: number
|
||||
routing_fee_reserve_sats: number
|
||||
service_fee_sats: number
|
||||
swap_fee_sats: number
|
||||
swap_operation_id: string
|
||||
transaction_amount_sats: number
|
||||
|
|
@ -3766,6 +3768,8 @@ export type TransactionSwapQuoteOptions = OptionsBaseMessage & {
|
|||
checkOptionalsAreSet?: []
|
||||
chain_fee_sats_CustomCheck?: (v: number) => boolean
|
||||
invoice_amount_sats_CustomCheck?: (v: number) => boolean
|
||||
routing_fee_reserve_sats_CustomCheck?: (v: number) => boolean
|
||||
service_fee_sats_CustomCheck?: (v: number) => boolean
|
||||
swap_fee_sats_CustomCheck?: (v: number) => boolean
|
||||
swap_operation_id_CustomCheck?: (v: string) => boolean
|
||||
transaction_amount_sats_CustomCheck?: (v: number) => boolean
|
||||
|
|
@ -3780,6 +3784,12 @@ export const TransactionSwapQuoteValidate = (o?: TransactionSwapQuote, opts: Tra
|
|||
if (typeof o.invoice_amount_sats !== 'number') return new Error(`${path}.invoice_amount_sats: is not a number`)
|
||||
if (opts.invoice_amount_sats_CustomCheck && !opts.invoice_amount_sats_CustomCheck(o.invoice_amount_sats)) return new Error(`${path}.invoice_amount_sats: custom check failed`)
|
||||
|
||||
if (typeof o.routing_fee_reserve_sats !== 'number') return new Error(`${path}.routing_fee_reserve_sats: is not a number`)
|
||||
if (opts.routing_fee_reserve_sats_CustomCheck && !opts.routing_fee_reserve_sats_CustomCheck(o.routing_fee_reserve_sats)) return new Error(`${path}.routing_fee_reserve_sats: custom check failed`)
|
||||
|
||||
if (typeof o.service_fee_sats !== 'number') return new Error(`${path}.service_fee_sats: is not a number`)
|
||||
if (opts.service_fee_sats_CustomCheck && !opts.service_fee_sats_CustomCheck(o.service_fee_sats)) return new Error(`${path}.service_fee_sats: custom check failed`)
|
||||
|
||||
if (typeof o.swap_fee_sats !== 'number') return new Error(`${path}.swap_fee_sats: is not a number`)
|
||||
if (opts.swap_fee_sats_CustomCheck && !opts.swap_fee_sats_CustomCheck(o.swap_fee_sats)) return new Error(`${path}.swap_fee_sats: custom check failed`)
|
||||
|
||||
|
|
|
|||
|
|
@ -832,8 +832,11 @@ message TransactionSwapRequest {
|
|||
|
||||
message TransactionSwapQuote {
|
||||
string swap_operation_id = 1;
|
||||
int64 swap_fee_sats = 2;
|
||||
int64 invoice_amount_sats = 3;
|
||||
int64 transaction_amount_sats = 4;
|
||||
int64 invoice_amount_sats = 2;
|
||||
int64 transaction_amount_sats = 3;
|
||||
|
||||
int64 swap_fee_sats = 4;
|
||||
int64 chain_fee_sats = 5;
|
||||
int64 routing_fee_reserve_sats = 6;
|
||||
int64 service_fee_sats = 7;
|
||||
}
|
||||
|
|
@ -373,7 +373,10 @@ export default class {
|
|||
}
|
||||
const decoded = await this.lnd.DecodeInvoice(res.createdResponse.invoice)
|
||||
const swapFee = decoded.numSatoshis - chainTotal
|
||||
|
||||
const app = await this.storage.applicationStorage.GetApplication(ctx.app_id)
|
||||
const isAppUserPayment = ctx.user_id !== app.owner.user_id
|
||||
const serviceFee = this.getServiceFee(Types.UserOperationType.OUTGOING_INVOICE, decoded.numSatoshis, isAppUserPayment)
|
||||
const routingFeeLimit = this.lnd.GetFeeLimitAmount(decoded.numSatoshis)
|
||||
const newSwap = await this.storage.paymentStorage.AddTransactionSwap({
|
||||
app_user_id: ctx.app_user_id,
|
||||
swap_quote_id: res.createdResponse.id,
|
||||
|
|
@ -396,6 +399,8 @@ export default class {
|
|||
invoice_amount_sats: decoded.numSatoshis,
|
||||
transaction_amount_sats: req.transaction_amount_sats,
|
||||
chain_fee_sats: minerFee,
|
||||
service_fee_sats: serviceFee,
|
||||
routing_fee_reserve_sats: routingFeeLimit
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue