channeldb: replace raw keys in ChannelConfig with keychain.KeyDescriptor
In this commit, we remove references to raw keys from the main ChannelConfig struct and instead replace it with usage of keychain.KeyDescriptor. We do this, as the ChannelConfig as it stands is a near complete static description of a channel. In the future, it will be possible to export these static descriptions as backups. We prefer the KeyDescriptor of a plain PublicKey, as the KeyLocator portion of the struct allows a stateless signer to re-derive the keys as needed when signing.
This commit is contained in:
3 files changed
+73
-17
No files matched your search
+33
-12
@@ -11,6 +11,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/shachain"
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
@@ -136,12 +137,22 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
|
||||
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
|
||||
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
||||
},
|
||||
CsvDelay: uint16(rand.Int31()),
|
||||
MultiSigKey: privKey.PubKey(),
|
||||
RevocationBasePoint: privKey.PubKey(),
|
||||
PaymentBasePoint: privKey.PubKey(),
|
||||
DelayBasePoint: privKey.PubKey(),
|
||||
HtlcBasePoint: privKey.PubKey(),
|
||||
CsvDelay: uint16(rand.Int31()),
|
||||
MultiSigKey: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
RevocationBasePoint: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
PaymentBasePoint: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
DelayBasePoint: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
HtlcBasePoint: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
}
|
||||
remoteCfg := ChannelConfig{
|
||||
ChannelConstraints: ChannelConstraints{
|
||||
@@ -151,12 +162,22 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
|
||||
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
|
||||
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
||||
},
|
||||
CsvDelay: uint16(rand.Int31()),
|
||||
MultiSigKey: privKey.PubKey(),
|
||||
RevocationBasePoint: privKey.PubKey(),
|
||||
PaymentBasePoint: privKey.PubKey(),
|
||||
DelayBasePoint: privKey.PubKey(),
|
||||
HtlcBasePoint: privKey.PubKey(),
|
||||
CsvDelay: uint16(rand.Int31()),
|
||||
MultiSigKey: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
RevocationBasePoint: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
PaymentBasePoint: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
DelayBasePoint: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
HtlcBasePoint: keychain.KeyDescriptor{
|
||||
PubKey: privKey.PubKey(),
|
||||
},
|
||||
}
|
||||
|
||||
chanID := lnwire.NewShortChanIDFromInt(uint64(rand.Int63()))
|
||||
|
||||
Reference in new issue
Block a user