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 26, 2023
1 parent 058e26c commit eaca527
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 19 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
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
4 changes: 4 additions & 0 deletions stores/ChannelsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ export default class ChannelsStore {
perm?: boolean,
connectPeerOnly?: boolean
) => {
this.resetOpenChannel();
this.channelRequest = undefined;
this.connectingToPeer = true;

Expand Down Expand Up @@ -590,6 +591,8 @@ export default class ChannelsStore {
openChannel = (request: OpenChannelRequest) => {
delete request.host;

console.log('request', request);

this.peerSuccess = false;
this.channelSuccess = false;
this.openingChannel = true;
Expand All @@ -613,6 +616,7 @@ export default class ChannelsStore {
this.channelSuccess = true;
})
.catch((error: any) => {
console.log('error', error);
this.errorMsgChannel = error.toString();
this.output_index = null;
this.funding_txid_str = null;
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: false,
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 eaca527

Please sign in to comment.