multi: use key locator for lnwallet.MessageSigner

To simplify the message signing API even further, we refactor the
lnwallet.MessageSigner interface to use a key locator instead of the
public key to identify which key should be signed with.
This commit is contained in:
Oliver Gugger
2021-09-23 16:54:30 +02:00
parent afa03f22cc
commit e79d59dd4c
19 changed files with 184 additions and 102 deletions

View File

@@ -6,7 +6,6 @@ import (
"time"
"github.com/btcsuite/btcd/btcec"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
@@ -18,8 +17,8 @@ type mockSigner struct {
err error
}
func (m *mockSigner) SignMessage(pk *btcec.PublicKey,
msg []byte) (input.Signature, error) {
func (m *mockSigner) SignMessage(_ keychain.KeyLocator,
_ []byte) (*btcec.Signature, error) {
if m.err != nil {
return nil, m.err
@@ -32,7 +31,7 @@ var _ lnwallet.MessageSigner = (*mockSigner)(nil)
var (
privKey, _ = btcec.NewPrivateKey(btcec.S256())
privKeySigner = &keychain.PrivKeyMessageSigner{PrivKey: privKey}
privKeySigner = keychain.NewPrivKeyMessageSigner(privKey, testKeyLoc)
pubKey = privKey.PubKey()
@@ -130,7 +129,7 @@ func TestUpdateDisableFlag(t *testing.T) {
// Attempt to update and sign the new update, specifying
// disabled or enabled as prescribed in the test case.
err := netann.SignChannelUpdate(
tc.signer, pubKey, newUpdate,
tc.signer, testKeyLoc, newUpdate,
netann.ChanUpdSetDisable(tc.disable),
netann.ChanUpdSetTimestamp,
)