multi: move breach arbiter and utxo nursery into contractcourt package

In this commit, we take an initial step towards converting the existing
breach arbiter and utxo nursery logic into contract resolvers by moving
the files as is, into the `contractcourt` pacakge.

This commit is primarily move only, though we had to massage some
interfaces and config names along the way to make things compile and the
tests run properly.
This commit is contained in:
Olaoluwa Osuntokun
2021-09-13 19:00:36 -07:00
parent be2566cf26
commit 7bde1662e2
15 changed files with 388 additions and 348 deletions

View File

@@ -2401,7 +2401,8 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
}
updateChan, errChan = r.server.htlcSwitch.CloseLink(
chanPoint, htlcswitch.CloseRegular, feeRate, deliveryScript,
chanPoint, contractcourt.CloseRegular, feeRate,
deliveryScript,
)
}
out:
@@ -2518,8 +2519,8 @@ func (r *rpcServer) abandonChan(chanPoint *wire.OutPoint,
// close, then it's possible that the nursery is hanging on to some
// state. To err on the side of caution, we'll now attempt to wipe any
// state for this channel from the nursery.
err = r.server.utxoNursery.cfg.Store.RemoveChannel(chanPoint)
if err != nil && err != ErrContractNotFound {
err = r.server.utxoNursery.RemoveChannel(chanPoint)
if err != nil && err != contractcourt.ErrContractNotFound {
return err
}
@@ -3495,7 +3496,7 @@ func (r *rpcServer) nurseryPopulateForceCloseResp(chanPoint *wire.OutPoint,
// didn't have any time-locked outputs, then the nursery may not know of
// the contract.
nurseryInfo, err := r.server.utxoNursery.NurseryReport(chanPoint)
if err == ErrContractNotFound {
if err == contractcourt.ErrContractNotFound {
return nil
}
if err != nil {
@@ -3508,18 +3509,18 @@ func (r *rpcServer) nurseryPopulateForceCloseResp(chanPoint *wire.OutPoint,
// information detailing exactly how much funds are time locked and also
// the height in which we can ultimately sweep the funds into the
// wallet.
forceClose.LimboBalance = int64(nurseryInfo.limboBalance)
forceClose.RecoveredBalance = int64(nurseryInfo.recoveredBalance)
forceClose.LimboBalance = int64(nurseryInfo.LimboBalance)
forceClose.RecoveredBalance = int64(nurseryInfo.RecoveredBalance)
for _, htlcReport := range nurseryInfo.htlcs {
for _, htlcReport := range nurseryInfo.Htlcs {
// TODO(conner) set incoming flag appropriately after handling
// incoming incubation
htlc := &lnrpc.PendingHTLC{
Incoming: false,
Amount: int64(htlcReport.amount),
Outpoint: htlcReport.outpoint.String(),
MaturityHeight: htlcReport.maturityHeight,
Stage: htlcReport.stage,
Amount: int64(htlcReport.Amount),
Outpoint: htlcReport.Outpoint.String(),
MaturityHeight: htlcReport.MaturityHeight,
Stage: htlcReport.Stage,
}
if htlc.MaturityHeight != 0 {