policy update

This commit is contained in:
boufni95 2024-11-18 16:29:55 +00:00
parent 5417c49245
commit 79bd82b802
14 changed files with 6176 additions and 5875 deletions

View file

@ -220,6 +220,11 @@ The nostr server will send back a message response, and inside the body there wi
- input: [CallbackUrl](#CallbackUrl)
- output: [CallbackUrl](#CallbackUrl)
- UpdateChannelPolicy
- auth type: __Admin__
- input: [UpdateChannelPolicyRequest](#UpdateChannelPolicyRequest)
- This methods has an __empty__ __response__ body
- UseInviteLink
- auth type: __GuestWithPub__
- input: [UseInviteLinkRequest](#UseInviteLinkRequest)
@ -721,6 +726,13 @@ The nostr server will send back a message response, and inside the body there wi
- input: [CallbackUrl](#CallbackUrl)
- output: [CallbackUrl](#CallbackUrl)
- UpdateChannelPolicy
- auth type: __Admin__
- http method: __post__
- http route: __/api/admin/channel/policy/update__
- input: [UpdateChannelPolicyRequest](#UpdateChannelPolicyRequest)
- This methods has an __empty__ __response__ body
- UseInviteLink
- auth type: __GuestWithPub__
- http method: __post__
@ -823,6 +835,13 @@ The nostr server will send back a message response, and inside the body there wi
### CallbackUrl
- __url__: _string_
### ChannelPolicy
- __base_fee_msat__: _number_
- __fee_rate_ppm__: _number_
- __max_htlc_msat__: _number_
- __min_htlc_msat__: _number_
- __timelock_delta__: _number_
### CloseChannelRequest
- __force__: _boolean_
- __funding_txid__: _string_
@ -901,9 +920,6 @@ The nostr server will send back a message response, and inside the body there wi
### GetAppUserRequest
- __user_identifier__: _string_
### GetChannelPolicyRequest
- __channel_id__: _string_
### GetInviteTokenStateRequest
- __invite_token__: _string_
@ -1039,9 +1055,11 @@ The nostr server will send back a message response, and inside the body there wi
- __active__: _boolean_
- __capacity__: _number_
- __channel_id__: _string_
- __channel_point__: _string_
- __label__: _string_
- __lifetime__: _number_
- __local_balance__: _number_
- __policy__: _[ChannelPolicy](#ChannelPolicy)_ *this field is optional
- __remote_balance__: _number_
### OpenChannelRequest
@ -1138,6 +1156,10 @@ The nostr server will send back a message response, and inside the body there wi
- __amount__: _number_
- __invoice__: _string_
### UpdateChannelPolicyRequest
- __policy__: _[ChannelPolicy](#ChannelPolicy)_
- __update__: _[UpdateChannelPolicyRequest_update](#UpdateChannelPolicyRequest_update)_
### UsageMetric
- __auth_in_nano__: _number_
- __batch__: _boolean_

View file

@ -117,6 +117,7 @@ type Client struct {
SetMockAppUserBalance func(req SetMockAppUserBalanceRequest) error
SetMockInvoiceAsPaid func(req SetMockInvoiceAsPaidRequest) error
UpdateCallbackUrl func(req CallbackUrl) (*CallbackUrl, error)
UpdateChannelPolicy func(req UpdateChannelPolicyRequest) error
UseInviteLink func(req UseInviteLinkRequest) error
UserHealth func() error
}
@ -1692,6 +1693,30 @@ func NewClient(params ClientParams) *Client {
}
return &res, nil
},
UpdateChannelPolicy: func(req UpdateChannelPolicyRequest) error {
auth, err := params.RetrieveAdminAuth()
if err != nil {
return err
}
finalRoute := "/api/admin/channel/policy/update"
body, err := json.Marshal(req)
if err != nil {
return err
}
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
if err != nil {
return err
}
result := ResultError{}
err = json.Unmarshal(resBody, &result)
if err != nil {
return err
}
if result.Status == "ERROR" {
return fmt.Errorf(result.Reason)
}
return nil
},
UseInviteLink: func(req UseInviteLinkRequest) error {
auth, err := params.RetrieveGuestWithPubAuth()
if err != nil {

View file

@ -158,6 +158,13 @@ type BannedAppUser struct {
type CallbackUrl struct {
Url string `json:"url"`
}
type ChannelPolicy struct {
Base_fee_msat int64 `json:"base_fee_msat"`
Fee_rate_ppm int64 `json:"fee_rate_ppm"`
Max_htlc_msat int64 `json:"max_htlc_msat"`
Min_htlc_msat int64 `json:"min_htlc_msat"`
Timelock_delta int64 `json:"timelock_delta"`
}
type CloseChannelRequest struct {
Force bool `json:"force"`
Funding_txid string `json:"funding_txid"`
@ -236,9 +243,6 @@ type GetAppUserLNURLInfoRequest struct {
type GetAppUserRequest struct {
User_identifier string `json:"user_identifier"`
}
type GetChannelPolicyRequest struct {
Channel_id string `json:"channel_id"`
}
type GetInviteTokenStateRequest struct {
Invite_token string `json:"invite_token"`
}
@ -371,13 +375,15 @@ type NewInvoiceResponse struct {
Invoice string `json:"invoice"`
}
type OpenChannel struct {
Active bool `json:"active"`
Capacity int64 `json:"capacity"`
Channel_id string `json:"channel_id"`
Label string `json:"label"`
Lifetime int64 `json:"lifetime"`
Local_balance int64 `json:"local_balance"`
Remote_balance int64 `json:"remote_balance"`
Active bool `json:"active"`
Capacity int64 `json:"capacity"`
Channel_id string `json:"channel_id"`
Channel_point string `json:"channel_point"`
Label string `json:"label"`
Lifetime int64 `json:"lifetime"`
Local_balance int64 `json:"local_balance"`
Policy *ChannelPolicy `json:"policy"`
Remote_balance int64 `json:"remote_balance"`
}
type OpenChannelRequest struct {
Close_address string `json:"close_address"`
@ -473,6 +479,10 @@ type SetMockInvoiceAsPaidRequest struct {
Amount int64 `json:"amount"`
Invoice string `json:"invoice"`
}
type UpdateChannelPolicyRequest struct {
Policy *ChannelPolicy `json:"policy"`
Update *UpdateChannelPolicyRequest_update `json:"update"`
}
type UsageMetric struct {
Auth_in_nano int64 `json:"auth_in_nano"`
Batch bool `json:"batch"`
@ -581,3 +591,15 @@ type NPubLinking_state struct {
Linking_token *string `json:"linking_token"`
Unlinked *Empty `json:"unlinked"`
}
type UpdateChannelPolicyRequest_update_type string
const (
ALL UpdateChannelPolicyRequest_update_type = "all"
CHANNEL_POINT UpdateChannelPolicyRequest_update_type = "channel_point"
)
type UpdateChannelPolicyRequest_update struct {
Type UpdateChannelPolicyRequest_update_type `json:"type"`
All *Empty `json:"all"`
Channel_point *string `json:"channel_point"`
}

View file

@ -1543,6 +1543,28 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => {
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
})
if (!opts.allowNotImplementedMethods && !methods.UpdateChannelPolicy) throw new Error('method: UpdateChannelPolicy is not implemented')
app.post('/api/admin/channel/policy/update', async (req, res) => {
const info: Types.RequestInfo = { rpcName: 'UpdateChannelPolicy', batch: false, nostr: false, batchSize: 0}
const stats: Types.RequestStats = { startMs:req.startTimeMs || 0, start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n }
let authCtx: Types.AuthContext = {}
try {
if (!methods.UpdateChannelPolicy) throw new Error('method: UpdateChannelPolicy is not implemented')
const authContext = await opts.AdminAuthGuard(req.headers['authorization'])
authCtx = authContext
stats.guard = process.hrtime.bigint()
const request = req.body
const error = Types.UpdateChannelPolicyRequestValidate(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
const params = req.params
await methods.UpdateChannelPolicy({rpcName:'UpdateChannelPolicy', ctx:authContext , req: request})
stats.handle = process.hrtime.bigint()
res.json({status: 'OK'})
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
})
if (!opts.allowNotImplementedMethods && !methods.UseInviteLink) throw new Error('method: UseInviteLink is not implemented')
app.post('/api/guest/invite', async (req, res) => {
const info: Types.RequestInfo = { rpcName: 'UseInviteLink', batch: false, nostr: false, batchSize: 0}

View file

@ -810,6 +810,17 @@ export default (params: ClientParams) => ({
}
return { status: 'ERROR', reason: 'invalid response' }
},
UpdateChannelPolicy: async (request: Types.UpdateChannelPolicyRequest): Promise<ResultError | ({ status: 'OK' })> => {
const auth = await params.retrieveAdminAuth()
if (auth === null) throw new Error('retrieveAdminAuth() returned null')
let finalRoute = '/api/admin/channel/policy/update'
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
return data
}
return { status: 'ERROR', reason: 'invalid response' }
},
UseInviteLink: async (request: Types.UseInviteLinkRequest): Promise<ResultError | ({ status: 'OK' })> => {
const auth = await params.retrieveGuestWithPubAuth()
if (auth === null) throw new Error('retrieveGuestWithPubAuth() returned null')

View file

@ -594,6 +594,18 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ
}
return { status: 'ERROR', reason: 'invalid response' }
},
UpdateChannelPolicy: async (request: Types.UpdateChannelPolicyRequest): Promise<ResultError | ({ status: 'OK' })> => {
const auth = await params.retrieveNostrAdminAuth()
if (auth === null) throw new Error('retrieveNostrAdminAuth() returned null')
const nostrRequest: NostrRequest = {}
nostrRequest.body = request
const data = await send(params.pubDestination, {rpcName:'UpdateChannelPolicy',authIdentifier:auth, ...nostrRequest })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
return data
}
return { status: 'ERROR', reason: 'invalid response' }
},
UseInviteLink: async (request: Types.UseInviteLinkRequest): Promise<ResultError | ({ status: 'OK' })> => {
const auth = await params.retrieveNostrGuestWithPubAuth()
if (auth === null) throw new Error('retrieveNostrGuestWithPubAuth() returned null')

View file

@ -912,6 +912,22 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
break
case 'UpdateChannelPolicy':
try {
if (!methods.UpdateChannelPolicy) throw new Error('method: UpdateChannelPolicy is not implemented')
const authContext = await opts.NostrAdminAuthGuard(req.appId, req.authIdentifier)
stats.guard = process.hrtime.bigint()
authCtx = authContext
const request = req.body
const error = Types.UpdateChannelPolicyRequestValidate(request)
stats.validate = process.hrtime.bigint()
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback)
await methods.UpdateChannelPolicy({rpcName:'UpdateChannelPolicy', ctx:authContext , req: request})
stats.handle = process.hrtime.bigint()
res({status: 'OK'})
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
break
case 'UseInviteLink':
try {
if (!methods.UseInviteLink) throw new Error('method: UseInviteLink is not implemented')

View file

@ -7,8 +7,8 @@ export type RequestMetric = AuthContext & RequestInfo & RequestStats & { error?:
export type AdminContext = {
admin_id: string
}
export type AdminMethodInputs = AddApp_Input | AddPeer_Input | AuthApp_Input | BanUser_Input | CloseChannel_Input | CreateOneTimeInviteLink_Input | GetInviteLinkState_Input | GetSeed_Input | ListChannels_Input | LndGetInfo_Input | OpenChannel_Input
export type AdminMethodOutputs = AddApp_Output | AddPeer_Output | AuthApp_Output | BanUser_Output | CloseChannel_Output | CreateOneTimeInviteLink_Output | GetInviteLinkState_Output | GetSeed_Output | ListChannels_Output | LndGetInfo_Output | OpenChannel_Output
export type AdminMethodInputs = AddApp_Input | AddPeer_Input | AuthApp_Input | BanUser_Input | CloseChannel_Input | CreateOneTimeInviteLink_Input | GetInviteLinkState_Input | GetSeed_Input | ListChannels_Input | LndGetInfo_Input | OpenChannel_Input | UpdateChannelPolicy_Input
export type AdminMethodOutputs = AddApp_Output | AddPeer_Output | AuthApp_Output | BanUser_Output | CloseChannel_Output | CreateOneTimeInviteLink_Output | GetInviteLinkState_Output | GetSeed_Output | ListChannels_Output | LndGetInfo_Output | OpenChannel_Output | UpdateChannelPolicy_Output
export type AppContext = {
app_id: string
}
@ -249,6 +249,9 @@ export type SetMockInvoiceAsPaid_Output = ResultError | { status: 'OK' }
export type UpdateCallbackUrl_Input = {rpcName:'UpdateCallbackUrl', req: CallbackUrl}
export type UpdateCallbackUrl_Output = ResultError | ({ status: 'OK' } & CallbackUrl)
export type UpdateChannelPolicy_Input = {rpcName:'UpdateChannelPolicy', req: UpdateChannelPolicyRequest}
export type UpdateChannelPolicy_Output = ResultError | { status: 'OK' }
export type UseInviteLink_Input = {rpcName:'UseInviteLink', req: UseInviteLinkRequest}
export type UseInviteLink_Output = ResultError | { status: 'OK' }
@ -318,6 +321,7 @@ export type ServerMethods = {
SetMockAppUserBalance?: (req: SetMockAppUserBalance_Input & {ctx: AppContext }) => Promise<void>
SetMockInvoiceAsPaid?: (req: SetMockInvoiceAsPaid_Input & {ctx: GuestContext }) => Promise<void>
UpdateCallbackUrl?: (req: UpdateCallbackUrl_Input & {ctx: UserContext }) => Promise<CallbackUrl>
UpdateChannelPolicy?: (req: UpdateChannelPolicy_Input & {ctx: AdminContext }) => Promise<void>
UseInviteLink?: (req: UseInviteLink_Input & {ctx: GuestWithPubContext }) => Promise<void>
UserHealth?: (req: UserHealth_Input & {ctx: UserContext }) => Promise<void>
}
@ -846,6 +850,44 @@ export const CallbackUrlValidate = (o?: CallbackUrl, opts: CallbackUrlOptions =
return null
}
export type ChannelPolicy = {
base_fee_msat: number
fee_rate_ppm: number
max_htlc_msat: number
min_htlc_msat: number
timelock_delta: number
}
export const ChannelPolicyOptionalFields: [] = []
export type ChannelPolicyOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
base_fee_msat_CustomCheck?: (v: number) => boolean
fee_rate_ppm_CustomCheck?: (v: number) => boolean
max_htlc_msat_CustomCheck?: (v: number) => boolean
min_htlc_msat_CustomCheck?: (v: number) => boolean
timelock_delta_CustomCheck?: (v: number) => boolean
}
export const ChannelPolicyValidate = (o?: ChannelPolicy, opts: ChannelPolicyOptions = {}, path: string = 'ChannelPolicy::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.base_fee_msat !== 'number') return new Error(`${path}.base_fee_msat: is not a number`)
if (opts.base_fee_msat_CustomCheck && !opts.base_fee_msat_CustomCheck(o.base_fee_msat)) return new Error(`${path}.base_fee_msat: custom check failed`)
if (typeof o.fee_rate_ppm !== 'number') return new Error(`${path}.fee_rate_ppm: is not a number`)
if (opts.fee_rate_ppm_CustomCheck && !opts.fee_rate_ppm_CustomCheck(o.fee_rate_ppm)) return new Error(`${path}.fee_rate_ppm: custom check failed`)
if (typeof o.max_htlc_msat !== 'number') return new Error(`${path}.max_htlc_msat: is not a number`)
if (opts.max_htlc_msat_CustomCheck && !opts.max_htlc_msat_CustomCheck(o.max_htlc_msat)) return new Error(`${path}.max_htlc_msat: custom check failed`)
if (typeof o.min_htlc_msat !== 'number') return new Error(`${path}.min_htlc_msat: is not a number`)
if (opts.min_htlc_msat_CustomCheck && !opts.min_htlc_msat_CustomCheck(o.min_htlc_msat)) return new Error(`${path}.min_htlc_msat: custom check failed`)
if (typeof o.timelock_delta !== 'number') return new Error(`${path}.timelock_delta: is not a number`)
if (opts.timelock_delta_CustomCheck && !opts.timelock_delta_CustomCheck(o.timelock_delta)) return new Error(`${path}.timelock_delta: custom check failed`)
return null
}
export type CloseChannelRequest = {
force: boolean
funding_txid: string
@ -1318,24 +1360,6 @@ export const GetAppUserRequestValidate = (o?: GetAppUserRequest, opts: GetAppUse
return null
}
export type GetChannelPolicyRequest = {
channel_id: string
}
export const GetChannelPolicyRequestOptionalFields: [] = []
export type GetChannelPolicyRequestOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
channel_id_CustomCheck?: (v: string) => boolean
}
export const GetChannelPolicyRequestValidate = (o?: GetChannelPolicyRequest, opts: GetChannelPolicyRequestOptions = {}, path: string = 'GetChannelPolicyRequest::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.channel_id !== 'string') return new Error(`${path}.channel_id: is not a string`)
if (opts.channel_id_CustomCheck && !opts.channel_id_CustomCheck(o.channel_id)) return new Error(`${path}.channel_id: custom check failed`)
return null
}
export type GetInviteTokenStateRequest = {
invite_token: string
}
@ -2143,20 +2167,25 @@ export type OpenChannel = {
active: boolean
capacity: number
channel_id: string
channel_point: string
label: string
lifetime: number
local_balance: number
policy?: ChannelPolicy
remote_balance: number
}
export const OpenChannelOptionalFields: [] = []
export type OpenChannelOptionalField = 'policy'
export const OpenChannelOptionalFields: OpenChannelOptionalField[] = ['policy']
export type OpenChannelOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
checkOptionalsAreSet?: OpenChannelOptionalField[]
active_CustomCheck?: (v: boolean) => boolean
capacity_CustomCheck?: (v: number) => boolean
channel_id_CustomCheck?: (v: string) => boolean
channel_point_CustomCheck?: (v: string) => boolean
label_CustomCheck?: (v: string) => boolean
lifetime_CustomCheck?: (v: number) => boolean
local_balance_CustomCheck?: (v: number) => boolean
policy_Options?: ChannelPolicyOptions
remote_balance_CustomCheck?: (v: number) => boolean
}
export const OpenChannelValidate = (o?: OpenChannel, opts: OpenChannelOptions = {}, path: string = 'OpenChannel::root.'): Error | null => {
@ -2172,6 +2201,9 @@ export const OpenChannelValidate = (o?: OpenChannel, opts: OpenChannelOptions =
if (typeof o.channel_id !== 'string') return new Error(`${path}.channel_id: is not a string`)
if (opts.channel_id_CustomCheck && !opts.channel_id_CustomCheck(o.channel_id)) return new Error(`${path}.channel_id: custom check failed`)
if (typeof o.channel_point !== 'string') return new Error(`${path}.channel_point: is not a string`)
if (opts.channel_point_CustomCheck && !opts.channel_point_CustomCheck(o.channel_point)) return new Error(`${path}.channel_point: custom check failed`)
if (typeof o.label !== 'string') return new Error(`${path}.label: is not a string`)
if (opts.label_CustomCheck && !opts.label_CustomCheck(o.label)) return new Error(`${path}.label: custom check failed`)
@ -2181,6 +2213,12 @@ export const OpenChannelValidate = (o?: OpenChannel, opts: OpenChannelOptions =
if (typeof o.local_balance !== 'number') return new Error(`${path}.local_balance: is not a number`)
if (opts.local_balance_CustomCheck && !opts.local_balance_CustomCheck(o.local_balance)) return new Error(`${path}.local_balance: custom check failed`)
if (typeof o.policy === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('policy')) {
const policyErr = ChannelPolicyValidate(o.policy, opts.policy_Options, `${path}.policy`)
if (policyErr !== null) return policyErr
}
if (typeof o.remote_balance !== 'number') return new Error(`${path}.remote_balance: is not a number`)
if (opts.remote_balance_CustomCheck && !opts.remote_balance_CustomCheck(o.remote_balance)) return new Error(`${path}.remote_balance: custom check failed`)
@ -2717,6 +2755,31 @@ export const SetMockInvoiceAsPaidRequestValidate = (o?: SetMockInvoiceAsPaidRequ
return null
}
export type UpdateChannelPolicyRequest = {
policy: ChannelPolicy
update: UpdateChannelPolicyRequest_update
}
export const UpdateChannelPolicyRequestOptionalFields: [] = []
export type UpdateChannelPolicyRequestOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
policy_Options?: ChannelPolicyOptions
update_Options?: UpdateChannelPolicyRequest_updateOptions
}
export const UpdateChannelPolicyRequestValidate = (o?: UpdateChannelPolicyRequest, opts: UpdateChannelPolicyRequestOptions = {}, path: string = 'UpdateChannelPolicyRequest::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')
const policyErr = ChannelPolicyValidate(o.policy, opts.policy_Options, `${path}.policy`)
if (policyErr !== null) return policyErr
const updateErr = UpdateChannelPolicyRequest_updateValidate(o.update, opts.update_Options, `${path}.update`)
if (updateErr !== null) return updateErr
return null
}
export type UsageMetric = {
auth_in_nano: number
batch: boolean
@ -3184,6 +3247,42 @@ export const NPubLinking_stateValidate = (o?: NPubLinking_state, opts:NPubLinkin
if (unlinkedErr !== null) return unlinkedErr
break
default:
return new Error(path + ': unknown type '+ stringType)
}
return null
}
export enum UpdateChannelPolicyRequest_update_type {
ALL = 'all',
CHANNEL_POINT = 'channel_point',
}
export const enumCheckUpdateChannelPolicyRequest_update_type = (e?: UpdateChannelPolicyRequest_update_type): boolean => {
for (const v in UpdateChannelPolicyRequest_update_type) if (e === v) return true
return false
}
export type UpdateChannelPolicyRequest_update =
{type:UpdateChannelPolicyRequest_update_type.ALL, all:Empty}|
{type:UpdateChannelPolicyRequest_update_type.CHANNEL_POINT, channel_point:string}
export type UpdateChannelPolicyRequest_updateOptions = {
all_Options?: EmptyOptions
channel_point_CustomCheck?: (v: string) => boolean
}
export const UpdateChannelPolicyRequest_updateValidate = (o?: UpdateChannelPolicyRequest_update, opts:UpdateChannelPolicyRequest_updateOptions = {}, path: string = 'UpdateChannelPolicyRequest_update::root.'): Error | null => {
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
const stringType: string = o.type
switch (o.type) {
case UpdateChannelPolicyRequest_update_type.ALL:
const allErr = EmptyValidate(o.all, opts.all_Options, `${path}.all`)
if (allErr !== null) return allErr
break
case UpdateChannelPolicyRequest_update_type.CHANNEL_POINT:
if (typeof o.channel_point !== 'string') return new Error(`${path}.channel_point: is not a string`)
if (opts.channel_point_CustomCheck && !opts.channel_point_CustomCheck(o.channel_point)) return new Error(`${path}.channel_point: custom check failed`)
break
default:
return new Error(path + ': unknown type '+ stringType)

View file

@ -151,6 +151,13 @@ service LightningPub {
option (nostr) = true;
}
rpc UpdateChannelPolicy (structs.UpdateChannelPolicyRequest) returns (structs.Empty) {
option (auth_type) = "Admin";
option (http_method) = "post";
option (http_route) = "/api/admin/channel/policy/update";
option (nostr) = true;
}
rpc OpenChannel(structs.OpenChannelRequest) returns (structs.OpenChannelResponse) {
option (auth_type) = "Admin";
option (http_method) = "post";

View file

@ -88,6 +88,22 @@ message RoutingEvent {
bool forward_fail_event = 12;
}
message ChannelPolicy {
int64 base_fee_msat= 1;
int64 fee_rate_ppm = 2;
int64 max_htlc_msat = 3;
int64 min_htlc_msat = 4;
int64 timelock_delta = 5;
}
message UpdateChannelPolicyRequest {
oneof update {
string channel_point = 1;
Empty all = 2;
}
ChannelPolicy policy = 3;
}
message OpenChannel {
string channel_id = 1;
int64 capacity = 2;
@ -96,6 +112,8 @@ message OpenChannel {
int64 local_balance=5;
int64 remote_balance = 6;
string label = 7;
string channel_point = 8;
optional ChannelPolicy policy = 9;
}
message ClosedChannel {
string channel_id = 1;
@ -131,10 +149,6 @@ message LndChannels {
repeated OpenChannel open_channels = 1;
}
message GetChannelPolicyRequest {
string channel_id = 1;
}
message OpenChannelRequest{