Skip to content

Commit

Permalink
LND: wire up Simple Taproot Channels
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Aug 26, 2023
1 parent 058e26c commit 89840ec
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 21 deletions.
5 changes: 3 additions & 2 deletions 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 Expand Up @@ -185,6 +186,6 @@ export default class EmbeddedLND extends LND {
supportsBumpFee = () => true;
supportsLSPs = () => true;
supportsNetworkInfo = () => true;
supportsSimpleTaprootChannels = () => this.supports('v0.17.0');
supportsSimpleTaprootChannels = () => this.supports('v0.16.99');
isLNDBased = () => true;
}
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": "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
1 change: 1 addition & 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
1 change: 1 addition & 0 deletions utils/LndMobileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const writeLndConfig = async (isTestnet?: boolean, rescan?: boolean) => {
protocol.wumbo-channels=true
protocol.option-scid-alias=true
protocol.zero-conf=true
protocol.simple-taproot-chans=true
[routerrpc]
routerrpc.estimator=${
Expand Down
7 changes: 6 additions & 1 deletion views/Channels/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import NodeInfoStore from '../../stores/NodeInfoStore';
import Edit from '../../assets/images/SVG/Edit.svg';
import Share from '../../assets/images/SVG/Share.svg';

import { lnrpc } from '../../proto/lightning';

interface ChannelProps {
navigation: any;
ChannelsStore: ChannelsStore;
Expand Down Expand Up @@ -302,7 +304,10 @@ export default class ChannelView extends React.Component<
keyValue={localeString(
'views.Channel.commitmentType'
)}
value={commitment_type}
value={
lnrpc.CommitmentType[commitment_type] ||
commitment_type
}
/>
)}
{chain_hash && (
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 89840ec

Please sign in to comment.