Skip to content

Commit 65f8716

Browse files
authored
Merge pull request #5368 from BitGo/BTC-1692
feat(sdk-core): add WalletBalance codecs
2 parents bf83b6b + 1d3f09d commit 65f8716

File tree

1 file changed

+79
-0
lines changed
  • modules/sdk-core/src/bitgo/lightning

1 file changed

+79
-0
lines changed

modules/sdk-core/src/bitgo/lightning/codecs.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,82 @@ export const UpdateLightningWallet = t.partial(
9191
);
9292

9393
export type UpdateLightningWallet = t.TypeOf<typeof UpdateLightningWallet>;
94+
95+
export const LndAmount = t.strict(
96+
{
97+
sat: t.string,
98+
msat: t.string,
99+
},
100+
'LndAmount'
101+
);
102+
103+
export type LndAmount = t.TypeOf<typeof LndAmount>;
104+
105+
export const ChannelBalance = t.strict(
106+
{
107+
/** The balance on your side of the channel and what you the user can spend. */
108+
localBalance: LndAmount,
109+
/** The balance on the other side of the channel, what your channel partner can controls. */
110+
remoteBalance: LndAmount,
111+
/** Sum of local unsettled balances. */
112+
unsettledLocalBalance: LndAmount,
113+
/** Sum of remote unsettled balances. */
114+
unsettledRemoteBalance: LndAmount,
115+
/** Sum of local pending balances. */
116+
pendingOpenLocalBalance: LndAmount,
117+
/** Sum of local remote balances. */
118+
pendingOpenRemoteBalance: LndAmount,
119+
},
120+
'ChannelBalance'
121+
);
122+
123+
export type ChannelBalance = t.TypeOf<typeof ChannelBalance>;
124+
125+
export const LndWalletBalance = t.strict(
126+
{
127+
/** Total balance, confirmed and unconfirmed */
128+
totalBalance: t.string,
129+
confirmedBalance: t.string,
130+
unconfirmedBalance: t.string,
131+
},
132+
'LndWalletBalance'
133+
);
134+
135+
export type LndWalletBalance = t.TypeOf<typeof LndWalletBalance>;
136+
137+
/**
138+
The balances as returned from lnd.
139+
140+
Wallet Balance
141+
https://api.lightning.community/api/lnd/lightning/wallet-balance/index.html
142+
143+
Channel Balance
144+
https://api.lightning.community/api/lnd/lightning/channel-balance/index.html
145+
*/
146+
export const LndBalance = t.strict(
147+
{
148+
offchain: ChannelBalance,
149+
onchain: LndWalletBalance,
150+
},
151+
'LndBalance'
152+
);
153+
154+
export type LndBalance = t.TypeOf<typeof LndBalance>;
155+
156+
export const LndGetBalancesResponse = t.strict(
157+
{
158+
inboundBalance: t.string,
159+
inboundPendingBalance: t.string,
160+
inboundUnsettledBalance: t.string,
161+
outboundBalance: t.string,
162+
outboundPendingBalance: t.string,
163+
outboundUnsettledBalance: t.string,
164+
// wallet balances, names forced by type in AbstractCoin
165+
spendableBalanceString: t.string,
166+
balanceString: t.string,
167+
confirmedBalanceString: t.string,
168+
},
169+
'LndGetBalancesResponse'
170+
);
171+
172+
export type LndGetBalancesResponse = t.TypeOf<typeof LndGetBalancesResponse>;

0 commit comments

Comments
 (0)