contractcourt: add resolver report function to ContractReport

Our current set of reports contain much of the information we will
need to persist contract resolutions. We add a function to create
resolver reports from our exiting set of resolutions.
This commit is contained in:
carla 2020-07-07 19:49:52 +02:00
parent fa46db9c48
commit 0a01d5d17c
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91

@ -8,6 +8,7 @@ import (
"sync/atomic"
"time"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/davecgh/go-spew/spew"
@ -204,6 +205,21 @@ type ContractReport struct {
RecoveredBalance btcutil.Amount
}
// resolverReport creates a resolve report using some of the information in the
// contract report.
func (c *ContractReport) resolverReport(spendTx *chainhash.Hash,
resolverType channeldb.ResolverType,
outcome channeldb.ResolverOutcome) *channeldb.ResolverReport {
return &channeldb.ResolverReport{
OutPoint: c.Outpoint,
Amount: c.Amount,
ResolverType: resolverType,
ResolverOutcome: outcome,
SpendTxID: spendTx,
}
}
// htlcSet represents the set of active HTLCs on a given commitment
// transaction.
type htlcSet struct {