Skip to content

Add remote signing binary #9293

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

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5c024f1
lnd+lncfg: Refactor `RemoteSigner` Config
ViktorTigerstrom Dec 9, 2024
27ebb83
multi: correct `DefaultRemoteSignerRPCTimeout` docs
ViktorTigerstrom May 20, 2024
0e62619
lnd: add new `remotesigner` macaroon entity
ViktorTigerstrom Aug 23, 2024
cac0b86
walletrpc: add `SignCoordinatorStreams` RPC
ViktorTigerstrom May 14, 2024
9e6f00b
rpcwallet: add `RemoteSignerConnection` interface
ViktorTigerstrom May 14, 2024
7a5ac80
rpcwallet: add `OutboundConnection` implementation
ViktorTigerstrom May 14, 2024
3deac01
rpcwallet: add `RemoteSignerConnectionBuilder`
ViktorTigerstrom May 14, 2024
c0157a9
rpcwallet: use `RemoteSignerConnection` in RPCKeyRing
ViktorTigerstrom May 14, 2024
547c883
lnd: refactor `createLivenessMonitor` signature
ViktorTigerstrom Dec 17, 2024
cb9aea5
multi: use `RemoteSignerConnection` for health check
ViktorTigerstrom May 14, 2024
392f118
multi: Add `watchonlynode` Namespace to `Config`
ViktorTigerstrom Dec 6, 2024
a5359ab
fn: add CancelOrQuit helper
ViktorTigerstrom Dec 5, 2024
eeba872
rpcwallet: add `RemoteSignerClient` struct
ViktorTigerstrom May 14, 2024
f4980b6
f - rpcwallet: use GoroutineManager in remote signer signer client
ViktorTigerstrom Oct 31, 2024
f907101
rpcwallet: Add `RemoteSignerClientBuilder`
ViktorTigerstrom Sep 1, 2024
f3caf7c
lnd: add `RemoteSignerClient` instance on startup
ViktorTigerstrom May 14, 2024
c1ab0da
lncfg: allow `watchonlynode.enable`
ViktorTigerstrom Dec 6, 2024
e6e7e57
conf: add `remotesigner.allowinboundconnection`
ViktorTigerstrom Dec 6, 2024
a322b63
rpcwallet: add `SignCoordinator` struct
ViktorTigerstrom May 14, 2024
c8a8e42
rpcwallet: add `InboundConnection` implementation
ViktorTigerstrom Dec 6, 2024
2d65e77
lnrpc: add `AllowRemoteSigner` `WalletState` proto
ViktorTigerstrom May 14, 2024
3c9273e
rpcperms: allow some RPCs before `rpcActive` state
ViktorTigerstrom May 14, 2024
e254d67
rpcperms: fix `SetServerActive` function docs typo
ViktorTigerstrom May 14, 2024
a7aba5b
multi: enable `RpcServer` before dependencies exist
ViktorTigerstrom May 14, 2024
4faa3ba
multi: add `RemoteSignerConnection` to walletrpc conf
ViktorTigerstrom May 14, 2024
d84ac5d
walletrpc: implement `SignCoordinatorStreams` RPC
ViktorTigerstrom May 14, 2024
47d4db2
multi: populate `RemoteSignerConnection` ref early
ViktorTigerstrom May 28, 2024
be62f29
f - multi: populate `RemoteSignerConnection` ref early
ViktorTigerstrom Dec 5, 2024
e0030c5
multi: add `ReadySignal` to `WalletController`
ViktorTigerstrom May 14, 2024
01f1637
lnd: await remote signer connection on startup
ViktorTigerstrom May 28, 2024
ca5e017
multi: allow `remotesigner.allowinboundconnection`
ViktorTigerstrom Dec 6, 2024
ca280c8
docs: add outbound signer to remote signing docs
ViktorTigerstrom May 13, 2024
403b996
docs: update release notes
ViktorTigerstrom Oct 31, 2024
8bcf99e
lntest: separate creation/start of watch-only node
ViktorTigerstrom May 14, 2024
83e159c
itest: fix testRemoteSignerRandomSeedOutbound typo
ViktorTigerstrom Mar 21, 2025
ba6d4e9
itest: add outbound remote signer itests
ViktorTigerstrom May 14, 2024
6d87e66
itest: add testOutboundRSMacaroonEnforcement itest
ViktorTigerstrom Aug 28, 2024
3ac2294
itest: wrap deriveCustomScopeAccounts at 80 chars
ViktorTigerstrom May 17, 2024
0f06ef3
rpcwallet: allow remote signer to reconnect
ViktorTigerstrom Mar 21, 2025
7340883
lncfg: Add `watchonlynode.allowinboundconnection`
ViktorTigerstrom Nov 21, 2024
b5ea30d
multi: Block non-whitelisted RPCs as remote signer
ViktorTigerstrom Nov 21, 2024
9acf2d1
docs: recommend specifying that node acts as inbound signer
ViktorTigerstrom Nov 21, 2024
ae7999d
multi: Add `lndsigner` binary
ViktorTigerstrom Nov 21, 2024
2f56beb
lnd+lncfg: Add `SignerConfig`
ViktorTigerstrom Nov 21, 2024
b9275f5
lnd: load `SignerConfig` into `lndsigner`
ViktorTigerstrom Nov 21, 2024
e19ebd5
f - lnd: Use interface for config loading instead
ViktorTigerstrom Nov 20, 2024
5bbd3d1
make+scripts: add `lndsigner` to release script
ViktorTigerstrom Nov 21, 2024
5f99200
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 @@ -96,11 +96,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 @@ -120,38 +121,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 @@ -433,7 +436,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