lnd/lnwire/outpoint.go
Oli 8047149c6a
multi: upgrade to btcd v2 modules
Migrate all btcd dependencies to the new per-package v2 modules (wire/v2,
txscript/v2, chaincfg/v2, chainhash/v2, btcutil/v2, psbt/v2, btcec/v2)
introduced by btcd v0.26.0, and pin the tagged ecosystem versions:
btcwallet v0.17.0, neutrino v0.18.0 and lightning-onion v1.4.0.

The bulk of the import rewrite was produced by the scripted diff from
https://github.com/btcsuite/btcd/pull/2547 (followed by 'make rpc'). The
address symbols that moved out of btcutil into the new address package
are imported as btcaddr where a local "address" variable would otherwise
shadow them. The go.mod/go.sum updates and the remaining manual
compilation fixes are folded into this single commit so it builds on its
own (the migration was previously split into a reproducible scripted-diff
plus follow-ups, intended to be squashed on merge).
2026-06-24 10:58:36 -07:00

53 lines
1.3 KiB
Go

package lnwire
import (
"bytes"
"io"
"github.com/btcsuite/btcd/wire/v2"
"github.com/lightningnetwork/lnd/tlv"
)
// OutPoint describes an outpoint of a transaction via its transaction hash
// and the outpoint index. This is a thin wrapper around the wire.OutPoint to
// provide TLV encoding/decoding.
type OutPoint wire.OutPoint
// Record returns a TLV record that can be used to encode/decode the OutPoint.
//
// NOTE: this is part of the tlv.RecordProducer interface.
func (o *OutPoint) Record() tlv.Record {
return tlv.MakeStaticRecord(0, o, 34, outpointEncoder, outpointDecoder)
}
// outpointEncoder is a TLV encoder for OutPoint.
func outpointEncoder(w io.Writer, val any, _ *[8]byte) error {
if v, ok := val.(*OutPoint); ok {
buf := bytes.NewBuffer(nil)
err := WriteOutPoint(buf, wire.OutPoint(*v))
if err != nil {
return err
}
_, err = w.Write(buf.Bytes())
return err
}
return tlv.NewTypeForEncodingErr(val, "OutPoint")
}
// outpointDecoder is a TLV decoder for OutPoint.
func outpointDecoder(r io.Reader, val any, _ *[8]byte, l uint64) error {
if v, ok := val.(*OutPoint); ok {
var o wire.OutPoint
if err := ReadElement(r, &o); err != nil {
return err
}
*v = OutPoint(o)
return nil
}
return tlv.NewTypeForDecodingErr(val, "OutPoint", l, 34)
}