channeldb: modify FindPreviousState to return a ChannelCommitment
This commit is contained in:
parent
5bdff9585b
commit
da22078995
@ -1102,34 +1102,33 @@ func (c *OpenChannel) CommitmentHeight() (uint64, error) {
|
|||||||
// intended to be used for obtaining the relevant data needed to claim all
|
// intended to be used for obtaining the relevant data needed to claim all
|
||||||
// funds rightfully spendable in the case of an on-chain broadcast of the
|
// funds rightfully spendable in the case of an on-chain broadcast of the
|
||||||
// commitment transaction.
|
// commitment transaction.
|
||||||
func (c *OpenChannel) FindPreviousState(updateNum uint64) (*ChannelDelta, error) {
|
func (c *OpenChannel) FindPreviousState(updateNum uint64) (*ChannelCommitment, error) {
|
||||||
delta := &ChannelDelta{}
|
var commit ChannelCommitment
|
||||||
|
|
||||||
err := c.Db.View(func(tx *bolt.Tx) error {
|
err := c.Db.View(func(tx *bolt.Tx) error {
|
||||||
chanBucket := tx.Bucket(openChannelBucket)
|
chanBucket, err := readChanBucket(tx, c.IdentityPub,
|
||||||
|
&c.FundingOutpoint, c.ChainHash)
|
||||||
nodePub := c.IdentityPub.SerializeCompressed()
|
if err != nil {
|
||||||
nodeChanBucket := chanBucket.Bucket(nodePub)
|
return err
|
||||||
if nodeChanBucket == nil {
|
|
||||||
return ErrNoActiveChannels
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logBucket := nodeChanBucket.Bucket(channelLogBucket)
|
logBucket := chanBucket.Bucket(revocationLogBucket)
|
||||||
if logBucket == nil {
|
if logBucket == nil {
|
||||||
return ErrNoPastDeltas
|
return ErrNoPastDeltas
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
c, err := fetchChannelLogEntry(logBucket, updateNum)
|
||||||
delta, err = fetchChannelLogEntry(logBucket, &c.FundingOutpoint,
|
if err != nil {
|
||||||
updateNum)
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
commit = c
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return delta, nil
|
return &commit, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClosureType is an enum like structure that details exactly _how_ a channel
|
// ClosureType is an enum like structure that details exactly _how_ a channel
|
||||||
|
Loading…
Reference in New Issue
Block a user