Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion cmd/commands/cmd_open_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
"github.com/urfave/cli"
Expand Down Expand Up @@ -406,7 +407,7 @@ func openChannel(ctx *cli.Context) error {
if ctx.IsSet("utxo") {
utxos := ctx.StringSlice("utxo")

outpoints, err := UtxosToOutpoints(utxos)
outpoints, err := lnd.UtxosToOutpoints(utxos)
if err != nil {
return fmt.Errorf("unable to decode utxos: %w", err)
}
Expand Down
42 changes: 35 additions & 7 deletions cmd/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,20 @@ var estimateFeeCommand = cli.Command{
"transaction *should* confirm in",
},
coinSelectionStrategyFlag,
cli.BoolFlag{
Name: "show_outpoints",
Usage: "(optional) if set, the outpoints that will " +
"be used for the transaction will be printed " +
"to the console",
},
cli.StringSliceFlag{
Name: "utxo",
Usage: "a utxo specified as outpoint(tx:idx) which " +
"will be used as input for the transaction " +
"to be estimated. This flag can be " +
"repeatedly used to specify multiple utxos " +
"as inputs.",
},
},
Action: actionDecorator(estimateFees),
}
Expand All @@ -423,10 +437,22 @@ func estimateFees(ctx *cli.Context) error {
client, cleanUp := getClient(ctx)
defer cleanUp()

var outpoints []*lnrpc.OutPoint
if ctx.IsSet("utxo") {
utxos := ctx.StringSlice("utxo")

outpoints, err = lnd.UtxosToOutpoints(utxos)
if err != nil {
return fmt.Errorf("unable to decode utxos: %w", err)
}
}

resp, err := client.EstimateFee(ctxc, &lnrpc.EstimateFeeRequest{
AddrToAmount: amountToAddr,
TargetConf: int32(ctx.Int64("conf_target")),
CoinSelectionStrategy: coinSelectionStrategy,
Outpoints: outpoints,
ShowOutpoints: ctx.Bool("show_outpoints"),
})
if err != nil {
return err
Expand Down Expand Up @@ -607,7 +633,7 @@ func sendCoins(ctx *cli.Context) error {
if ctx.IsSet("utxo") {
utxos := ctx.StringSlice("utxo")

outpoints, err = UtxosToOutpoints(utxos)
outpoints, err = lnd.UtxosToOutpoints(utxos)
if err != nil {
return fmt.Errorf("unable to decode utxos: %w", err)
}
Expand Down Expand Up @@ -784,12 +810,12 @@ func listUnspent(ctx *cli.Context) error {
// to stdout. At the moment, this filters out the raw txid bytes from
// each utxo's outpoint and only prints the txid string.
var listUnspentResp = struct {
Utxos []*Utxo `json:"utxos"`
Utxos []*lnd.Utxo `json:"utxos"`
}{
Utxos: make([]*Utxo, 0, len(resp.Utxos)),
Utxos: make([]*lnd.Utxo, 0, len(resp.Utxos)),
}
for _, protoUtxo := range resp.Utxos {
utxo := NewUtxoFromProto(protoUtxo)
utxo := lnd.NewUtxoFromProto(protoUtxo)
listUnspentResp.Utxos = append(listUnspentResp.Utxos, utxo)
}

Expand Down Expand Up @@ -2789,12 +2815,14 @@ func updateChannelPolicy(ctx *cli.Context) error {
// to stdout. At the moment, this filters out the raw txid bytes from
// each failed update's outpoint and only prints the txid string.
var listFailedUpdateResp = struct {
FailedUpdates []*FailedUpdate `json:"failed_updates"`
FailedUpdates []*lnd.FailedUpdate `json:"failed_updates"`
}{
FailedUpdates: make([]*FailedUpdate, 0, len(resp.FailedUpdates)),
FailedUpdates: make(
[]*lnd.FailedUpdate, 0, len(resp.FailedUpdates),
),
}
for _, protoUpdate := range resp.FailedUpdates {
failedUpdate := NewFailedUpdateFromProto(protoUpdate)
failedUpdate := lnd.NewFailedUpdateFromProto(protoUpdate)
listFailedUpdateResp.FailedUpdates = append(
listFailedUpdateResp.FailedUpdates, failedUpdate)
}
Expand Down
21 changes: 11 additions & 10 deletions cmd/commands/walletrpc_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
Expand Down Expand Up @@ -330,7 +331,7 @@ func bumpFee(ctx *cli.Context) error {
}

// Validate and parse the relevant arguments/flags.
protoOutPoint, err := NewProtoOutPoint(ctx.Args().Get(0))
protoOutPoint, err := lnd.NewProtoOutPoint(ctx.Args().Get(0))
if err != nil {
return err
}
Expand Down Expand Up @@ -812,11 +813,11 @@ func removeTransaction(ctx *cli.Context) error {

// utxoLease contains JSON annotations for a lease on an unspent output.
type utxoLease struct {
ID string `json:"id"`
OutPoint OutPoint `json:"outpoint"`
Expiration uint64 `json:"expiration"`
PkScript []byte `json:"pk_script"`
Value uint64 `json:"value"`
ID string `json:"id"`
OutPoint lnd.OutPoint `json:"outpoint"`
Expiration uint64 `json:"expiration"`
PkScript []byte `json:"pk_script"`
Value uint64 `json:"value"`
}

// fundPsbtResponse is a struct that contains JSON annotations for nice result
Expand Down Expand Up @@ -1358,7 +1359,7 @@ func fundPsbt(ctx *cli.Context) error {
}

for idx, input := range inputs {
op, err := NewProtoOutPoint(input)
op, err := lnd.NewProtoOutPoint(input)
if err != nil {
return fmt.Errorf("error parsing "+
"UTXO outpoint %d: %v", idx,
Expand Down Expand Up @@ -1447,7 +1448,7 @@ func marshallLocks(lockedUtxos []*walletrpc.UtxoLease) []*utxoLease {
for idx, lock := range lockedUtxos {
jsonLocks[idx] = &utxoLease{
ID: hex.EncodeToString(lock.Id),
OutPoint: NewOutPointFromProto(lock.Outpoint),
OutPoint: lnd.NewOutPointFromProto(lock.Outpoint),
Expiration: lock.Expiration,
PkScript: lock.PkScript,
Value: lock.Value,
Expand Down Expand Up @@ -1578,7 +1579,7 @@ func leaseOutput(ctx *cli.Context) error {
}

outpointStr := ctx.String("outpoint")
outpoint, err := NewProtoOutPoint(outpointStr)
outpoint, err := lnd.NewProtoOutPoint(outpointStr)
if err != nil {
return fmt.Errorf("error parsing outpoint: %w", err)
}
Expand Down Expand Up @@ -1663,7 +1664,7 @@ func releaseOutput(ctx *cli.Context) error {
return fmt.Errorf("outpoint argument missing")
}

outpoint, err := NewProtoOutPoint(outpointStr)
outpoint, err := lnd.NewProtoOutPoint(outpointStr)
if err != nil {
return fmt.Errorf("error parsing outpoint: %w", err)
}
Expand Down
29 changes: 17 additions & 12 deletions cmd/commands/walletrpc_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package commands

import "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
import (
"github.com/lightningnetwork/lnd"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
)

// PendingSweep is a CLI-friendly type of the walletrpc.PendingSweep proto. We
// use this to show more useful string versions of byte slices and enums.
Expand All @@ -9,16 +12,16 @@ import "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
// here. Instead, we should rely on the struct defined in the proto
// `PendingSweepsResponse` only.
type PendingSweep struct {
OutPoint OutPoint `json:"outpoint"`
WitnessType string `json:"witness_type"`
AmountSat uint32 `json:"amount_sat"`
SatPerVByte uint32 `json:"sat_per_vbyte"`
BroadcastAttempts uint32 `json:"broadcast_attempts"`
RequestedSatPerVByte uint32 `json:"requested_sat_per_vbyte"`
Immediate bool `json:"immediate"`
Budget uint64 `json:"budget"`
DeadlineHeight uint32 `json:"deadline_height"`
MaturityHeight uint32 `json:"maturity_height"`
OutPoint lnd.OutPoint `json:"outpoint"`
WitnessType string `json:"witness_type"`
AmountSat uint32 `json:"amount_sat"`
SatPerVByte uint32 `json:"sat_per_vbyte"`
BroadcastAttempts uint32 `json:"broadcast_attempts"`
RequestedSatPerVByte uint32 `json:"requested_sat_per_vbyte"`
Immediate bool `json:"immediate"`
Budget uint64 `json:"budget"`
DeadlineHeight uint32 `json:"deadline_height"`
MaturityHeight uint32 `json:"maturity_height"`

NextBroadcastHeight uint32 `json:"next_broadcast_height"`
RequestedConfTarget uint32 `json:"requested_conf_target"`
Expand All @@ -29,7 +32,9 @@ type PendingSweep struct {
// its corresponding CLI-friendly type.
func NewPendingSweepFromProto(pendingSweep *walletrpc.PendingSweep) *PendingSweep {
return &PendingSweep{
OutPoint: NewOutPointFromProto(pendingSweep.Outpoint),
OutPoint: lnd.NewOutPointFromProto(
pendingSweep.Outpoint,
),
WitnessType: pendingSweep.WitnessType.String(),
AmountSat: pendingSweep.AmountSat,
SatPerVByte: uint32(pendingSweep.SatPerVbyte),
Expand Down
10 changes: 10 additions & 0 deletions docs/release-notes/release-notes-0.21.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,17 @@

## RPC Additions

* The `EstimateFee` RPC now supports [explicit input
selection](https://github.com/lightningnetwork/lnd/pull/10296). Users can
specify a list of outpoints to use as transaction inputs via the new
`outpoints` field in `EstimateFeeRequest`. The `show_outpoints` field can be
set to include the selected outpoints in the `EstimateFeeResponse`.

## lncli Additions

* The `estimatefee` command now supports the `--utxos` flag to specify explicit
inputs for fee estimation.

# Improvements
## Functional Updates

Expand Down Expand Up @@ -77,4 +86,5 @@

* Boris Nagaev
* Elle Mouton
* hieblmi
* Nishant Bansal
Loading
Loading