Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sweep: allow force sweeping of negatively yielding inputs #3809

Merged
merged 4 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"];
joostjager marked this conversation as resolved.
Show resolved Hide resolved
}

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