Skip to content

Commit

Permalink
WIP: LND: wire up Simple Taproot Channels on OpenChannel call + in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Aug 25, 2023
1 parent 6480c9e commit 5f3d6ef
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 33 deletions.
3 changes: 2 additions & 1 deletion backends/EmbeddedLND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export default class EmbeddedLND extends LND {
data.sat_per_vbyte ? Number(data.sat_per_vbyte) : undefined,
data.scidAlias,
data.min_confs,
data.spend_unconfirmed
data.spend_unconfirmed,
data.simpleTaprootChannel
);
connectPeer = async (data: any) =>
await connectPeer(data.addr.pubkey, data.addr.host, data.perm);
Expand Down
32 changes: 23 additions & 9 deletions backends/LND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,29 @@ export default class LND {
getPayments = () => this.getRequest('/v1/payments');
getNewAddress = (data: any) => this.getRequest('/v1/newaddress', data);
openChannel = (data: OpenChannelRequest) =>
this.postRequest('/v1/channels', {
private: data.privateChannel,
scid_alias: data.scidAlias,
local_funding_amount: data.local_funding_amount,
min_confs: data.min_confs,
node_pubkey_string: data.node_pubkey_string,
sat_per_vbyte: data.sat_per_vbyte,
spend_unconfirmed: data.spend_unconfirmed
});
this.postRequest(
'/v1/channels',
data.simpleTaprootChannel
? {
private: data.privateChannel,
scid_alias: data.scidAlias,
local_funding_amount: data.local_funding_amount,
min_confs: data.min_confs,
node_pubkey_string: data.node_pubkey_string,
sat_per_vbyte: data.sat_per_vbyte,
spend_unconfirmed: data.spend_unconfirmed,
commitment_type: 'SIMPLE_TAPROOT'
}
: {
private: data.privateChannel,
scid_alias: data.scidAlias,
local_funding_amount: data.local_funding_amount,
min_confs: data.min_confs,
node_pubkey_string: data.node_pubkey_string,
sat_per_vbyte: data.sat_per_vbyte,
spend_unconfirmed: data.spend_unconfirmed
}
);
openChannelStream = (data: OpenChannelRequest) =>
this.wsReq('/v1/channels/stream', 'POST', data);
connectPeer = (data: any) => this.postRequest('/v1/peers', data);
Expand Down
32 changes: 23 additions & 9 deletions backends/LightningNodeConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,29 @@ export default class LightningNodeConnect {

openChannel = async (data: OpenChannelRequest) =>
await this.lnc.lnd.lightning
.openChannelSync({
private: data.privateChannel,
scid_alias: data.scidAlias,
local_funding_amount: data.local_funding_amount,
min_confs: data.min_confs,
node_pubkey_string: data.node_pubkey_string,
sat_per_vbyte: data.sat_per_vbyte,
spend_unconfirmed: data.spend_unconfirmed
})
.openChannelSync(
data.simpleTaprootChannel
? {
private: data.privateChannel,
scid_alias: data.scidAlias,
local_funding_amount: data.local_funding_amount,
min_confs: data.min_confs,
node_pubkey_string: data.node_pubkey_string,
sat_per_vbyte: data.sat_per_vbyte,
spend_unconfirmed: data.spend_unconfirmed,
commitment_type:
lnrpc.CommitmentType['SIMPLE_TAPROOT']
}
: {
private: data.privateChannel,
scid_alias: data.scidAlias,
local_funding_amount: data.local_funding_amount,
min_confs: data.min_confs,
node_pubkey_string: data.node_pubkey_string,
sat_per_vbyte: data.sat_per_vbyte,
spend_unconfirmed: data.spend_unconfirmed
}
)
.then((data: lnrpc.ChannelPoint) => snakeize(data));
// TODO add with external accounts
// openChannelStream = (data: OpenChannelRequest) =>
Expand Down
3 changes: 2 additions & 1 deletion lndmobile/LndMobileInjection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ export interface ILndMobileInjections {
feeRateSat?: number,
scidAlias?: boolean,
min_confs?: number,
spend_unconfirmed?: boolean
spend_unconfirmed?: boolean,
simpleTaprootChannel?: boolean
) => Promise<lnrpc.ChannelPoint>;
openChannelAll: (
pubkey: string,
Expand Down
41 changes: 28 additions & 13 deletions lndmobile/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const openChannel = async (
fee_rate_sat?: number,
scidAlias?: boolean,
min_confs?: number,
spend_unconfirmed?: boolean
spend_unconfirmed?: boolean,
simpleTaprootChannel?: boolean
): Promise<lnrpc.ChannelPoint> => {
const response = await sendCommand<
lnrpc.IOpenChannelRequest,
Expand All @@ -29,18 +30,32 @@ export const openChannel = async (
request: lnrpc.OpenChannelRequest,
response: lnrpc.ChannelPoint,
method: 'OpenChannelSync',
options: {
node_pubkey_string: pubkey,
local_funding_amount: Long.fromValue(amount),
target_conf: fee_rate_sat ? undefined : 2,
private: private_channel,
sat_per_vbyte: fee_rate_sat
? Long.fromValue(fee_rate_sat)
: undefined,
scid_alias: scidAlias,
min_confs,
spend_unconfirmed
}
options: simpleTaprootChannel
? {
node_pubkey_string: pubkey,
local_funding_amount: Long.fromValue(amount),
target_conf: fee_rate_sat ? undefined : 2,
private: private_channel,
sat_per_vbyte: fee_rate_sat
? Long.fromValue(fee_rate_sat)
: undefined,
scid_alias: scidAlias,
min_confs,
spend_unconfirmed,
commitment_type: lnrpc.CommitmentType.SIMPLE_TAPROOT
}
: {
node_pubkey_string: pubkey,
local_funding_amount: Long.fromValue(amount),
target_conf: fee_rate_sat ? undefined : 2,
private: private_channel,
sat_per_vbyte: fee_rate_sat
? Long.fromValue(fee_rate_sat)
: undefined,
scid_alias: scidAlias,
min_confs,
spend_unconfirmed
}
});
return response;
};
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"views.Wallet.Channels.filters": "Filters",
"views.OpenChannel.announceChannel": "Announce channel",
"views.OpenChannel.scidAlias": "Attempt to use SCID alias",
"views.OpenChannel.simpleTaprootChannel": "Attempt to open Simple Taproot Channel",
"views.OpenChannel.openChannelToOlympus": "Open channel to Olympus",
"views.OpenChannel.peerToOlympus": "Peer to Olympus",
"views.Wallet.BalancePane.sync.title": "Finishing sync",
Expand Down
1 change: 1 addition & 0 deletions models/OpenChannelRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class OpenChannelRequest extends BaseModel {
public utxos?: string[];
public privateChannel?: boolean;
public scidAlias?: boolean;
public simpleTaprootChannel?: boolean;

constructor(data?: any) {
super(data);
Expand Down
29 changes: 29 additions & 0 deletions views/OpenChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface OpenChannelState {
sat_per_vbyte: string;
privateChannel: boolean;
scidAlias: boolean;
simpleTaprootChannel: boolean;
host: string;
suggestImport: string;
utxos: Array<string>;
Expand Down Expand Up @@ -93,6 +94,7 @@ export default class OpenChannel extends React.Component<
sat_per_vbyte: '2',
privateChannel: true,
scidAlias: true,
simpleTaprootChannel: BackendUtils.supportsSimpleTaprootChannels(),
host: '',
suggestImport: '',
utxos: [],
Expand Down Expand Up @@ -259,6 +261,7 @@ export default class OpenChannel extends React.Component<
utxoBalance,
privateChannel,
scidAlias,
simpleTaprootChannel,
connectPeerOnly
} = this.state;
const { settings } = SettingsStore;
Expand Down Expand Up @@ -616,6 +619,32 @@ export default class OpenChannel extends React.Component<
/>
</>
)}

{BackendUtils.supportsSimpleTaprootChannels() && (
<>
<Text
style={{
top: 20,
color: themeColor(
'secondaryText'
)
}}
>
{localeString(
'views.OpenChannel.simpleTaprootChannel'
)}
</Text>
<Switch
value={simpleTaprootChannel}
onValueChange={() =>
this.setState({
simpleTaprootChannel:
!simpleTaprootChannel
})
}
/>
</>
)}
</>
)}

Expand Down

0 comments on commit 5f3d6ef

Please sign in to comment.