Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e0a9e48
peer: add new abstract message router
Roasbeef Jan 27, 2024
c7a1324
peer: update readHandler to dispatch to msgRouter if set
Roasbeef Jan 31, 2024
b151aa7
peer: update Start/Stop w/ awareness of msg router
Roasbeef Mar 5, 2024
8272566
multi: make MsgRouter available in the ImplementationCfg
Roasbeef Apr 4, 2024
ffedd5f
peer+protofsm: move MsgRouter to new protofsm package
Roasbeef Apr 4, 2024
ed1c489
funding: add new type alias for PendingChanID = [32]byte
Roasbeef Apr 4, 2024
b7aae1d
fundign: use atomic.Uint64 for chanIDNonce
Roasbeef Apr 4, 2024
ee9e679
lnwallet: add new AuxFundingDesc struct
Roasbeef Apr 5, 2024
486a1db
lnwallet: use AuxFundingDesc to populate all custom chan info
Roasbeef Apr 5, 2024
f70e702
funding: create new AuxFundingController interface
Roasbeef Apr 5, 2024
53018eb
config+serer: add AuxFundingController as top level cfg option
Roasbeef Apr 5, 2024
26c6ae6
lnwallet: update GenTaprootFundingScript to also return the taproot i…
Roasbeef Apr 16, 2024
eaada10
lnwallet: add TaprootInternalKey method to ShimIntent
Roasbeef Apr 16, 2024
4e422a9
lnwallet: for PsbtIntent return the internal key in the POutput
Roasbeef Apr 16, 2024
cd34dbb
lnwallet+input: update unit tests for compilation
Roasbeef Apr 16, 2024
078f756
funding+lnwallet: only blind tapscript root early in funding flow
Roasbeef Apr 18, 2024
8a7167a
funding+lnwallet: finish hook up new aux funding flow
Roasbeef Apr 18, 2024
ce70590
lnwallet: add new AuxSigner interface to mirror SigPool
Roasbeef Apr 9, 2024
f4b5641
lnwallet: add WithAuxSigner option to channel
Roasbeef Apr 9, 2024
01ef2b1
lnwallet: obtain+verify aux sigs for all second level HTLCs
Roasbeef Apr 9, 2024
cfd4314
lnwire: modify PackRecords to prepend new records
Roasbeef Apr 9, 2024
8fb1753
cmd/lncli: move commands and export
guggero Apr 5, 2024
5e1dd2a
lnwallet: add AddHeight and RemoveHeight funcs
guggero Apr 11, 2024
fa61f26
lnwallet: export AnchorSize
guggero Apr 11, 2024
4bda93a
lnwallet: export GenTaprootHtlcScript
guggero Apr 11, 2024
15abb14
lnwallet: add Tree() method, fix formatting
guggero Apr 11, 2024
011ff00
invoices: add invoice settlement interceptor service
ffranr Apr 23, 2024
14a56fc
invoices: add `SkipAmountCheck` field to `invoiceUpdateCtx` type
ffranr Apr 30, 2024
434e8b0
invoices: integrate settlement interceptor with invoice registry
ffranr Apr 23, 2024
aa44325
lnd: initialize invoice settlement interceptor at server startup
ffranr Apr 23, 2024
4e7acd4
invoicesrpc: add settlement interceptor to invoices RPC server
ffranr Apr 23, 2024
471816e
invoicesrpc: add `InvoiceAcceptor` RPC endpoint and acceptor RPC server
ffranr Apr 23, 2024
91d56c7
lntest: add `InvoiceAcceptor` support to node RPC harness
ffranr Apr 30, 2024
989cc26
itest: add basic invoice acceptor integration test
ffranr Apr 30, 2024
8ba92d7
multi: pass `UpdateAddHtlc` message custom records to invoice acceptor
ffranr May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions chainreg/chainregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ type Config struct {
// leaves for certain custom channel types.
AuxLeafStore fn.Option[lnwallet.AuxLeafStore]

// AuxSigner is an optional signer that can be used to sign auxiliary
// leaves for certain custom channel types.
AuxSigner fn.Option[lnwallet.AuxSigner]

// BlockCache is the main cache for storing block information.
BlockCache *blockcache.BlockCache

Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/arg_parse.go → cmd/commands/arg_parse.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"regexp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build autopilotrpc
// +build autopilotrpc

package main
package commands

import (
"github.com/lightningnetwork/lnd/lnrpc/autopilotrpc"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build !autopilotrpc
// +build !autopilotrpc

package main
package commands

import "github.com/urfave/cli"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build chainrpc
// +build chainrpc

package main
package commands

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build !chainrpc
// +build !chainrpc

package main
package commands

import "github.com/urfave/cli"

Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/cmd_custom.go → cmd/commands/cmd_custom.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"encoding/hex"
Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/cmd_debug.go → cmd/commands/cmd_debug.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/cmd_invoice.go → cmd/commands/cmd_invoice.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"encoding/hex"
Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/cmd_macaroon.go → cmd/commands/cmd_macaroon.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
20 changes: 16 additions & 4 deletions cmd/lncli/cmd_open_channel.go → cmd/commands/cmd_open_channel.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"bytes"
Expand Down Expand Up @@ -65,7 +65,8 @@ Signed base64 encoded PSBT or hex encoded raw wire TX (or path to file): `
)

// TODO(roasbeef): change default number of confirmations.
var openChannelCommand = cli.Command{

var OpenChannelCommand = cli.Command{
Name: "openchannel",
Category: "Channels",
Usage: "Open a channel to a node or an existing peer.",
Expand Down Expand Up @@ -284,10 +285,14 @@ var openChannelCommand = cli.Command{
allowed length is 500 characters`,
},
},
Action: actionDecorator(openChannel),
Action: actionDecorator(func(c *cli.Context) error {
return OpenChannel(c, nil)
}),
}

func openChannel(ctx *cli.Context) error {
func OpenChannel(ctx *cli.Context,
reqDecorator RequestDecorator[*lnrpc.OpenChannelRequest]) error {

// TODO(roasbeef): add deadline to context
ctxc := getContext()
client, cleanUp := getClient(ctx)
Expand Down Expand Up @@ -451,6 +456,13 @@ func openChannel(ctx *cli.Context) error {
return fmt.Errorf("unsupported channel type %v", channelType)
}

if reqDecorator != nil {
err = reqDecorator(ctx, req)
if err != nil {
return err
}
}

// PSBT funding is a more involved, interactive process that is too
// large to also fit into this already long function.
if ctx.Bool("psbt") {
Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/cmd_payments.go → cmd/commands/cmd_payments.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/cmd_profile.go → cmd/commands/cmd_profile.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/cmd_state.go → cmd/commands/cmd_state.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion cmd/lncli/cmd_version.go → cmd/commands/cmd_version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"bufio"
Expand Down
122 changes: 90 additions & 32 deletions cmd/lncli/commands.go → cmd/commands/commands.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"bufio"
Expand All @@ -12,6 +12,7 @@ import (
"io/ioutil"
"math"
"os"
"regexp"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -42,8 +43,44 @@ const (
defaultUtxoMinConf = 1
)

var errBadChanPoint = errors.New("expecting chan_point to be in format of: " +
"txid:index")
var (
errBadChanPoint = errors.New(
"expecting chan_point to be in format of: txid:index",
)

customDataPattern = regexp.MustCompile(
`"custom_channel_data":\s*"([0-9a-z]+)"`,
)
)

func replaceCustomData(jsonBytes []byte) ([]byte, error) {
if customDataPattern.Match(jsonBytes) {
jsonBytes = customDataPattern.ReplaceAllFunc(
jsonBytes, func(match []byte) []byte {
encoded := customDataPattern.FindStringSubmatch(
string(match),
)[1]
decoded, err := hex.DecodeString(encoded)
if err != nil {
return match
}

return []byte("\"custom_channel_data\":" +
string(decoded))
},
)

var buf bytes.Buffer
err := json.Indent(&buf, jsonBytes, "", " ")
if err != nil {
return nil, err
}

jsonBytes = buf.Bytes()
}

return jsonBytes, nil
}

func getContext() context.Context {
shutdownInterceptor, err := signal.Intercept()
Expand All @@ -67,7 +104,7 @@ func printJSON(resp interface{}) {
}

var out bytes.Buffer
json.Indent(&out, b, "", "\t")
json.Indent(&out, b, "", " ")
out.WriteString("\n")
out.WriteTo(os.Stdout)
}
Expand All @@ -79,7 +116,13 @@ func printRespJSON(resp proto.Message) {
return
}

fmt.Printf("%s\n", jsonBytes)
jsonBytesReplaced, err := replaceCustomData(jsonBytes)
if err != nil {
fmt.Println("unable to replace custom data: ", err)
jsonBytesReplaced = jsonBytes
}

fmt.Printf("%s\n", jsonBytesReplaced)
}

// actionDecorator is used to add additional information and error handling
Expand Down Expand Up @@ -1553,7 +1596,11 @@ func pendingChannels(ctx *cli.Context) error {
return nil
}

var listChannelsCommand = cli.Command{
type RequestDecorator[T proto.Message] func(*cli.Context, T) error

type ResponseDecorator[T proto.Message] func(*cli.Context, T) error

var ListChannelsCommand = cli.Command{
Name: "listchannels",
Category: "Channels",
Usage: "List all open channels.",
Expand Down Expand Up @@ -1586,35 +1633,14 @@ var listChannelsCommand = cli.Command{
"order to improve performance",
},
},
Action: actionDecorator(listChannels),
Action: actionDecorator(func(c *cli.Context) error {
return ListChannels(c, nil)
}),
}

var listAliasesCommand = cli.Command{
Name: "listaliases",
Category: "Channels",
Usage: "List all aliases.",
Flags: []cli.Flag{},
Action: actionDecorator(listaliases),
}
func ListChannels(ctx *cli.Context,
respDecorator ResponseDecorator[*lnrpc.ListChannelsResponse]) error {

func listaliases(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()

req := &lnrpc.ListAliasesRequest{}

resp, err := client.ListAliases(ctxc, req)
if err != nil {
return err
}

printRespJSON(resp)

return nil
}

func listChannels(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
Expand Down Expand Up @@ -1651,6 +1677,38 @@ func listChannels(ctx *cli.Context) error {
return err
}

if respDecorator != nil {
err = respDecorator(ctx, resp)
if err != nil {
return err
}
}

printRespJSON(resp)

return nil
}

var listAliasesCommand = cli.Command{
Name: "listaliases",
Category: "Channels",
Usage: "List all aliases.",
Flags: []cli.Flag{},
Action: actionDecorator(listAliases),
}

func listAliases(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()

req := &lnrpc.ListAliasesRequest{}

resp, err := client.ListAliases(ctxc, req)
if err != nil {
return err
}

printRespJSON(resp)

return nil
Expand Down
Loading