Skip to content

Commit

Permalink
Merge pull request #2729 from sha-265/allow-cln-max-spend
Browse files Browse the repository at this point in the history
Add option to use all funds for channel with CLN
  • Loading branch information
kaloudis authored Jan 13, 2025
2 parents 6c15a61 + a5bb72b commit 7e5bd6f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
29 changes: 11 additions & 18 deletions backends/CLNRest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,24 +280,16 @@ export default class CLNRest {
const feeRate = `${new BigNumber(data.sat_per_vbyte || 0)
.times(1000)
.toString()}perkb`;
if (data.utxos && data.utxos.length > 0) {
request = {
id: data.id,
amount: data.satoshis,
feerate: feeRate,
announce: !data.privateChannel ? true : false,
minconf: data.min_confs,
utxos: data.utxos
};
} else {
request = {
id: data.id,
amount: data.satoshis,
feerate: feeRate,
announce: !data.privateChannel ? true : false,
minconf: data.min_confs
};
}

request = {
id: data.id,
amount: data.fundMax ? 'all' : data.satoshis,
feerate: feeRate,
announce: !data.privateChannel ? true : false,
minconf: data.min_confs
};

if (data.utxos && data.utxos.length > 0) request.utxos = data.utxos;

return this.postRequest('/v1/fundchannel', request);
};
Expand Down Expand Up @@ -420,6 +412,7 @@ export default class CLNRest {
supportsOnchainSendMax = () => true;
supportsOnchainBatching = () => false;
supportsChannelBatching = () => false;
supportsChannelFundMax = () => true;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
supportsBolt11BlindedRoutes = () => false;
Expand Down
1 change: 1 addition & 0 deletions backends/EmbeddedLND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export default class EmbeddedLND extends LND {
supportsOnchainSendMax = () => this.supports('v0.18.3');
supportsOnchainBatching = () => true;
supportsChannelBatching = () => true;
supportsChannelFundMax = () => true;
supportsLSPS1customMessage = () => true;
supportsLSPS1rest = () => false;
supportsOffers = () => false;
Expand Down
1 change: 1 addition & 0 deletions backends/LND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ export default class LND {
supportsOnchainSendMax = () => this.supports('v0.18.3');
supportsOnchainBatching = () => true;
supportsChannelBatching = () => true;
supportsChannelFundMax = () => true;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
supportsOffers = (): Promise<boolean> | boolean => false;
Expand Down
1 change: 1 addition & 0 deletions backends/LightningNodeConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ export default class LightningNodeConnect {
supportsOnchainSendMax = () => this.supports('v0.18.3');
supportsOnchainBatching = () => true;
supportsChannelBatching = () => true;
supportsChannelFundMax = () => true;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
supportsOffers = () => false;
Expand Down
1 change: 1 addition & 0 deletions utils/BackendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class BackendUtils {
supportsOnchainSendMax = () => this.call('supportsOnchainSendMax');
supportsOnchainBatching = () => this.call('supportsOnchainBatching');
supportsChannelBatching = () => this.call('supportsChannelBatching');
supportsChannelFundMax = () => this.call('supportsChannelFundMax');
supportsOffers = () => this.call('supportsOffers');
supportsBolt11BlindedRoutes = () =>
this.call('supportsBolt11BlindedRoutes');
Expand Down
2 changes: 1 addition & 1 deletion views/OpenChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ export default class OpenChannel extends React.Component<
</View>
)}

{BackendUtils.isLNDBased() &&
{BackendUtils.supportsChannelFundMax() &&
additionalChannels.length === 0 && (
<>
<Text
Expand Down

0 comments on commit 7e5bd6f

Please sign in to comment.