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

@ -177,19 +177,25 @@ type ChannelConfig struct {
// unique revocation key for each state. // unique revocation key for each state.
RevocationBasePoint *btcec.PublicKey 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 // the key used within the non-delayed pay-to-self output on the
// commitment transaction for a node. This will be combined with a // commitment transaction for a node. This will be combined with a
// tweak derived from the per-commitment point to ensure unique keys // tweak derived from the per-commitment point to ensure unique keys
// for each commitment transaction. // for each commitment transaction.
PaymentBasePoint *btcec.PublicKey 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 // key used within the delayed pay-to-self output on the commitment
// transaction for a node. This will be combined with a tweak derived // transaction for a node. This will be combined with a tweak derived
// from the per-commitment point to ensure unique keys for each // from the per-commitment point to ensure unique keys for each
// commitment transaction. // commitment transaction.
DelayBasePoint *btcec.PublicKey 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 // 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.DustLimit, c.MaxPendingAmount, c.ChanReserve, c.MinHTLC,
c.MaxAcceptedHtlcs, c.CsvDelay, c.MultiSigKey, c.MaxAcceptedHtlcs, c.CsvDelay, c.MultiSigKey,
c.RevocationBasePoint, c.PaymentBasePoint, c.DelayBasePoint, c.RevocationBasePoint, c.PaymentBasePoint, c.DelayBasePoint,
c.HtlcBasePoint,
) )
} }
if err := writeChanConfig(&w, &channel.LocalChanCfg); err != nil { 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.MinHTLC, &c.MaxAcceptedHtlcs, &c.CsvDelay,
&c.MultiSigKey, &c.RevocationBasePoint, &c.MultiSigKey, &c.RevocationBasePoint,
&c.PaymentBasePoint, &c.DelayBasePoint, &c.PaymentBasePoint, &c.DelayBasePoint,
&c.HtlcBasePoint,
) )
} }
if err := readChanConfig(r, &channel.LocalChanCfg); err != nil { if err := readChanConfig(r, &channel.LocalChanCfg); err != nil {

@ -139,6 +139,7 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
RevocationBasePoint: privKey.PubKey(), RevocationBasePoint: privKey.PubKey(),
PaymentBasePoint: privKey.PubKey(), PaymentBasePoint: privKey.PubKey(),
DelayBasePoint: privKey.PubKey(), DelayBasePoint: privKey.PubKey(),
HtlcBasePoint: privKey.PubKey(),
} }
remoteCfg := ChannelConfig{ remoteCfg := ChannelConfig{
ChannelConstraints: ChannelConstraints{ ChannelConstraints: ChannelConstraints{
@ -153,6 +154,7 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
RevocationBasePoint: privKey.PubKey(), RevocationBasePoint: privKey.PubKey(),
PaymentBasePoint: privKey.PubKey(), PaymentBasePoint: privKey.PubKey(),
DelayBasePoint: privKey.PubKey(), DelayBasePoint: privKey.PubKey(),
HtlcBasePoint: privKey.PubKey(),
} }
chanID := lnwire.NewShortChanIDFromInt(uint64(rand.Int63())) 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 // The decoded channel state should be identical to what we stored
// above. // above.
if !reflect.DeepEqual(state, newState) { 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", t.Fatalf("channel state doesn't match:: %v vs %v",
spew.Sdump(state), spew.Sdump(newState)) spew.Sdump(state), spew.Sdump(newState))
} }