diff --git a/proto/autogenerated/client.md b/proto/autogenerated/client.md index 4d8d30c0..6884a4cb 100644 --- a/proto/autogenerated/client.md +++ b/proto/autogenerated/client.md @@ -652,7 +652,6 @@ The nostr server will send back a message response, and inside the body there wi - __identifier__: _string_ - __info__: _[UserInfo](#UserInfo)_ - __max_withdrawable__: _number_ - - __noffer__: _string_ ### Application - __balance__: _number_ @@ -966,6 +965,7 @@ The nostr server will send back a message response, and inside the body there wi - __max_withdrawable__: _number_ - __network_max_fee_bps__: _number_ - __network_max_fee_fixed__: _number_ + - __noffer__: _string_ - __service_fee_bps__: _number_ - __userId__: _string_ - __user_identifier__: _string_ diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index 87a44181..d3c2c131 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -510,7 +510,6 @@ export type AppUser = { identifier: string info: UserInfo max_withdrawable: number - noffer: string } export const AppUserOptionalFields: [] = [] export type AppUserOptions = OptionsBaseMessage & { @@ -518,7 +517,6 @@ export type AppUserOptions = OptionsBaseMessage & { identifier_CustomCheck?: (v: string) => boolean info_Options?: UserInfoOptions max_withdrawable_CustomCheck?: (v: number) => boolean - noffer_CustomCheck?: (v: string) => boolean } export const AppUserValidate = (o?: AppUser, opts: AppUserOptions = {}, path: string = 'AppUser::root.'): Error | null => { if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') @@ -534,9 +532,6 @@ export const AppUserValidate = (o?: AppUser, opts: AppUserOptions = {}, path: st 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 (typeof o.noffer !== 'string') return new Error(`${path}.noffer: is not a string`) - if (opts.noffer_CustomCheck && !opts.noffer_CustomCheck(o.noffer)) return new Error(`${path}.noffer: custom check failed`) - return null } @@ -2361,6 +2356,7 @@ export type UserInfo = { max_withdrawable: number network_max_fee_bps: number network_max_fee_fixed: number + noffer: string service_fee_bps: number userId: string user_identifier: string @@ -2372,6 +2368,7 @@ export type UserInfoOptions = OptionsBaseMessage & { max_withdrawable_CustomCheck?: (v: number) => boolean network_max_fee_bps_CustomCheck?: (v: number) => boolean network_max_fee_fixed_CustomCheck?: (v: number) => boolean + noffer_CustomCheck?: (v: string) => boolean service_fee_bps_CustomCheck?: (v: number) => boolean userId_CustomCheck?: (v: string) => boolean user_identifier_CustomCheck?: (v: string) => boolean @@ -2392,6 +2389,9 @@ export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path: if (typeof o.network_max_fee_fixed !== 'number') return new Error(`${path}.network_max_fee_fixed: is not a number`) if (opts.network_max_fee_fixed_CustomCheck && !opts.network_max_fee_fixed_CustomCheck(o.network_max_fee_fixed)) return new Error(`${path}.network_max_fee_fixed: custom check failed`) + if (typeof o.noffer !== 'string') return new Error(`${path}.noffer: is not a string`) + if (opts.noffer_CustomCheck && !opts.noffer_CustomCheck(o.noffer)) return new Error(`${path}.noffer: custom check failed`) + if (typeof o.service_fee_bps !== 'number') return new Error(`${path}.service_fee_bps: is not a number`) if (opts.service_fee_bps_CustomCheck && !opts.service_fee_bps_CustomCheck(o.service_fee_bps)) return new Error(`${path}.service_fee_bps: custom check failed`) diff --git a/proto/service/structs.proto b/proto/service/structs.proto index 60dbcc37..bedb45bf 100644 --- a/proto/service/structs.proto +++ b/proto/service/structs.proto @@ -192,7 +192,6 @@ message AppUser { string identifier = 1; UserInfo info = 2; int64 max_withdrawable = 3; - string noffer = 4; } message AddAppInvoiceRequest { @@ -354,6 +353,7 @@ message UserInfo{ int64 service_fee_bps = 5; int64 network_max_fee_bps = 6; int64 network_max_fee_fixed = 7; + string noffer = 8; } message GetUserOperationsRequest{ diff --git a/src/services/main/appUserManager.ts b/src/services/main/appUserManager.ts index 6da520ae..1909be9d 100644 --- a/src/services/main/appUserManager.ts +++ b/src/services/main/appUserManager.ts @@ -4,6 +4,7 @@ import * as Types from '../../../proto/autogenerated/ts/types.js' import { MainSettings } from './settings.js' import ApplicationManager from './applicationManager.js' +import { encodeNoffer, PriceType } from '../../custom-nip19.js' export default class { storage: Storage settings: MainSettings @@ -59,7 +60,8 @@ export default class { user_identifier: appUser.identifier, network_max_fee_bps: this.settings.lndSettings.feeRateBps, 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: "" }) } } diff --git a/src/services/main/applicationManager.ts b/src/services/main/applicationManager.ts index 4c8d0b0e..a5c2ff3c 100644 --- a/src/services/main/applicationManager.ts +++ b/src/services/main/applicationManager.ts @@ -158,10 +158,10 @@ export default class { user_identifier: u.identifier, network_max_fee_bps: this.settings.lndSettings.feeRateBps, 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: "" }), max_withdrawable: this.paymentManager.GetMaxPayableInvoice(u.user.balance_sats, true) } } @@ -198,8 +198,9 @@ export default class { user_identifier: user.identifier, network_max_fee_bps: this.settings.lndSettings.feeRateBps, network_max_fee_fixed: this.settings.lndSettings.feeFixedLimit, - service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps - }, noffer: encodeNoffer({ pubkey: app.nostr_public_key!, offer: user.identifier, priceType: PriceType.spontaneous, relay: "" }) + service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps, + noffer: encodeNoffer({ pubkey: app.nostr_public_key!, offer: user.identifier, priceType: PriceType.spontaneous, relay: "" }) + }, } }