channeldb: extend ChannelConfig with new HtlcBasePoint key

This commit is contained in:
Olaoluwa Osuntokun 2017-11-14 20:29:26 -08:00
parent a14a15641b
commit 12e5951434
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 12 additions and 29 deletions

View File

@ -177,19 +177,25 @@ type ChannelConfig struct {
// unique revocation key for each state.
RevocationBasePoint *btcec.PublicKey
// PaymentBasePoint is the based public key to be used when deriving
// PaymentBasePoint is the base public key to be used when deriving
// the key used within the non-delayed pay-to-self output on the
// commitment transaction for a node. This will be combined with a
// tweak derived from the per-commitment point to ensure unique keys
// for each commitment transaction.
PaymentBasePoint *btcec.PublicKey
// DelayBasePoint is the based public key to be used when deriving the
// DelayBasePoint is the base public key to be used when deriving the
// key used within the delayed pay-to-self output on the commitment
// transaction for a node. This will be combined with a tweak derived
// from the per-commitment point to ensure unique keys for each
// commitment transaction.
DelayBasePoint *btcec.PublicKey
// HtlcBasePoint is the base public key to be used when deriving the
// local HTLC key. The derived key (combined with the tweak derived
// from the per-commitment point) is used within the "to self" clause
// within any HTLC output scripts.
HtlcBasePoint *btcec.PublicKey
}
// ChannelCommitment is a snapshot of the commitment state at a particular
@ -1447,6 +1453,7 @@ func putChanInfo(chanBucket *bolt.Bucket, channel *OpenChannel) error {
c.DustLimit, c.MaxPendingAmount, c.ChanReserve, c.MinHTLC,
c.MaxAcceptedHtlcs, c.CsvDelay, c.MultiSigKey,
c.RevocationBasePoint, c.PaymentBasePoint, c.DelayBasePoint,
c.HtlcBasePoint,
)
}
if err := writeChanConfig(&w, &channel.LocalChanCfg); err != nil {
@ -1547,6 +1554,7 @@ func fetchChanInfo(chanBucket *bolt.Bucket, channel *OpenChannel) error {
&c.MinHTLC, &c.MaxAcceptedHtlcs, &c.CsvDelay,
&c.MultiSigKey, &c.RevocationBasePoint,
&c.PaymentBasePoint, &c.DelayBasePoint,
&c.HtlcBasePoint,
)
}
if err := readChanConfig(r, &channel.LocalChanCfg); err != nil {

View File

@ -139,6 +139,7 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
RevocationBasePoint: privKey.PubKey(),
PaymentBasePoint: privKey.PubKey(),
DelayBasePoint: privKey.PubKey(),
HtlcBasePoint: privKey.PubKey(),
}
remoteCfg := ChannelConfig{
ChannelConstraints: ChannelConstraints{
@ -153,6 +154,7 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
RevocationBasePoint: privKey.PubKey(),
PaymentBasePoint: privKey.PubKey(),
DelayBasePoint: privKey.PubKey(),
HtlcBasePoint: privKey.PubKey(),
}
chanID := lnwire.NewShortChanIDFromInt(uint64(rand.Int63()))
@ -246,33 +248,6 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
// The decoded channel state should be identical to what we stored
// above.
if !reflect.DeepEqual(state, newState) {
state.LocalChanCfg.MultiSigKey.Curve = nil
state.LocalChanCfg.RevocationBasePoint.Curve = nil
state.LocalChanCfg.PaymentBasePoint.Curve = nil
state.LocalChanCfg.DelayBasePoint.Curve = nil
state.RemoteChanCfg.MultiSigKey.Curve = nil
state.RemoteChanCfg.RevocationBasePoint.Curve = nil
state.RemoteChanCfg.PaymentBasePoint.Curve = nil
state.RemoteChanCfg.DelayBasePoint.Curve = nil
state.IdentityPub.Curve = nil
state.RemoteNextRevocation.Curve = nil
state.RemoteCurrentRevocation.Curve = nil
newState.LocalChanCfg.MultiSigKey.Curve = nil
newState.LocalChanCfg.RevocationBasePoint.Curve = nil
newState.LocalChanCfg.PaymentBasePoint.Curve = nil
newState.LocalChanCfg.DelayBasePoint.Curve = nil
newState.RemoteChanCfg.MultiSigKey.Curve = nil
newState.RemoteChanCfg.RevocationBasePoint.Curve = nil
newState.RemoteChanCfg.PaymentBasePoint.Curve = nil
newState.RemoteChanCfg.DelayBasePoint.Curve = nil
newState.IdentityPub.Curve = nil
newState.RemoteCurrentRevocation.Curve = nil
newState.RemoteNextRevocation.Curve = nil
t.Fatalf("channel state doesn't match:: %v vs %v",
spew.Sdump(state), spew.Sdump(newState))
}