From 049bdcdfca22f4c4edc4f3b146d06c361094afaf Mon Sep 17 00:00:00 2001 From: Nitesh Balusu Date: Tue, 31 Jan 2023 20:59:11 +0530 Subject: [PATCH] add avoid-high-fee-routes to send command Signed-off-by: Nitesh Balusu --- SERVER.md | 1 + src/client/commands.ts | 1 + src/client/pages/commands/Send.tsx | 19 +++++++++++++++++++ src/client/pages/result/SendResult.tsx | 1 + src/server/commands/send/send_command.ts | 2 ++ src/shared/commands.dto.ts | 5 +++++ src/shared/types.ts | 1 + 7 files changed, 30 insertions(+) diff --git a/SERVER.md b/SERVER.md index ab9463e..6c719f6 100644 --- a/SERVER.md +++ b/SERVER.md @@ -1751,6 +1751,7 @@ http://localhost:8055/api/send [in_through]: [is_dry_run]: [is_omitting_message_from]: + [is_strict_max_fee]: [max_fee]: [max_fee_rate]: [message]: diff --git a/src/client/commands.ts b/src/client/commands.ts index 1874e5c..7f8ae2d 100644 --- a/src/client/commands.ts +++ b/src/client/commands.ts @@ -442,6 +442,7 @@ const commands: Commands = [ in_through: 'In', is_dry_run: 'Dryrun', is_omitting_message_from: 'messageOmitFromKey', + is_strict_max_fee: 'AvoidHighFeeRoutes', max_fee: 'MaxFee', max_fee_rate: 'MaxFeeRate', message: 'Message', diff --git a/src/client/pages/commands/Send.tsx b/src/client/pages/commands/Send.tsx index d6e8f3a..98258f3 100644 --- a/src/client/pages/commands/Send.tsx +++ b/src/client/pages/commands/Send.tsx @@ -28,6 +28,7 @@ const Send = () => { const [destination, setDestination] = useState(''); const [inPeer, setInPeer] = useState(undefined); const [isDryrun, setIsDryRun] = useState(false); + const [isStrictMaxFee, setIsStrictMaxFee] = useState(false); const [outPeer, setOutPeer] = useState(undefined); const [maxFee, setMaxFee] = useState('1337'); const [maxFeeRate, setMaxFeeRate] = useState(''); @@ -62,6 +63,10 @@ const Send = () => { setAvoid(newFormValues); }; + const handleAvoidHighFeeRoutes = () => { + setIsStrictMaxFee((previousState: boolean) => !previousState); + }; + const handleDryrunChange = () => { setIsDryRun((previousState: boolean) => !previousState); }; @@ -99,6 +104,7 @@ const Send = () => { in_through: inPeer, is_dry_run: isDryrun, is_omitting_message_from: isOmittingMessageFrom, + is_strict_max_fee: isStrictMaxFee, max_fee: Number(maxFee), max_fee_rate: Number(maxFeeRate), out_through: outPeer, @@ -189,6 +195,19 @@ const Send = () => { onChange={handleMaxFeeRateChange} style={styles.textField} /> + + + } + label={SendCommand.flags.is_strict_max_fee} + /> + { in_through: router.query.in_through, is_dry_run: router.query.is_dry_run, is_omitting_message_from: router.query.is_omitting_message_from, + is_strict_max_fee: router.query.is_strict_max_fee, max_fee: router.query.max_fee, max_fee_rate: router.query.max_fee_rate, message: router.query.message, diff --git a/src/server/commands/send/send_command.ts b/src/server/commands/send/send_command.ts index 0712b9a..c936ed6 100644 --- a/src/server/commands/send/send_command.ts +++ b/src/server/commands/send/send_command.ts @@ -19,6 +19,7 @@ import { readFile } from 'fs'; [in_through]: [is_dry_run]: [is_omitting_message_from]: + [is_strict_max_fee]: lnd: logger: max_fee: @@ -61,6 +62,7 @@ const sendCommand = async ({ args, lnd, logger }: Args): Promise<{ result: any } in_through: args.in_through, is_dry_run: args.is_dry_run, is_omitting_message_from: args.is_omitting_message_from, + is_strict_max_fee: !!args.is_strict_max_fee, max_fee: args.max_fee || 1337, max_fee_rate: args.max_fee_rate || undefined, message: args.message, diff --git a/src/shared/commands.dto.ts b/src/shared/commands.dto.ts index 349ac50..81b2920 100644 --- a/src/shared/commands.dto.ts +++ b/src/shared/commands.dto.ts @@ -1020,6 +1020,11 @@ export class sendDto { @IsBoolean() is_omitting_message_from: boolean; + @Transform(({ value }) => toBoolean(value)) + @IsOptional() + @IsBoolean() + is_strict_max_fee: boolean; + @Transform(({ value }) => toNumber(value)) @IsOptional() @IsNumber() diff --git a/src/shared/types.ts b/src/shared/types.ts index 25dc53f..d8fa0f9 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -308,6 +308,7 @@ export type commandSend = { in_through: string; is_dry_run: boolean; is_omitting_message_from: boolean; + is_strict_max_fee: boolean; max_fee: number; max_fee_rate: number; message: string;