-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(express): lightning wallet creation step two
initialize signer lnd and update platform. Ticket: BTC-1356
- Loading branch information
1 parent
19c7408
commit 7449cfd
Showing
13 changed files
with
618 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import * as t from 'io-ts'; | ||
import { isIP } from 'net'; | ||
import { NonEmptyString } from 'io-ts-types'; | ||
|
||
function getCodecPair<C extends t.Mixed>(innerCodec: C): t.UnionC<[t.TypeC<{ lnbtc: C }>, t.TypeC<{ tlnbtc: C }>]> { | ||
return t.union([t.type({ lnbtc: innerCodec }), t.type({ tlnbtc: innerCodec })]); | ||
} | ||
|
||
export const IPCustomCodec = new t.Type<string, string, unknown>( | ||
'IPAddress', | ||
t.string.is, | ||
(input, context) => (typeof input === 'string' && isIP(input) ? t.success(input) : t.failure(input, context)), | ||
t.identity | ||
); | ||
|
||
export type IPAddress = t.TypeOf<typeof IPCustomCodec>; | ||
|
||
export const LightningSignerDetailsCodec = t.type({ | ||
url: t.string, | ||
tlsCert: t.string, | ||
}); | ||
|
||
export type LightningSignerDetails = t.TypeOf<typeof LightningSignerDetailsCodec>; | ||
|
||
export const LightningSignerConnectionsCodec = t.record(t.string, LightningSignerDetailsCodec); | ||
|
||
export type LightningSignerConnections = t.TypeOf<typeof LightningSignerConnectionsCodec>; | ||
|
||
export const KeyPurposeCodec = t.union([t.literal('userAuth'), t.literal('nodeAuth')], 'KeyPurpose'); | ||
|
||
export type KeyPurpose = t.TypeOf<typeof KeyPurposeCodec>; | ||
|
||
export const LightningAuthKeychainCoinSpecificCodec = getCodecPair(t.type({ purpose: KeyPurposeCodec })); | ||
|
||
export const LightningKeychainCodec = t.strict( | ||
{ | ||
id: NonEmptyString, | ||
pub: NonEmptyString, | ||
encryptedPrv: NonEmptyString, | ||
coinSpecific: t.undefined, | ||
source: t.literal('user'), | ||
}, | ||
'LightningKeychain' | ||
); | ||
|
||
export type LightningKeychain = t.TypeOf<typeof LightningKeychainCodec>; | ||
|
||
export const LightningAuthKeychainCodec = t.strict( | ||
{ | ||
id: NonEmptyString, | ||
pub: NonEmptyString, | ||
encryptedPrv: NonEmptyString, | ||
coinSpecific: LightningAuthKeychainCoinSpecificCodec, | ||
source: t.literal('user'), | ||
}, | ||
'LightningAuthKeychain' | ||
); | ||
|
||
export type LightningAuthKeychain = t.TypeOf<typeof LightningAuthKeychainCodec>; | ||
|
||
export const GetWalletStateResponseCodec = t.type( | ||
{ | ||
state: t.number, | ||
}, | ||
'GetWalletStateResponse' | ||
); | ||
|
||
export type GetWalletStateResponse = t.TypeOf<typeof GetWalletStateResponseCodec>; | ||
|
||
export const InitLightningWalletRequestCodec = t.strict( | ||
{ | ||
passphrase: NonEmptyString, | ||
signerIP: IPCustomCodec, | ||
signerTlsCert: NonEmptyString, | ||
signerTlsKey: NonEmptyString, | ||
watchOnlyIP: IPCustomCodec, | ||
}, | ||
'InitLightningWalletRequest' | ||
); | ||
|
||
export type InitLightningWalletRequest = t.TypeOf<typeof InitLightningWalletRequestCodec>; | ||
|
||
export const InitWalletResponseCodec = t.type( | ||
{ | ||
admin_macaroon: t.string, | ||
}, | ||
'InitWalletResponse' | ||
); | ||
|
||
export type InitWalletResponse = t.TypeOf<typeof InitWalletResponseCodec>; | ||
|
||
export const BakeMacaroonResponseCodec = t.type( | ||
{ | ||
macaroon: t.string, | ||
}, | ||
'BakeMacaroonResponse' | ||
); | ||
|
||
export type BakeMacaroonResponse = t.TypeOf<typeof BakeMacaroonResponseCodec>; |
Oops, something went wrong.