Merge pull request #7624 from ellemouton/marshalBytesAndStringTxid

multi: populate both string and byte TXID in lnrpc.Outpoint
This commit is contained in:
Oliver Gugger authored and GitHub committed 2023-05-08 17:32:54 +02:00
commit 8df4edef1b
6 files changed
+22 -25

No files matched your search

+11 -5
View File
@@ -8,6 +8,7 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
)
@@ -106,11 +107,7 @@ func MarshalUtxos(utxos []*lnwallet.Utxo, activeNetParams *chaincfg.Params) (
// Now that we know we have a proper mapping to an address,
// we'll convert the regular outpoint to an lnrpc variant.
outpoint := &OutPoint{
TxidBytes: utxo.OutPoint.Hash[:],
TxidStr: utxo.OutPoint.Hash.String(),
OutputIndex: utxo.OutPoint.Index,
}
outpoint := MarshalOutPoint(&utxo.OutPoint)
utxoResp := Utxo{
AddressType: addrType,
@@ -173,3 +170,12 @@ func MarshallOutputType(o txscript.ScriptClass) OutputScriptType {
return OutputScriptType_SCRIPT_TYPE_PUBKEY_HASH
}
}
// MarshalOutPoint converts a wire.OutPoint to its proto counterpart.
func MarshalOutPoint(op *wire.OutPoint) *OutPoint {
return &OutPoint{
TxidBytes: op.Hash[:],
TxidStr: op.Hash.String(),
OutputIndex: op.Index,
}
}
+3 -10
View File
@@ -780,10 +780,7 @@ func (w *WalletKit) PendingSweeps(ctx context.Context,
pendingInput.OutPoint)
}
op := &lnrpc.OutPoint{
TxidBytes: pendingInput.OutPoint.Hash[:],
OutputIndex: pendingInput.OutPoint.Index,
}
op := lnrpc.MarshalOutPoint(&pendingInput.OutPoint)
amountSat := uint32(pendingInput.Amount)
satPerVbyte := uint64(pendingInput.LastFeeRate.FeePerKVByte() / 1000)
broadcastAttempts := uint32(pendingInput.BroadcastAttempts)
@@ -1268,12 +1265,8 @@ func marshallLeases(locks []*base.ListLeasedOutputResult) []*UtxoLease {
lock := lock
rpcLocks[idx] = &UtxoLease{
Id: lock.LockID[:],
Outpoint: &lnrpc.OutPoint{
TxidBytes: lock.Outpoint.Hash[:],
TxidStr: lock.Outpoint.Hash.String(),
OutputIndex: lock.Outpoint.Index,
},
Id: lock.LockID[:],
Outpoint: lnrpc.MarshalOutPoint(&lock.Outpoint),
Expiration: uint64(lock.Expiration.Unix()),
PkScript: lock.PkScript,
Value: uint64(lock.Value),