Skip to content

Commit 8df4ede

Browse files
authored
Merge pull request #7624 from ellemouton/marshalBytesAndStringTxid
multi: populate both string and byte TXID in lnrpc.Outpoint
2 parents eaa8aa7 + 7b18671 commit 8df4ede

File tree

6 files changed

+22
-25
lines changed

6 files changed

+22
-25
lines changed

docs/release-notes/release-notes-0.17.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
wtdb.BackupIDs](https://github.com/lightningnetwork/lnd/pull/7623) instead of
1313
the entire retribution struct. This reduces the amount of data that needs to
1414
be held in memory.
15+
16+
## Misc
17+
18+
* [Ensure that both the byte and string form of a TXID is populated in the
19+
lnrpc.Outpoint message](https://github.com/lightningnetwork/lnd/pull/7624).
1520

1621
## RPC
1722

funding/batch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ func (b *Batcher) cleanup(ctx context.Context) {
490490
rpcOP := &lnrpc.OutPoint{
491491
OutputIndex: lockedUTXO.Outpoint.OutputIndex,
492492
TxidBytes: lockedUTXO.Outpoint.TxidBytes,
493+
TxidStr: lockedUTXO.Outpoint.TxidStr,
493494
}
494495
_, err := b.cfg.WalletKitServer.ReleaseOutput(
495496
ctx, &walletrpc.ReleaseOutputRequest{

lnrpc/marshall_utils.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/btcsuite/btcd/btcutil"
99
"github.com/btcsuite/btcd/chaincfg"
1010
"github.com/btcsuite/btcd/txscript"
11+
"github.com/btcsuite/btcd/wire"
1112
"github.com/lightningnetwork/lnd/lnwallet"
1213
"github.com/lightningnetwork/lnd/lnwire"
1314
)
@@ -106,11 +107,7 @@ func MarshalUtxos(utxos []*lnwallet.Utxo, activeNetParams *chaincfg.Params) (
106107

107108
// Now that we know we have a proper mapping to an address,
108109
// we'll convert the regular outpoint to an lnrpc variant.
109-
outpoint := &OutPoint{
110-
TxidBytes: utxo.OutPoint.Hash[:],
111-
TxidStr: utxo.OutPoint.Hash.String(),
112-
OutputIndex: utxo.OutPoint.Index,
113-
}
110+
outpoint := MarshalOutPoint(&utxo.OutPoint)
114111

115112
utxoResp := Utxo{
116113
AddressType: addrType,
@@ -173,3 +170,12 @@ func MarshallOutputType(o txscript.ScriptClass) OutputScriptType {
173170
return OutputScriptType_SCRIPT_TYPE_PUBKEY_HASH
174171
}
175172
}
173+
174+
// MarshalOutPoint converts a wire.OutPoint to its proto counterpart.
175+
func MarshalOutPoint(op *wire.OutPoint) *OutPoint {
176+
return &OutPoint{
177+
TxidBytes: op.Hash[:],
178+
TxidStr: op.Hash.String(),
179+
OutputIndex: op.Index,
180+
}
181+
}

lnrpc/walletrpc/walletkit_server.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,7 @@ func (w *WalletKit) PendingSweeps(ctx context.Context,
780780
pendingInput.OutPoint)
781781
}
782782

783-
op := &lnrpc.OutPoint{
784-
TxidBytes: pendingInput.OutPoint.Hash[:],
785-
OutputIndex: pendingInput.OutPoint.Index,
786-
}
783+
op := lnrpc.MarshalOutPoint(&pendingInput.OutPoint)
787784
amountSat := uint32(pendingInput.Amount)
788785
satPerVbyte := uint64(pendingInput.LastFeeRate.FeePerKVByte() / 1000)
789786
broadcastAttempts := uint32(pendingInput.BroadcastAttempts)
@@ -1268,12 +1265,8 @@ func marshallLeases(locks []*base.ListLeasedOutputResult) []*UtxoLease {
12681265
lock := lock
12691266

12701267
rpcLocks[idx] = &UtxoLease{
1271-
Id: lock.LockID[:],
1272-
Outpoint: &lnrpc.OutPoint{
1273-
TxidBytes: lock.Outpoint.Hash[:],
1274-
TxidStr: lock.Outpoint.Hash.String(),
1275-
OutputIndex: lock.Outpoint.Index,
1276-
},
1268+
Id: lock.LockID[:],
1269+
Outpoint: lnrpc.MarshalOutPoint(&lock.Outpoint),
12771270
Expiration: uint64(lock.Expiration.Unix()),
12781271
PkScript: lock.PkScript,
12791272
Value: uint64(lock.Value),

routing/localchans/manager.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,7 @@ func (r *Manager) getHtlcAmtLimits(tx kvdb.RTx, chanPoint wire.OutPoint) (
265265
func makeFailureItem(outPoint wire.OutPoint, updateFailure lnrpc.UpdateFailure,
266266
errStr string) *lnrpc.FailedUpdate {
267267

268-
outpoint := &lnrpc.OutPoint{
269-
TxidBytes: outPoint.Hash[:],
270-
TxidStr: outPoint.Hash.String(),
271-
OutputIndex: outPoint.Index,
272-
}
268+
outpoint := lnrpc.MarshalOutPoint(&outPoint)
273269

274270
return &lnrpc.FailedUpdate{
275271
Outpoint: outpoint,

rpcserver.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,11 +4489,7 @@ func rpcChannelResolution(report *channeldb.ResolverReport) (*lnrpc.Resolution,
44894489

44904490
res := &lnrpc.Resolution{
44914491
AmountSat: uint64(report.Amount),
4492-
Outpoint: &lnrpc.OutPoint{
4493-
OutputIndex: report.OutPoint.Index,
4494-
TxidStr: report.OutPoint.Hash.String(),
4495-
TxidBytes: report.OutPoint.Hash[:],
4496-
},
4492+
Outpoint: lnrpc.MarshalOutPoint(&report.OutPoint),
44974493
}
44984494

44994495
if report.SpendTxID != nil {

0 commit comments

Comments
 (0)