Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
add avoid-high-fee-routes to send command
Browse files Browse the repository at this point in the history
Signed-off-by: Nitesh Balusu <[email protected]>
  • Loading branch information
niteshbalusu11 committed Jan 31, 2023
1 parent d279cad commit 049bdcd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions SERVER.md
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,7 @@ http://localhost:8055/api/send
[in_through]: <Pay In Through Peer String>
[is_dry_run]: <Do Not Push Payment Bool>
[is_omitting_message_from]: <Do Not Include From Key In Message Bool>
[is_strict_max_fee]: <Avoid High Fee Routes Boolean>
[max_fee]: <Maximum Fee Tokens Number>
[max_fee_rate]: <Max Fee Rate Tokens Per Million Number>
[message]: <Message to Include With Payment String>
Expand Down
1 change: 1 addition & 0 deletions src/client/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 19 additions & 0 deletions src/client/pages/commands/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down Expand Up @@ -62,6 +63,10 @@ const Send = () => {
setAvoid(newFormValues);
};

const handleAvoidHighFeeRoutes = () => {
setIsStrictMaxFee((previousState: boolean) => !previousState);
};

const handleDryrunChange = () => {
setIsDryRun((previousState: boolean) => !previousState);
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -189,6 +195,19 @@ const Send = () => {
onChange={handleMaxFeeRateChange}
style={styles.textField}
/>

<FormControlLabel
style={styles.switch}
control={
<StandardSwitch
checked={isStrictMaxFee}
onChange={handleAvoidHighFeeRoutes}
id={SendCommand.flags.is_strict_max_fee}
/>
}
label={SendCommand.flags.is_strict_max_fee}
/>

<TextField
type="text"
placeholder={`${SendCommand.flags.message} (Message to include with payment)`}
Expand Down
1 change: 1 addition & 0 deletions src/client/pages/result/SendResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const SendResult = () => {
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,
Expand Down
2 changes: 2 additions & 0 deletions src/server/commands/send/send_command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { readFile } from 'fs';
[in_through]: <Pay In Through Peer String>
[is_dry_run]: <Do Not Push Payment Bool>
[is_omitting_message_from]: <Do Not Include From Key In Message Bool>
[is_strict_max_fee]: <Avoid High Fee Routes Boolean>
lnd: <Authenticated LND API Object>
logger: <Winston Logger Object>
max_fee: <Maximum Fee Tokens Number>
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/shared/commands.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 049bdcd

Please sign in to comment.