Merge pull request #384 from cfromknecht/utxn-incubate-2nd-layer-htlcs

Utxo Nursery, adds outgoing 2nd-layer HTLC persistence
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2017-11-16 19:00:40 -08:00
commit caec23a236
14 files changed
+3446 -1367

No files matched your search

+29 -3
View File
@@ -942,7 +942,9 @@ func (r *rpcServer) forceCloseChan(channel *lnwallet.LightningChannel) (*chainha
// Send the closed channel summary over to the utxoNursery in order to
// have its outputs swept back into the wallet once they're mature.
r.server.utxoNursery.IncubateOutputs(closeSummary)
if err := r.server.utxoNursery.IncubateOutputs(closeSummary); err != nil {
return nil, nil, err
}
return &txid, closeSummary, nil
}
@@ -1241,13 +1243,37 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
// we can ultimately sweep the funds into the wallet.
if nurseryInfo != nil {
forceClose.LimboBalance = int64(nurseryInfo.limboBalance)
forceClose.RecoveredBalance = int64(nurseryInfo.recoveredBalance)
forceClose.MaturityHeight = nurseryInfo.maturityHeight
// If the transaction has been confirmed, then
// we can compute how many blocks it has left.
if forceClose.MaturityHeight != 0 {
forceClose.BlocksTilMaturity = (forceClose.MaturityHeight -
uint32(currentHeight))
forceClose.BlocksTilMaturity =
int32(forceClose.MaturityHeight) -
currentHeight
}
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,
}
if htlc.MaturityHeight != 0 {
htlc.BlocksTilMaturity =
int32(htlc.MaturityHeight) -
currentHeight
}
forceClose.PendingHtlcs = append(forceClose.PendingHtlcs,
htlc)
}
resp.TotalLimboBalance += int64(nurseryInfo.limboBalance)