mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-07 05:30:11 +02:00
Merge pull request #7766 from ffranr/export_unmarshall_outpoint
Export unmarshall outpoint functionality
This commit is contained in:
commit
df9b53b6af
@ -464,7 +464,7 @@ func (w *WalletKit) LeaseOutput(ctx context.Context,
|
|||||||
return nil, errors.New("reserved id cannot be used")
|
return nil, errors.New("reserved id cannot be used")
|
||||||
}
|
}
|
||||||
|
|
||||||
op, err := unmarshallOutPoint(req.Outpoint)
|
op, err := UnmarshallOutPoint(req.Outpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -505,7 +505,7 @@ func (w *WalletKit) ReleaseOutput(ctx context.Context,
|
|||||||
var lockID wtxmgr.LockID
|
var lockID wtxmgr.LockID
|
||||||
copy(lockID[:], req.Id)
|
copy(lockID[:], req.Id)
|
||||||
|
|
||||||
op, err := unmarshallOutPoint(req.Outpoint)
|
op, err := UnmarshallOutPoint(req.Outpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -807,21 +807,19 @@ func (w *WalletKit) PendingSweeps(ctx context.Context,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmarshallOutPoint converts an outpoint from its lnrpc type to its canonical
|
// UnmarshallOutPoint converts an outpoint from its lnrpc type to its canonical
|
||||||
// type.
|
// type.
|
||||||
func unmarshallOutPoint(op *lnrpc.OutPoint) (*wire.OutPoint, error) {
|
func UnmarshallOutPoint(op *lnrpc.OutPoint) (*wire.OutPoint, error) {
|
||||||
if op == nil {
|
if op == nil {
|
||||||
return nil, fmt.Errorf("empty outpoint provided")
|
return nil, fmt.Errorf("empty outpoint provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
var hash chainhash.Hash
|
var hash chainhash.Hash
|
||||||
switch {
|
switch {
|
||||||
|
// Return an error if both txid fields are unpopulated.
|
||||||
case len(op.TxidBytes) == 0 && len(op.TxidStr) == 0:
|
case len(op.TxidBytes) == 0 && len(op.TxidStr) == 0:
|
||||||
fallthrough
|
return nil, fmt.Errorf("TxidBytes and TxidStr are both " +
|
||||||
|
"unspecified")
|
||||||
case len(op.TxidBytes) != 0 && len(op.TxidStr) != 0:
|
|
||||||
return nil, fmt.Errorf("either TxidBytes or TxidStr must be " +
|
|
||||||
"specified, but not both")
|
|
||||||
|
|
||||||
// The hash was provided as raw bytes.
|
// The hash was provided as raw bytes.
|
||||||
case len(op.TxidBytes) != 0:
|
case len(op.TxidBytes) != 0:
|
||||||
@ -851,7 +849,7 @@ func (w *WalletKit) BumpFee(ctx context.Context,
|
|||||||
in *BumpFeeRequest) (*BumpFeeResponse, error) {
|
in *BumpFeeRequest) (*BumpFeeResponse, error) {
|
||||||
|
|
||||||
// Parse the outpoint from the request.
|
// Parse the outpoint from the request.
|
||||||
op, err := unmarshallOutPoint(in.Outpoint)
|
op, err := UnmarshallOutPoint(in.Outpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1125,7 +1123,7 @@ func (w *WalletKit) FundPsbt(_ context.Context,
|
|||||||
|
|
||||||
txIn := make([]*wire.OutPoint, len(tpl.Inputs))
|
txIn := make([]*wire.OutPoint, len(tpl.Inputs))
|
||||||
for idx, in := range tpl.Inputs {
|
for idx, in := range tpl.Inputs {
|
||||||
op, err := unmarshallOutPoint(in)
|
op, err := UnmarshallOutPoint(in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error parsing "+
|
return nil, fmt.Errorf("error parsing "+
|
||||||
"outpoint: %v", err)
|
"outpoint: %v", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user