From 0a01d5d17ca2dce4d18b48646cbc6cb10fb2a8f9 Mon Sep 17 00:00:00 2001 From: carla Date: Tue, 7 Jul 2020 19:49:52 +0200 Subject: [PATCH] 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. --- contractcourt/channel_arbitrator.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index 6cbf5f1a..b67d2c7c 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -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 {