Skip to content

Commit

Permalink
feat(transfer): add manual channel with external node (#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwltr authored Sep 26, 2024
1 parent 61a8f6e commit 50c37b9
Show file tree
Hide file tree
Showing 61 changed files with 1,641 additions and 811 deletions.
17 changes: 12 additions & 5 deletions __tests__/reselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ describe('Reselect', () => {
const received1 = transferLimitsSelector(s1);
const expected1 = {
minChannelSize: 11,
maxChannelSize: 180,
maxClientBalance: 90,
maxChannelSize: 190,
maxClientBalance: 95,
};

expect(received1).toMatchObject(expected1);
Expand All @@ -156,38 +156,45 @@ describe('Reselect', () => {
const received2 = transferLimitsSelector(s2);
const expected2 = {
minChannelSize: 11,
maxChannelSize: 180,
maxChannelSize: 190,
maxClientBalance: 40,
};

expect(received2).toMatchObject(expected2);
});

it('should calculate limits with existing LN channels', () => {
const btNodeId =
'03b9a456fb45d5ac98c02040d39aec77fa3eeb41fd22cf40b862b393bcfc43473a';
// max value is limited by leftover node capacity
const s1 = cloneDeep(s);
s1.wallet.wallets.wallet0.balance.bitcoinRegtest = 1000;
s1.blocktank.info.nodes = [
{ alias: 'node1', pubkey: btNodeId, connectionStrings: [] },
];
s1.blocktank.info.options = {
...s1.blocktank.info.options,
minChannelSizeSat: 10,
maxChannelSizeSat: 200,
};

const channel1 = {
channel_id: 'channel1',
status: EChannelStatus.open,
is_channel_ready: true,
outbound_capacity_sat: 1,
balance_sat: 2,
channel_value_satoshis: 100,
counterparty_node_id: btNodeId,
} as TChannel;
const lnWallet = s1.lightning.nodes.wallet0;
lnWallet.channels.bitcoinRegtest = { channel1 };

const received1 = transferLimitsSelector(s1);
const expected1 = {
minChannelSize: 11,
maxChannelSize: 100,
maxClientBalance: 50,
maxChannelSize: 90,
maxClientBalance: 45,
};

expect(received1).toMatchObject(expected1);
Expand Down
4 changes: 3 additions & 1 deletion __tests__/todos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ describe('Todos selector', () => {
type: ETransferType.open,
status: ETransferStatus.pending,
amount: 100000,
confirmsIn: 1,
orderId: 'order1',
});
expect(todosFullSelector(state)).toEqual(
Expand All @@ -144,7 +145,7 @@ describe('Todos selector', () => {
);
});

it('should return lightningSettingUpTodo for addtional pending transfers to spending', () => {
it('should return lightningSettingUpTodo for additional pending transfers to spending', () => {
const state = cloneDeep(s);
const channel1: Partial<TChannel> = {
channel_id: 'channel1',
Expand All @@ -159,6 +160,7 @@ describe('Todos selector', () => {
type: ETransferType.open,
status: ETransferStatus.pending,
amount: 100000,
confirmsIn: 1,
orderId: 'order1',
});
expect(todosFullSelector(state)).toEqual(
Expand Down
Loading

0 comments on commit 50c37b9

Please sign in to comment.