mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
channeldb: add new field to store the state hint obsfucator
This commit is contained in:
parent
bc3e16dd13
commit
66571e4464
@ -144,7 +144,11 @@ type OpenChannel struct {
|
||||
OurCommitTx *wire.MsgTx
|
||||
OurCommitSig []byte
|
||||
|
||||
// The outpoint of the final funding transaction.
|
||||
// StateHintObsfucator are the btyes selected by the initiator (derived
|
||||
// from their shachain root) to obsfucate the state-hint encoded within
|
||||
// the commitment transaction.
|
||||
StateHintObsfucator [4]byte
|
||||
|
||||
// ChanType denotes which type of channel this is.
|
||||
ChanType ChannelType
|
||||
|
||||
@ -1265,6 +1269,10 @@ func putChanElkremState(nodeChanBucket *bolt.Bucket, channel *OpenChannel) error
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := b.Write(channel.StateHintObsfucator[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nodeChanBucket.Put(elkremKey, b.Bytes())
|
||||
}
|
||||
|
||||
@ -1320,6 +1328,11 @@ func fetchChanElkremState(nodeChanBucket *bolt.Bucket, channel *OpenChannel) err
|
||||
}
|
||||
channel.RemoteElkrem = remoteE
|
||||
|
||||
_, err = io.ReadFull(elkremStateBytes, channel.StateHintObsfucator[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,9 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
|
||||
}
|
||||
}
|
||||
|
||||
var obsfucator [4]byte
|
||||
copy(obsfucator[:], key[:])
|
||||
|
||||
return &OpenChannel{
|
||||
IsInitiator: true,
|
||||
ChanType: SingleFunder,
|
||||
@ -147,6 +150,7 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
|
||||
OurCommitSig: bytes.Repeat([]byte{1}, 71),
|
||||
LocalElkrem: sender,
|
||||
RemoteElkrem: receiver,
|
||||
StateHintObsfucator: obsfucator,
|
||||
FundingOutpoint: testOutpoint,
|
||||
OurMultiSigKey: privKey.PubKey(),
|
||||
TheirMultiSigKey: privKey.PubKey(),
|
||||
@ -207,7 +211,8 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
|
||||
t.Fatalf("chan id's don't match")
|
||||
}
|
||||
if state.MinFeePerKb != newState.MinFeePerKb {
|
||||
t.Fatalf("fee/kb doens't match")
|
||||
t.Fatalf("fee/kb doesn't match")
|
||||
}
|
||||
if state.IsInitiator != newState.IsInitiator {
|
||||
t.Fatalf("initiator status doesn't match")
|
||||
}
|
||||
@ -322,6 +327,10 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
|
||||
t.Fatalf("htlcs don't match: %v vs %v", spew.Sdump(state.Htlcs[0]),
|
||||
spew.Sdump(newState.Htlcs[0]))
|
||||
}
|
||||
if !bytes.Equal(state.StateHintObsfucator[:],
|
||||
newState.StateHintObsfucator[:]) {
|
||||
t.Fatalf("obsfuctators don't match")
|
||||
}
|
||||
|
||||
// Finally to wrap up the test, delete the state of the channel within
|
||||
// the database. This involves "closing" the channel which removes all
|
||||
|
Loading…
Reference in New Issue
Block a user