Skip to content

Commit

Permalink
feat: gRPC to change swap status (#500)
Browse files Browse the repository at this point in the history
* feat: add setswapstatus to boltz-cli

This commit adds a new `boltz-cli setswapstatus <swapID> <status>` command to update swap statuses
manually.

Closes #495

* fixup! feat: add setswapstatus to boltz-cli

* fixup! feat: add setswapstatus to boltz-cli

* fixup! feat: add setswapstatus to boltz-cli
  • Loading branch information
maybeast committed Mar 11, 2024
1 parent b2c14d6 commit 7853162
Show file tree
Hide file tree
Showing 11 changed files with 526 additions and 1 deletion.
27 changes: 27 additions & 0 deletions lib/cli/commands/SetSwapStatus.ts
@@ -0,0 +1,27 @@
import { Arguments } from 'yargs';
import { SetSwapStatusRequest } from '../../proto/boltzrpc_pb';
import { callback, loadBoltzClient } from '../Command';

export const command = 'setswapstatus <id> <status>';

export const describe = 'changes swap status in the database';

export const builder = {
id: {
type: 'string',
describe: 'ID of the swap',
},
status: {
type: 'string',
describe: 'swap status',
},
};

export const handler = (argv: Arguments<any>): void => {
const request = new SetSwapStatusRequest();

request.setId(argv.id);
request.setStatus(argv.status);

loadBoltzClient(argv).setSwapStatus(request, callback());
};
1 change: 1 addition & 0 deletions lib/grpc/GrpcServer.ts
Expand Up @@ -28,6 +28,7 @@ class GrpcServer {
addReferral: grpcService.addReferral,
sweepSwaps: grpcService.sweepSwaps,
rescan: grpcService.rescan,
setSwapStatus: grpcService.setSwapStatus,
});
}

Expand Down
13 changes: 13 additions & 0 deletions lib/grpc/GrpcService.ts
Expand Up @@ -172,6 +172,19 @@ class GrpcService {
});
};

public setSwapStatus: handleUnaryCall<
boltzrpc.SetSwapStatusRequest,
boltzrpc.SetSwapStatusResponse
> = async (call, callback) => {
await this.handleCallback(call, callback, async () => {
const { id, status } = call.request.toObject();

await this.service.setSwapStatus(id, status);

return new boltzrpc.SetSwapStatusResponse();
});
};

public sweepSwaps: handleUnaryCall<
boltzrpc.SweepSwapsRequest,
boltzrpc.SweepSwapsResponse
Expand Down
17 changes: 17 additions & 0 deletions lib/proto/boltzrpc_grpc_pb.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions lib/proto/boltzrpc_grpc_pb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions lib/proto/boltzrpc_pb.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7853162

Please sign in to comment.