UserInfo includes ndebit

This commit is contained in:
Mothana 2024-09-19 01:48:30 +04:00
parent bed397e424
commit 143fe44589
6 changed files with 15 additions and 4 deletions

View file

@ -1042,6 +1042,7 @@ The nostr server will send back a message response, and inside the body there wi
### UserInfo ### UserInfo
- __balance__: _number_ - __balance__: _number_
- __max_withdrawable__: _number_ - __max_withdrawable__: _number_
- __ndebit__: _string_
- __network_max_fee_bps__: _number_ - __network_max_fee_bps__: _number_
- __network_max_fee_fixed__: _number_ - __network_max_fee_fixed__: _number_
- __noffer__: _string_ - __noffer__: _string_

View file

@ -456,6 +456,7 @@ type UseInviteLinkRequest struct {
type UserInfo struct { type UserInfo struct {
Balance int64 `json:"balance"` Balance int64 `json:"balance"`
Max_withdrawable int64 `json:"max_withdrawable"` Max_withdrawable int64 `json:"max_withdrawable"`
Ndebit string `json:"ndebit"`
Network_max_fee_bps int64 `json:"network_max_fee_bps"` Network_max_fee_bps int64 `json:"network_max_fee_bps"`
Network_max_fee_fixed int64 `json:"network_max_fee_fixed"` Network_max_fee_fixed int64 `json:"network_max_fee_fixed"`
Noffer string `json:"noffer"` Noffer string `json:"noffer"`

View file

@ -2575,6 +2575,7 @@ export const UseInviteLinkRequestValidate = (o?: UseInviteLinkRequest, opts: Use
export type UserInfo = { export type UserInfo = {
balance: number balance: number
max_withdrawable: number max_withdrawable: number
ndebit: string
network_max_fee_bps: number network_max_fee_bps: number
network_max_fee_fixed: number network_max_fee_fixed: number
noffer: string noffer: string
@ -2587,6 +2588,7 @@ export type UserInfoOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: [] checkOptionalsAreSet?: []
balance_CustomCheck?: (v: number) => boolean balance_CustomCheck?: (v: number) => boolean
max_withdrawable_CustomCheck?: (v: number) => boolean max_withdrawable_CustomCheck?: (v: number) => boolean
ndebit_CustomCheck?: (v: string) => boolean
network_max_fee_bps_CustomCheck?: (v: number) => boolean network_max_fee_bps_CustomCheck?: (v: number) => boolean
network_max_fee_fixed_CustomCheck?: (v: number) => boolean network_max_fee_fixed_CustomCheck?: (v: number) => boolean
noffer_CustomCheck?: (v: string) => boolean noffer_CustomCheck?: (v: string) => boolean
@ -2604,6 +2606,9 @@ export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path:
if (typeof o.max_withdrawable !== 'number') return new Error(`${path}.max_withdrawable: is not a number`) if (typeof o.max_withdrawable !== 'number') return new Error(`${path}.max_withdrawable: is not a number`)
if (opts.max_withdrawable_CustomCheck && !opts.max_withdrawable_CustomCheck(o.max_withdrawable)) return new Error(`${path}.max_withdrawable: custom check failed`) if (opts.max_withdrawable_CustomCheck && !opts.max_withdrawable_CustomCheck(o.max_withdrawable)) return new Error(`${path}.max_withdrawable: custom check failed`)
if (typeof o.ndebit !== 'string') return new Error(`${path}.ndebit: is not a string`)
if (opts.ndebit_CustomCheck && !opts.ndebit_CustomCheck(o.ndebit)) return new Error(`${path}.ndebit: custom check failed`)
if (typeof o.network_max_fee_bps !== 'number') return new Error(`${path}.network_max_fee_bps: is not a number`) if (typeof o.network_max_fee_bps !== 'number') return new Error(`${path}.network_max_fee_bps: is not a number`)
if (opts.network_max_fee_bps_CustomCheck && !opts.network_max_fee_bps_CustomCheck(o.network_max_fee_bps)) return new Error(`${path}.network_max_fee_bps: custom check failed`) if (opts.network_max_fee_bps_CustomCheck && !opts.network_max_fee_bps_CustomCheck(o.network_max_fee_bps)) return new Error(`${path}.network_max_fee_bps: custom check failed`)

View file

@ -354,6 +354,7 @@ message UserInfo{
int64 network_max_fee_bps = 6; int64 network_max_fee_bps = 6;
int64 network_max_fee_fixed = 7; int64 network_max_fee_fixed = 7;
string noffer = 8; string noffer = 8;
string ndebit = 9;
} }
message GetUserOperationsRequest{ message GetUserOperationsRequest{

View file

@ -63,7 +63,8 @@ export default class {
network_max_fee_bps: this.settings.lndSettings.feeRateBps, network_max_fee_bps: this.settings.lndSettings.feeRateBps,
network_max_fee_fixed: this.settings.lndSettings.feeFixedLimit, network_max_fee_fixed: this.settings.lndSettings.feeFixedLimit,
service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps, service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps,
noffer: encodeNoffer({ pubkey: app.nostr_public_key!, offer: appUser.identifier, priceType: PriceType.spontaneous, relay: "" }) noffer: encodeNoffer({ pubkey: app.nostr_public_key!, offer: appUser.identifier, priceType: PriceType.spontaneous, relay: "" }),
ndebit: encodeNdebit({ pubkey: app.nostr_public_key!, pointerId: appUser.identifier, relay: "" })
} }
} }

View file

@ -8,7 +8,7 @@ import { ApplicationUser } from '../storage/entity/ApplicationUser.js'
import { PubLogger, getLogger } from '../helpers/logger.js' import { PubLogger, getLogger } from '../helpers/logger.js'
import crypto from 'crypto' import crypto from 'crypto'
import { Application } from '../storage/entity/Application.js' import { Application } from '../storage/entity/Application.js'
import { encodeNoffer, PriceType } from '../../custom-nip19.js' import { encodeNdebit, encodeNoffer, PriceType } from '../../custom-nip19.js'
const TOKEN_EXPIRY_TIME = 2 * 60 * 1000 // 2 minutes, in milliseconds const TOKEN_EXPIRY_TIME = 2 * 60 * 1000 // 2 minutes, in milliseconds
@ -159,7 +159,8 @@ export default class {
network_max_fee_bps: this.settings.lndSettings.feeRateBps, network_max_fee_bps: this.settings.lndSettings.feeRateBps,
network_max_fee_fixed: this.settings.lndSettings.feeFixedLimit, network_max_fee_fixed: this.settings.lndSettings.feeFixedLimit,
service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps, service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps,
noffer: encodeNoffer({ pubkey: app.nostr_public_key!, offer: u.identifier, priceType: PriceType.spontaneous, relay: "" }) noffer: encodeNoffer({ pubkey: app.nostr_public_key!, offer: u.identifier, priceType: PriceType.spontaneous, relay: "" }),
ndebit: encodeNdebit({ pubkey: app.nostr_public_key!, pointerId: u.identifier, relay: "" })
}, },
max_withdrawable: this.paymentManager.GetMaxPayableInvoice(u.user.balance_sats, true) max_withdrawable: this.paymentManager.GetMaxPayableInvoice(u.user.balance_sats, true)
@ -199,7 +200,8 @@ export default class {
network_max_fee_bps: this.settings.lndSettings.feeRateBps, network_max_fee_bps: this.settings.lndSettings.feeRateBps,
network_max_fee_fixed: this.settings.lndSettings.feeFixedLimit, network_max_fee_fixed: this.settings.lndSettings.feeFixedLimit,
service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps, service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps,
noffer: encodeNoffer({ pubkey: app.nostr_public_key!, offer: user.identifier, priceType: PriceType.spontaneous, relay: "" }) noffer: encodeNoffer({ pubkey: app.nostr_public_key!, offer: user.identifier, priceType: PriceType.spontaneous, relay: "" }),
ndebit: encodeNdebit({ pubkey: app.nostr_public_key!, pointerId: user.identifier, relay: "" })
}, },
} }
} }