Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remote signing binary #9293

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
de5b1c1
lnd+lncfg: add outbound remote signer to config
ViktorTigerstrom May 14, 2024
759b817
lncfg: correct `DefaultRemoteSignerRPCTimeout` docs
ViktorTigerstrom May 20, 2024
33b8286
lnd: add new `remotesigner` macaroon entity
ViktorTigerstrom Aug 23, 2024
0ab64ff
walletrpc: add `SignCoordinatorStreams` RPC
ViktorTigerstrom May 14, 2024
7643663
rpcwallet: add `RemoteSigner` interface
ViktorTigerstrom May 14, 2024
80b0ad3
rpcwallet: add InboundRemoteSigner implementation
ViktorTigerstrom May 14, 2024
c375590
rpcwallet: add `RemoteSignerBuilder`
ViktorTigerstrom May 14, 2024
22173bb
rpcwallet: use `RemoteSigner` in RPCKeyRing
ViktorTigerstrom May 14, 2024
27cb7eb
lnd+rpcwallet: use `RemoteSigner` for health check
ViktorTigerstrom May 14, 2024
96569ea
rpcwallet: add `RemoteSignerClient` struct
ViktorTigerstrom May 14, 2024
e469852
f - rpcwallet: use GoroutineManager in remote signer signer client
ViktorTigerstrom Oct 31, 2024
66d22b3
rpcwallet: Add `RemoteSignerClientBuilder`
ViktorTigerstrom Sep 1, 2024
748c28a
lnd: add RemoteSignerClient instance on startup
ViktorTigerstrom May 14, 2024
16fdc25
lncfg: enable signerrole `signer-outbound`
ViktorTigerstrom May 14, 2024
bc1a52b
rpcwallet: add `SignCoordinator` struct
ViktorTigerstrom May 14, 2024
6257910
rpcwallet: add OutboundRemoteSigner implementation
ViktorTigerstrom May 14, 2024
d252d69
lnrpc: add AllowRemoteSigner WalletState proto
ViktorTigerstrom May 14, 2024
300047b
rpcperms: allow some RPCs before rpcActive state
ViktorTigerstrom May 14, 2024
3173439
rpcperms: fix SetServerActive function docs typo
ViktorTigerstrom May 14, 2024
73ee337
multi: enable RpcServer before dependencies exist
ViktorTigerstrom May 14, 2024
71f512c
multi: add `RemoteSigner` to walletrpc config
ViktorTigerstrom May 14, 2024
2213b95
walletrpc: implement `SignCoordinatorStreams` RPC
ViktorTigerstrom May 14, 2024
3f1bd7c
multi: add RemoteSigner before other dependencies
ViktorTigerstrom May 28, 2024
6694892
multi: add `ReadySignal` to `WalletController`
ViktorTigerstrom May 14, 2024
0221e2d
lnd: await remote signer connection on startup
ViktorTigerstrom May 28, 2024
5d51427
multi: enable signerrole `watchonly-outbound`
ViktorTigerstrom May 14, 2024
8d4233c
docs: add outbound signer to remote signing docs
ViktorTigerstrom May 13, 2024
1ce108a
docs: update release notes
ViktorTigerstrom Oct 31, 2024
ebe7025
lntest: separate creation/start of watch-only node
ViktorTigerstrom May 14, 2024
c9fcf12
itest: add outbound remote signer itest
ViktorTigerstrom May 14, 2024
bfdd795
itest: add testOutboundRSMacaroonEnforcement itest
ViktorTigerstrom Aug 28, 2024
5d6e40b
itest: wrap deriveCustomScopeAccounts at 80 chars
ViktorTigerstrom May 17, 2024
fd933d6
lncfg: Add `signer-inbound` `signerrole`
ViktorTigerstrom Nov 21, 2024
a563368
multi: Block non-whitelisted RPCs as remote signer
ViktorTigerstrom Nov 21, 2024
55d16b7
docs: recommend setting signer-inbound signerrole
ViktorTigerstrom Nov 21, 2024
c7784e4
multi: Add `lndsigner` binary
ViktorTigerstrom Nov 21, 2024
570b34f
lnd+lncfg: Add `SignerConfig`
ViktorTigerstrom Nov 21, 2024
2b03e06
lnd: load `SignerConfig` into `lndsigner`
ViktorTigerstrom Nov 21, 2024
76e4caf
f - lnd: Use interface for config loading instead
ViktorTigerstrom Nov 20, 2024
37e2ffc
make+scripts: add `lndsigner` to release script
ViktorTigerstrom Nov 21, 2024
bc0c0dc
docs: add `lndsigner` info to remote signing docs
ViktorTigerstrom Nov 21, 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ _testmain.go

/lnd
/lnd-debug
/lndsigner
/lndsigner-debug
/lncli
/lncli-debug
/lnd-itest
Expand Down
23 changes: 13 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ $(GOIMPORTS_BIN):
# INSTALLATION
# ============

#? build: Build lnd and lncli binaries, place them in project directory
#? build: Build lnd, lncli and lndsigner binaries, place them in project directory
build:
@$(call print, "Building debug lnd and lncli.")
@$(call print, "Building debug lnd/lndsigner and lncli.")
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(DEV_GCFLAGS) $(DEV_LDFLAGS) $(PKG)/cmd/lnd
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(DEV_GCFLAGS) $(DEV_LDFLAGS) $(PKG)/cmd/lncli
$(GOBUILD) -tags="$(LND_SIGNER_TAGS)" -o lndsigner-debug $(DEV_GCFLAGS) $(DEV_LDFLAGS) $(PKG)/cmd/lndsigner

#? build-itest: Build integration test binaries, place them in itest directory
build-itest:
Expand All @@ -131,38 +132,40 @@ build-itest-race:
@$(call print, "Building itest binary for ${backend} backend.")
CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(RPC_TAGS) integration $(backend)" -c -o itest/itest.test$(EXEC_SUFFIX)

#? install-binaries: Build and install lnd and lncli binaries, place them in $GOPATH/bin
#? install-binaries: Build and install lnd, lncli and lndsigner binaries, place them in $GOPATH/bin
install-binaries:
@$(call print, "Installing lnd and lncli.")
@$(call print, "Installing lnd/lndsigner and lncli.")
$(GOINSTALL) -tags="${tags}" -ldflags="$(RELEASE_LDFLAGS)" $(PKG)/cmd/lnd
$(GOINSTALL) -tags="${tags}" -ldflags="$(RELEASE_LDFLAGS)" $(PKG)/cmd/lncli
$(GOINSTALL) -tags="${LND_SIGNER_TAGS}" -ldflags="$(RELEASE_LDFLAGS)" $(PKG)/cmd/lndsigner

#? manpages: generate and install man pages
manpages:
@$(call print, "Generating man pages lncli.1 and lnd.1.")
./scripts/gen_man_pages.sh $(DESTDIR) $(PREFIX)

#? install: Build and install lnd and lncli binaries and place them in $GOPATH/bin.
#? install: Build and install lnd, lncli and lndsigner binaries and place them in $GOPATH/bin.
install: install-binaries

#? install-all: Performs all the same tasks as the install command along with generating and
# installing the man pages for the lnd and lncli binaries. This command is useful in an
# environment where a user has root access and so has write access to the man page directory.
install-all: install manpages

#? release-install: Build and install lnd and lncli release binaries, place them in $GOPATH/bin
#? release-install: Build and install lnd, lncli and lndsigner binaries release binaries, place them in $GOPATH/bin
release-install:
@$(call print, "Installing release lnd and lncli.")
@$(call print, "Installing release lnd/lndsigner and lncli.")
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lnd
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lncli
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to note here is that lncli will be built with the RELEASE_TAGS build tags, and not with the LND_SIGNER_TAGS that the actual lncli that's shipped along with lndsigner in the zip file. I.e. the lncli here will contain more functionality. IMO that's ok though, as it could be a bit confusing if we'd allow installing of 2 different lncli in this make command.
Potentially we could give an option to the executer of this command choose which version they'd like to install though.

env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(LND_SIGNER_TAGS)" $(PKG)/cmd/lndsigner

#? release: Build the full set of reproducible release binaries for all supported platforms
# Make sure the generated mobile RPC stubs don't influence our vendor package
# by removing them first in the clean-mobile target.
release: clean-mobile
@$(call print, "Releasing lnd and lncli binaries.")
@$(call print, "Releasing lnd/lndsigner and lncli binaries.")
$(VERSION_CHECK)
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)"
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(LND_SIGNER_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)"

#? docker-release: Same as release but within a docker container to support reproducible builds on BSD/MacOS platforms
docker-release:
Expand Down Expand Up @@ -427,7 +430,7 @@ mobile: ios android
#? clean: Remove all generated files
clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) ./lnd-debug ./lncli-debug
$(RM) ./lnd-debug ./lndsigner-debug ./lncli-debug
$(RM) ./lnd-itest ./lncli-itest
$(RM) -r ./vendor .vendor-new

Expand Down
46 changes: 46 additions & 0 deletions cmd/lndsigner/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"errors"
"fmt"
"os"

"github.com/jessevdk/go-flags"
"github.com/lightningnetwork/lnd"
"github.com/lightningnetwork/lnd/signal"
)

func main() {
// Hook interceptor for os signals.
shutdownInterceptor, err := signal.Intercept()
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

// Load the signer configuration, and parse any command line options.
// This function will also set up logging properly.
loadedConfig, err := lnd.LoadSignerConfig(shutdownInterceptor)
if err != nil {
var flagsErr *flags.Error
if errors.As(err, &flagsErr) && flagsErr.Type == flags.ErrHelp {
// Help was requested, exit normally.
os.Exit(0)
}

// Print error if not due to help request.
err = fmt.Errorf("failed to load config: %w", err)
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
implCfg := loadedConfig.ImplementationConfig(shutdownInterceptor)

// Call the "real" main in a nested manner so the defers will properly
// be executed in the case of a graceful shutdown.
if err = lnd.Main(
loadedConfig, lnd.ListenerCfg{}, implCfg, shutdownInterceptor,
); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
Loading
Loading