cmd: make types.go accessible in lnd package
This commit is contained in:
5 files changed
+27
-18
No files matched your search
@@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/lightningnetwork/lnd"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@@ -406,7 +407,7 @@ func openChannel(ctx *cli.Context) error {
|
|||||||
if ctx.IsSet("utxo") {
|
if ctx.IsSet("utxo") {
|
||||||
utxos := ctx.StringSlice("utxo")
|
utxos := ctx.StringSlice("utxo")
|
||||||
|
|
||||||
outpoints, err := UtxosToOutpoints(utxos)
|
outpoints, err := lnd.UtxosToOutpoints(utxos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to decode utxos: %w", err)
|
return fmt.Errorf("unable to decode utxos: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -607,7 +607,7 @@ func sendCoins(ctx *cli.Context) error {
|
|||||||
if ctx.IsSet("utxo") {
|
if ctx.IsSet("utxo") {
|
||||||
utxos := ctx.StringSlice("utxo")
|
utxos := ctx.StringSlice("utxo")
|
||||||
|
|
||||||
outpoints, err = UtxosToOutpoints(utxos)
|
outpoints, err = lnd.UtxosToOutpoints(utxos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to decode utxos: %w", err)
|
return fmt.Errorf("unable to decode utxos: %w", err)
|
||||||
}
|
}
|
||||||
@@ -784,12 +784,12 @@ func listUnspent(ctx *cli.Context) error {
|
|||||||
// to stdout. At the moment, this filters out the raw txid bytes from
|
// to stdout. At the moment, this filters out the raw txid bytes from
|
||||||
// each utxo's outpoint and only prints the txid string.
|
// each utxo's outpoint and only prints the txid string.
|
||||||
var listUnspentResp = struct {
|
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 {
|
for _, protoUtxo := range resp.Utxos {
|
||||||
utxo := NewUtxoFromProto(protoUtxo)
|
utxo := lnd.NewUtxoFromProto(protoUtxo)
|
||||||
listUnspentResp.Utxos = append(listUnspentResp.Utxos, utxo)
|
listUnspentResp.Utxos = append(listUnspentResp.Utxos, utxo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2789,12 +2789,14 @@ func updateChannelPolicy(ctx *cli.Context) error {
|
|||||||
// to stdout. At the moment, this filters out the raw txid bytes from
|
// to stdout. At the moment, this filters out the raw txid bytes from
|
||||||
// each failed update's outpoint and only prints the txid string.
|
// each failed update's outpoint and only prints the txid string.
|
||||||
var listFailedUpdateResp = struct {
|
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 {
|
for _, protoUpdate := range resp.FailedUpdates {
|
||||||
failedUpdate := NewFailedUpdateFromProto(protoUpdate)
|
failedUpdate := lnd.NewFailedUpdateFromProto(protoUpdate)
|
||||||
listFailedUpdateResp.FailedUpdates = append(
|
listFailedUpdateResp.FailedUpdates = append(
|
||||||
listFailedUpdateResp.FailedUpdates, failedUpdate)
|
listFailedUpdateResp.FailedUpdates, failedUpdate)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/lightningnetwork/lnd"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
||||||
@@ -330,7 +331,7 @@ func bumpFee(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate and parse the relevant arguments/flags.
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -813,7 +814,7 @@ func removeTransaction(ctx *cli.Context) error {
|
|||||||
// utxoLease contains JSON annotations for a lease on an unspent output.
|
// utxoLease contains JSON annotations for a lease on an unspent output.
|
||||||
type utxoLease struct {
|
type utxoLease struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
OutPoint OutPoint `json:"outpoint"`
|
OutPoint lnd.OutPoint `json:"outpoint"`
|
||||||
Expiration uint64 `json:"expiration"`
|
Expiration uint64 `json:"expiration"`
|
||||||
PkScript []byte `json:"pk_script"`
|
PkScript []byte `json:"pk_script"`
|
||||||
Value uint64 `json:"value"`
|
Value uint64 `json:"value"`
|
||||||
@@ -1358,7 +1359,7 @@ func fundPsbt(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for idx, input := range inputs {
|
for idx, input := range inputs {
|
||||||
op, err := NewProtoOutPoint(input)
|
op, err := lnd.NewProtoOutPoint(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing "+
|
return fmt.Errorf("error parsing "+
|
||||||
"UTXO outpoint %d: %v", idx,
|
"UTXO outpoint %d: %v", idx,
|
||||||
@@ -1447,7 +1448,7 @@ func marshallLocks(lockedUtxos []*walletrpc.UtxoLease) []*utxoLease {
|
|||||||
for idx, lock := range lockedUtxos {
|
for idx, lock := range lockedUtxos {
|
||||||
jsonLocks[idx] = &utxoLease{
|
jsonLocks[idx] = &utxoLease{
|
||||||
ID: hex.EncodeToString(lock.Id),
|
ID: hex.EncodeToString(lock.Id),
|
||||||
OutPoint: NewOutPointFromProto(lock.Outpoint),
|
OutPoint: lnd.NewOutPointFromProto(lock.Outpoint),
|
||||||
Expiration: lock.Expiration,
|
Expiration: lock.Expiration,
|
||||||
PkScript: lock.PkScript,
|
PkScript: lock.PkScript,
|
||||||
Value: lock.Value,
|
Value: lock.Value,
|
||||||
@@ -1578,7 +1579,7 @@ func leaseOutput(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
outpointStr := ctx.String("outpoint")
|
outpointStr := ctx.String("outpoint")
|
||||||
outpoint, err := NewProtoOutPoint(outpointStr)
|
outpoint, err := lnd.NewProtoOutPoint(outpointStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing outpoint: %w", err)
|
return fmt.Errorf("error parsing outpoint: %w", err)
|
||||||
}
|
}
|
||||||
@@ -1663,7 +1664,7 @@ func releaseOutput(ctx *cli.Context) error {
|
|||||||
return fmt.Errorf("outpoint argument missing")
|
return fmt.Errorf("outpoint argument missing")
|
||||||
}
|
}
|
||||||
|
|
||||||
outpoint, err := NewProtoOutPoint(outpointStr)
|
outpoint, err := lnd.NewProtoOutPoint(outpointStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing outpoint: %w", err)
|
return fmt.Errorf("error parsing outpoint: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package commands
|
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
|
// 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.
|
// use this to show more useful string versions of byte slices and enums.
|
||||||
@@ -9,7 +12,7 @@ import "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
|||||||
// here. Instead, we should rely on the struct defined in the proto
|
// here. Instead, we should rely on the struct defined in the proto
|
||||||
// `PendingSweepsResponse` only.
|
// `PendingSweepsResponse` only.
|
||||||
type PendingSweep struct {
|
type PendingSweep struct {
|
||||||
OutPoint OutPoint `json:"outpoint"`
|
OutPoint lnd.OutPoint `json:"outpoint"`
|
||||||
WitnessType string `json:"witness_type"`
|
WitnessType string `json:"witness_type"`
|
||||||
AmountSat uint32 `json:"amount_sat"`
|
AmountSat uint32 `json:"amount_sat"`
|
||||||
SatPerVByte uint32 `json:"sat_per_vbyte"`
|
SatPerVByte uint32 `json:"sat_per_vbyte"`
|
||||||
@@ -29,7 +32,9 @@ type PendingSweep struct {
|
|||||||
// its corresponding CLI-friendly type.
|
// its corresponding CLI-friendly type.
|
||||||
func NewPendingSweepFromProto(pendingSweep *walletrpc.PendingSweep) *PendingSweep {
|
func NewPendingSweepFromProto(pendingSweep *walletrpc.PendingSweep) *PendingSweep {
|
||||||
return &PendingSweep{
|
return &PendingSweep{
|
||||||
OutPoint: NewOutPointFromProto(pendingSweep.Outpoint),
|
OutPoint: lnd.NewOutPointFromProto(
|
||||||
|
pendingSweep.Outpoint,
|
||||||
|
),
|
||||||
WitnessType: pendingSweep.WitnessType.String(),
|
WitnessType: pendingSweep.WitnessType.String(),
|
||||||
AmountSat: pendingSweep.AmountSat,
|
AmountSat: pendingSweep.AmountSat,
|
||||||
SatPerVByte: uint32(pendingSweep.SatPerVbyte),
|
SatPerVByte: uint32(pendingSweep.SatPerVbyte),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands
|
package lnd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
Reference in new issue
Block a user