|
| 1 | +import * as t from 'io-ts'; |
| 2 | +import { httpRoute, httpRequest } from '@api-ts/io-ts-http'; |
| 3 | +import { BitgoExpressError } from '../../schemas/error'; |
| 4 | +import { WalletState } from '../../../lightning/codecs'; |
| 5 | + |
| 6 | +/** |
| 7 | + * Path parameters for getting lightning node state |
| 8 | + */ |
| 9 | +export const LightningStateParams = { |
| 10 | + /** A lightning coin name (e.g., lnbtc or tlnbtc) */ |
| 11 | + coin: t.string, |
| 12 | + /** The ID of the lightning self-custody wallet */ |
| 13 | + walletId: t.string, |
| 14 | +} as const; |
| 15 | + |
| 16 | +export const LightningStateResponse200 = t.type({ |
| 17 | + state: WalletState, |
| 18 | +}); |
| 19 | + |
| 20 | +/** |
| 21 | + * Response for getting lightning node state |
| 22 | + */ |
| 23 | +export const LightningStateResponse = { |
| 24 | + /** Current Lightning wallet/node state('NON_EXISTING' | 'LOCKED' | 'UNLOCKED' | 'RPC_ACTIVE' | 'SERVER_ACTIVE' | 'WAITING_TO_START') */ |
| 25 | + 200: LightningStateResponse200, |
| 26 | + /** BitGo Express error payload when the request is invalid (e.g., invalid coin or wallet not a self-custody lightning wallet). */ |
| 27 | + 400: BitgoExpressError, |
| 28 | +} as const; |
| 29 | + |
| 30 | +/** |
| 31 | + * Lightning - Get node state |
| 32 | + * |
| 33 | + * This is only used for self-custody lightning. Get the current state of the lightning node. |
| 34 | + * |
| 35 | + * @operationId express.lightning.getState |
| 36 | + */ |
| 37 | +export const GetLightningState = httpRoute({ |
| 38 | + method: 'GET', |
| 39 | + path: '/api/v2/{coin}/wallet/{walletId}/state', |
| 40 | + request: httpRequest({ |
| 41 | + params: LightningStateParams, |
| 42 | + }), |
| 43 | + response: LightningStateResponse, |
| 44 | +}); |
0 commit comments