Skip to content

Commit

Permalink
open channel: use AmountInput to display fundMax
Browse files Browse the repository at this point in the history
  • Loading branch information
myxmaster committed Jan 23, 2025
1 parent 0abecd8 commit e61170f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 36 deletions.
4 changes: 3 additions & 1 deletion components/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface AmountInputProps {
onAmountChange: (amount: string, satAmount: string | number) => void;
amount?: string;
locked?: boolean;
disabled?: boolean;
title?: string;
hideConversion?: boolean;
hideUnitChangeButton?: boolean;
Expand Down Expand Up @@ -129,6 +130,7 @@ export default class AmountInput extends React.Component<
onAmountChange,
title,
locked,
disabled,
hideConversion,
hideUnitChangeButton,
FiatStore,
Expand Down Expand Up @@ -164,7 +166,7 @@ export default class AmountInput extends React.Component<
onAmountChange(formatted, satAmount);
this.setState({ satAmount });
}}
locked={locked}
locked={locked || disabled}
prefix={
units !== 'sats' &&
(units === 'BTC'
Expand Down
60 changes: 25 additions & 35 deletions views/OpenChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Route } from '@react-navigation/native';
import { StackNavigationProp } from '@react-navigation/stack';
import { Tab } from 'react-native-elements';

import Amount from '../components/Amount';
import AmountInput from '../components/AmountInput';
import Button from '../components/Button';
import DropdownSetting from '../components/DropdownSetting';
Expand Down Expand Up @@ -569,40 +568,31 @@ export default class OpenChannel extends React.Component<

{!connectPeerOnly && (
<>
{!fundMax && (
<AmountInput
amount={local_funding_amount}
title={localeString(
'views.OpenChannel.localAmt'
)}
onAmountChange={(
amount: string,
satAmount: string | number
) => {
this.setState({
local_funding_amount: amount,
satAmount
});
}}
hideConversion={
local_funding_amount === 'all'
}
/>
)}

{(local_funding_amount === 'all' ||
fundMax) && (
<View style={{ marginBottom: 20 }}>
<Amount
sats={
utxoBalance > 0
? utxoBalance
: confirmedBlockchainBalance
}
toggleable
/>
</View>
)}
<AmountInput
amount={
fundMax
? utxoBalance > 0
? utxoBalance.toString()
: confirmedBlockchainBalance.toString()
: local_funding_amount
}
title={localeString(
'views.OpenChannel.localAmt'
)}
onAmountChange={(
amount: string,
satAmount: string | number
) => {
this.setState({
local_funding_amount: amount,
satAmount
});
}}
hideConversion={
local_funding_amount === 'all'
}
disabled={fundMax}
/>

{BackendUtils.supportsChannelFundMax() &&
additionalChannels.length === 0 && (
Expand Down

0 comments on commit e61170f

Please sign in to comment.