@@ -123,9 +123,11 @@ function ConfigurePage(): JSX.Element {
123
123
return true ;
124
124
}
125
125
126
- const errors : IFormErrors = { } ;
126
+ const { max_chan_receiving, max_chan_spending } = product ;
127
+ const max_chan_receiving_usd = Math . floor ( product . max_chan_receiving_usd ) ;
128
+ const max_chan_spending_usd = Math . floor ( product . max_chan_spending_usd ) ;
127
129
128
- // TODO check channel balance
130
+ const errors : IFormErrors = { } ;
129
131
130
132
if ( channelExpiry !== '' && Number ( channelExpiry ) < 1 ) {
131
133
errors . channelExpiry = `Minimum channel expiry is ${ product . min_chan_expiry } week${
@@ -135,26 +137,27 @@ function ConfigurePage(): JSX.Element {
135
137
errors . channelExpiry = `Maximum channel expiry is ${ product . max_chan_expiry } weeks` ;
136
138
}
137
139
138
- if ( Number ( remoteBalance ) > product . max_channel_size ) {
140
+ if ( Number ( remoteBalance ) > max_chan_receiving ) {
139
141
errors . remoteBalance = `Max receiving capacity is ${ numberWithSpaces (
140
- product . max_channel_size
141
- ) } sats`;
142
+ max_chan_receiving
143
+ ) } sats ($ ${ numberWithSpaces ( max_chan_receiving_usd ) } ) `;
142
144
} else if ( Number ( remoteBalance ) < product . min_channel_size ) {
143
145
errors . remoteBalance = `Minimum receiving capacity is ${ numberWithSpaces (
144
146
product . min_channel_size
145
147
) } sats`;
146
148
}
147
149
148
- if ( Number ( localBalance ) !== 0 && Number ( localBalance ) < product . min_channel_size ) {
149
- errors . localBalance = `Minimum spending balance is ${ numberWithSpaces (
150
- product . min_channel_size
151
- ) } sats`;
152
- }
153
-
154
- if ( Number ( localBalance ) !== 0 && Number ( localBalance ) > product . max_channel_size ) {
155
- errors . localBalance = `Max spending balance is ${ numberWithSpaces (
156
- product . max_channel_size
157
- ) } sats`;
150
+ if ( Number ( localBalance ) !== 0 ) {
151
+ if ( Number ( localBalance ) > max_chan_spending ) {
152
+ errors . localBalance = `Max spending balance is ${ numberWithSpaces (
153
+ max_chan_spending
154
+ ) } sats ($${ max_chan_spending_usd } )`;
155
+ } else if ( Number ( localBalance ) < product . min_channel_size ) {
156
+ // TODO remove this check if the min spending cap check is removed from API
157
+ errors . localBalance = `Minimum spending capacity is ${ numberWithSpaces (
158
+ product . min_channel_size
159
+ ) } sats`;
160
+ }
158
161
}
159
162
160
163
setFormErrors ( errors ) ;
@@ -171,9 +174,9 @@ function ConfigurePage(): JSX.Element {
171
174
const rBalance = Number ( remoteBalance ) ;
172
175
const lBalance = Number ( localBalance ) ;
173
176
174
- if ( rBalance < lBalance + product . min_channel_size ) {
175
- setRemoteBalance ( `${ lBalance + product . min_channel_size } ` ) ; // TODO use new min field
176
- }
177
+ // if (rBalance < lBalance + product.min_channel_size) {
178
+ // setRemoteBalance(`${lBalance + product.min_channel_size}`); // TODO use new min field
179
+ // }
177
180
} , [ localBalance ] ) ;
178
181
179
182
const onSetInput = ( str : string , set : Function ) : void => {
@@ -209,6 +212,8 @@ function ConfigurePage(): JSX.Element {
209
212
setChannelExpiry ( Math . trunc ( Number ( channelExpiry ) ) . toString ( ) ) ;
210
213
}
211
214
215
+ setGeneralError ( '' ) ;
216
+
212
217
isValid ( )
213
218
. then ( )
214
219
. catch ( ( e ) => console . error ( e ) ) ;
0 commit comments