mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 14:45:23 +01:00
lnd+funding: use funding.WriteOutpoint instead of lnd version
This commit duplicates the utxonursery's writeOutpoint function in the funding package so that when the rest of the fundingmanager code is moved, it can use the WriteOutpoint function for its channel opening state data.
This commit is contained in:
parent
61e0f67edf
commit
f6524aabcb
28
funding/manager.go
Normal file
28
funding/manager.go
Normal file
@ -0,0 +1,28 @@
|
||||
package funding
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
var (
|
||||
// byteOrder defines the endian-ness we use for encoding to and from
|
||||
// buffers.
|
||||
byteOrder = binary.BigEndian
|
||||
)
|
||||
|
||||
// WriteOutpoint writes an outpoint to an io.Writer. This is not the same as
|
||||
// the channeldb variant as this uses WriteVarBytes for the Hash.
|
||||
func WriteOutpoint(w io.Writer, o *wire.OutPoint) error {
|
||||
scratch := make([]byte, 4)
|
||||
|
||||
if err := wire.WriteVarBytes(w, 0, o.Hash[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
byteOrder.PutUint32(scratch, o.Index)
|
||||
_, err := w.Write(scratch)
|
||||
return err
|
||||
}
|
@ -20,6 +20,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/kvdb"
|
||||
"github.com/lightningnetwork/lnd/discovery"
|
||||
"github.com/lightningnetwork/lnd/funding"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
@ -3536,7 +3537,7 @@ func (f *fundingManager) saveChannelOpeningState(chanPoint *wire.OutPoint,
|
||||
}
|
||||
|
||||
var outpointBytes bytes.Buffer
|
||||
if err = writeOutpoint(&outpointBytes, chanPoint); err != nil {
|
||||
if err = funding.WriteOutpoint(&outpointBytes, chanPoint); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -3568,7 +3569,7 @@ func (f *fundingManager) getChannelOpeningState(chanPoint *wire.OutPoint) (
|
||||
}
|
||||
|
||||
var outpointBytes bytes.Buffer
|
||||
if err := writeOutpoint(&outpointBytes, chanPoint); err != nil {
|
||||
if err := funding.WriteOutpoint(&outpointBytes, chanPoint); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -3597,7 +3598,7 @@ func (f *fundingManager) deleteChannelOpeningState(chanPoint *wire.OutPoint) err
|
||||
}
|
||||
|
||||
var outpointBytes bytes.Buffer
|
||||
if err := writeOutpoint(&outpointBytes, chanPoint); err != nil {
|
||||
if err := funding.WriteOutpoint(&outpointBytes, chanPoint); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user