Skip to content

Commit

Permalink
sweep+walletrpc+lncli: report requested fee preference for pending sw…
Browse files Browse the repository at this point in the history
…eeps

Previously only the fee rate used for the last sweep (the sweep bucket
average) was reported. This commit adds the request fee preference to
the report, which is used to select a bucket and the sweep tx fee rate.
  • Loading branch information
joostjager committed Jan 9, 2020
1 parent 6c8c99d commit 280611a
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 62 deletions.
4 changes: 4 additions & 0 deletions cmd/lncli/walletrpc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type PendingSweep struct {
SatPerByte uint32 `json:"sat_per_byte"`
BroadcastAttempts uint32 `json:"broadcast_attempts"`
NextBroadcastHeight uint32 `json:"next_broadcast_height"`
RequestedSatPerByte uint32 `json:"requested_sat_per_byte"`
RequestedConfTarget uint32 `json:"requested_conf_target"`
}

// NewPendingSweepFromProto converts the walletrpc.PendingSweep proto type into
Expand All @@ -23,5 +25,7 @@ func NewPendingSweepFromProto(pendingSweep *walletrpc.PendingSweep) *PendingSwee
SatPerByte: pendingSweep.SatPerByte,
BroadcastAttempts: pendingSweep.BroadcastAttempts,
NextBroadcastHeight: pendingSweep.NextBroadcastHeight,
RequestedSatPerByte: pendingSweep.RequestedSatPerByte,
RequestedConfTarget: pendingSweep.RequestedConfTarget,
}
}
144 changes: 82 additions & 62 deletions lnrpc/walletrpc/walletkit.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lnrpc/walletrpc/walletkit.proto
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ message PendingSweep {
sweep transaction of the output.
*/
uint32 next_broadcast_height = 6 [json_name = "next_broadcast_height"];

// The requested confirmation target for this output.
uint32 requested_conf_target = 8 [json_name = "requested_conf_target"];

// The requested fee rate, expressed in sat/byte, for this output.
uint32 requested_sat_per_byte = 9 [json_name = "requested_sat_per_byte"];
}

message PendingSweepsRequest {
Expand Down
5 changes: 5 additions & 0 deletions lnrpc/walletrpc/walletkit_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,18 @@ func (w *WalletKit) PendingSweeps(ctx context.Context,
broadcastAttempts := uint32(pendingInput.BroadcastAttempts)
nextBroadcastHeight := uint32(pendingInput.NextBroadcastHeight)

requestedFee := pendingInput.Params.Fee
requestedFeeRate := uint32(requestedFee.FeeRate.FeePerKVByte() / 1000)

rpcPendingSweeps = append(rpcPendingSweeps, &PendingSweep{
Outpoint: op,
WitnessType: witnessType,
AmountSat: amountSat,
SatPerByte: satPerByte,
BroadcastAttempts: broadcastAttempts,
NextBroadcastHeight: nextBroadcastHeight,
RequestedSatPerByte: requestedFeeRate,
RequestedConfTarget: requestedFee.ConfTarget,
})
}

Expand Down
4 changes: 4 additions & 0 deletions sweep/sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ type PendingInput struct {
// NextBroadcastHeight is the next height of the chain at which we'll
// attempt to broadcast a transaction sweeping the input.
NextBroadcastHeight uint32

// Params contains the sweep parameters for this pending request.
Params Params
}

// bumpFeeReq is an internal message we'll use to represent an external caller's
Expand Down Expand Up @@ -1034,6 +1037,7 @@ func (s *UtxoSweeper) handlePendingSweepsReq(
LastFeeRate: pendingInput.lastFeeRate,
BroadcastAttempts: pendingInput.publishAttempts,
NextBroadcastHeight: uint32(pendingInput.minPublishHeight),
Params: pendingInput.params,
}
}

Expand Down

0 comments on commit 280611a

Please sign in to comment.