lnd: fix gosimple warnings
This commit is contained in:
parent
f5fd4138a0
commit
8fb54782e2
@ -443,11 +443,8 @@ func (b *BrontideMachine) RecvActOne(actOne [ActOneSize]byte) error {
|
||||
|
||||
// If the initiator doesn't know our static key, then this operation
|
||||
// will fail.
|
||||
if _, err := b.DecryptAndHash(p[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err = b.DecryptAndHash(p[:])
|
||||
return err
|
||||
}
|
||||
|
||||
// GenActTwo generates the second packet (act two) to be sent from the
|
||||
@ -515,11 +512,8 @@ func (b *BrontideMachine) RecvActTwo(actTwo [ActTwoSize]byte) error {
|
||||
s := ecdh(b.remoteEphemeral, b.localEphemeral)
|
||||
b.mixKey(s)
|
||||
|
||||
if _, err := b.DecryptAndHash(p[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err = b.DecryptAndHash(p[:])
|
||||
return err
|
||||
}
|
||||
|
||||
// GenActThree creates the final (act three) packet of the handshake. Act three
|
||||
@ -662,11 +656,8 @@ func (b *BrontideMachine) WriteMessage(w io.Writer, p []byte) error {
|
||||
// single packet, as any fragmentation should have taken place at a
|
||||
// higher level.
|
||||
cipherText := b.sendCipher.Encrypt(nil, nil, p)
|
||||
if _, err := w.Write(cipherText); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err := w.Write(cipherText)
|
||||
return err
|
||||
}
|
||||
|
||||
// ReadMessage attempts to read the next message from the passed io.Reader. In
|
||||
|
@ -1269,11 +1269,7 @@ func fetchChannelIDs(nodeChanBucket *bolt.Bucket, channel *OpenChannel) error {
|
||||
|
||||
idBytes := nodeChanBucket.Get(idKey)
|
||||
channel.IdentityPub, err = btcec.ParsePubKey(idBytes, btcec.S256())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func putChanCommitKeys(nodeChanBucket *bolt.Bucket, channel *OpenChannel) error {
|
||||
@ -1329,11 +1325,7 @@ func fetchChanCommitKeys(nodeChanBucket *bolt.Bucket, channel *OpenChannel) erro
|
||||
}
|
||||
|
||||
channel.OurCommitKey, err = btcec.ParsePubKey(keyBytes[33:], btcec.S256())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func putChanCommitTxns(nodeChanBucket *bolt.Bucket, channel *OpenChannel) error {
|
||||
@ -1631,11 +1623,7 @@ func fetchChanPreimageState(nodeChanBucket *bolt.Bucket, channel *OpenChannel) e
|
||||
}
|
||||
|
||||
_, err = io.ReadFull(reader, channel.StateHintObsfucator[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func putChanDeliveryScripts(nodeChanBucket *bolt.Bucket, channel *OpenChannel) error {
|
||||
@ -1683,11 +1671,7 @@ func fetchChanDeliveryScripts(nodeChanBucket *bolt.Bucket, channel *OpenChannel)
|
||||
}
|
||||
|
||||
channel.TheirDeliveryScript, err = wire.ReadVarBytes(deliveryBytes, 0, 520, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// htlcDiskSize represents the number of btyes a serialized HTLC takes up on
|
||||
@ -1717,11 +1701,8 @@ func serializeHTLC(w io.Writer, h *HTLC) error {
|
||||
byteOrder.PutUint16(buf[n:], h.OutputIndex)
|
||||
n += 2
|
||||
|
||||
if _, err := w.Write(buf[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err := w.Write(buf[:])
|
||||
return err
|
||||
}
|
||||
|
||||
func deserializeHTLC(r io.Reader) (*HTLC, error) {
|
||||
@ -1980,11 +1961,8 @@ func writeOutpoint(w io.Writer, o *wire.OutPoint) error {
|
||||
}
|
||||
|
||||
byteOrder.PutUint32(scratch, o.Index)
|
||||
if _, err := w.Write(scratch); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err := w.Write(scratch)
|
||||
return err
|
||||
}
|
||||
|
||||
func readOutpoint(r io.Reader, o *wire.OutPoint) error {
|
||||
|
@ -437,11 +437,7 @@ func (d *DB) syncVersions(versions []version) error {
|
||||
}
|
||||
|
||||
meta.DbVersionNumber = latestVersion
|
||||
if err := putMeta(meta, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return putMeta(meta, tx)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,5 @@ func putMeta(meta *Meta, tx *bolt.Tx) error {
|
||||
func putDbVersion(metaBucket *bolt.Bucket, meta *Meta) error {
|
||||
scratch := make([]byte, 4)
|
||||
byteOrder.PutUint32(scratch, meta.DbVersionNumber)
|
||||
if err := metaBucket.Put(dbVersionKey, scratch); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return metaBucket.Put(dbVersionKey, scratch)
|
||||
}
|
||||
|
@ -158,11 +158,7 @@ func (db *DB) FetchLinkNode(identity *btcec.PublicKey) (*LinkNode, error) {
|
||||
// returned to the caller.
|
||||
nodeReader := bytes.NewReader(nodeBytes)
|
||||
node, err = deserializeLinkNode(nodeReader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -127,11 +127,7 @@ func (db *DB) DeleteAllPayments() error {
|
||||
}
|
||||
|
||||
_, err = tx.CreateBucket(paymentBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -88,14 +88,10 @@ func (i *invoiceRegistry) AddInvoice(invoice *channeldb.Invoice) error {
|
||||
}))
|
||||
|
||||
// TODO(roasbeef): also check in memory for quick lookups/settles?
|
||||
if err := i.cdb.AddInvoice(invoice); err != nil {
|
||||
return err
|
||||
}
|
||||
return i.cdb.AddInvoice(invoice)
|
||||
|
||||
// TODO(roasbeef): re-enable?
|
||||
//go i.notifyClients(invoice, false)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// lookupInvoice looks up an invoice by its payment hash (R-Hash), if found
|
||||
|
@ -281,11 +281,7 @@ func (b *BtcWallet) FetchRootKey() (*btcec.PrivateKey, error) {
|
||||
rootBucket := tx.RootBucket()
|
||||
|
||||
rootAddrHash = rootAddr[0].Address().ScriptAddress()
|
||||
if err := rootBucket.Put(rootKey, rootAddrHash); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return rootBucket.Put(rootKey, rootAddrHash)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -311,17 +311,14 @@ func loadTestCredits(miner *rpctest.Harness, w *lnwallet.LightningWallet, numOut
|
||||
// Wait until the wallet has finished syncing up to the main chain.
|
||||
ticker := time.NewTicker(100 * time.Millisecond)
|
||||
expectedBalance := btcutil.Amount(satoshiPerOutput * int64(numOutputs))
|
||||
out:
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
balance, err := w.ConfirmedBalance(1, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if balance == expectedBalance {
|
||||
break out
|
||||
}
|
||||
|
||||
for range ticker.C {
|
||||
balance, err := w.ConfirmedBalance(1, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if balance == expectedBalance {
|
||||
break
|
||||
}
|
||||
}
|
||||
ticker.Stop()
|
||||
|
@ -56,7 +56,7 @@ func (a *ChannelAnnouncement) Validate() error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.FirstNodeSig,
|
||||
&c.SecondNodeSig,
|
||||
&c.ChannelID,
|
||||
@ -67,11 +67,6 @@ func (c *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
&c.FirstBitcoinKey,
|
||||
&c.SecondBitcoinKey,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target ChannelAnnouncement into the passed io.Writer
|
||||
@ -79,7 +74,7 @@ func (c *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.FirstNodeSig,
|
||||
c.SecondNodeSig,
|
||||
c.ChannelID,
|
||||
@ -90,11 +85,6 @@ func (c *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||
c.FirstBitcoinKey,
|
||||
c.SecondBitcoinKey,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -72,7 +72,7 @@ func (a *ChannelUpdateAnnouncement) Validate() error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.Signature,
|
||||
&c.ChannelID,
|
||||
&c.Timestamp,
|
||||
@ -82,11 +82,6 @@ func (c *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
&c.FeeBaseMsat,
|
||||
&c.FeeProportionalMillionths,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target ChannelUpdateAnnouncement into the passed
|
||||
@ -94,7 +89,7 @@ func (c *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.Signature,
|
||||
c.ChannelID,
|
||||
c.Timestamp,
|
||||
@ -104,11 +99,6 @@ func (c *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||
c.FeeBaseMsat,
|
||||
c.FeeProportionalMillionths,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -43,14 +43,9 @@ var _ Message = (*CloseComplete)(nil)
|
||||
func (c *CloseComplete) Decode(r io.Reader, pver uint32) error {
|
||||
// ChannelPoint (8)
|
||||
// ResponderCloseSig (73)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelPoint,
|
||||
&c.ResponderCloseSig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target CloseComplete into the passed io.Writer observing
|
||||
@ -60,14 +55,9 @@ func (c *CloseComplete) Decode(r io.Reader, pver uint32) error {
|
||||
func (c *CloseComplete) Encode(w io.Writer, pver uint32) error {
|
||||
// ChannelPoint (8)
|
||||
// ResponderCloseSig (73)
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelPoint,
|
||||
c.ResponderCloseSig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -57,15 +57,10 @@ func (c *CloseRequest) Decode(r io.Reader, pver uint32) error {
|
||||
// RequesterCloseSig (73)
|
||||
// First byte length then sig
|
||||
// Fee (8)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelPoint,
|
||||
&c.RequesterCloseSig,
|
||||
&c.Fee)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target CloseRequest into the passed io.Writer observing
|
||||
@ -76,15 +71,10 @@ func (c *CloseRequest) Encode(w io.Writer, pver uint32) error {
|
||||
// ChannelID
|
||||
// RequesterCloseSig
|
||||
// Fee
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelPoint,
|
||||
c.RequesterCloseSig,
|
||||
c.Fee)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -46,15 +46,10 @@ var _ Message = (*CommitSig)(nil)
|
||||
func (c *CommitSig) Decode(r io.Reader, pver uint32) error {
|
||||
// ChannelPoint(8)
|
||||
// RequesterCommitSig(73max+2)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelPoint,
|
||||
&c.CommitSig,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target CommitSig into the passed io.Writer
|
||||
@ -62,14 +57,10 @@ func (c *CommitSig) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *CommitSig) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelPoint,
|
||||
c.CommitSig,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -73,17 +73,12 @@ var _ Message = (*ErrorGeneric)(nil)
|
||||
func (c *ErrorGeneric) Decode(r io.Reader, pver uint32) error {
|
||||
// ChannelPoint(8)
|
||||
// Problem
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelPoint,
|
||||
&c.Code,
|
||||
&c.Problem,
|
||||
&c.PendingChannelID,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target ErrorGeneric into the passed io.Writer
|
||||
@ -91,17 +86,12 @@ func (c *ErrorGeneric) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *ErrorGeneric) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelPoint,
|
||||
c.Code,
|
||||
c.Problem,
|
||||
c.PendingChannelID,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying an ErrorGeneric message on
|
||||
|
@ -197,11 +197,8 @@ func (f *FeatureVector) Encode(w io.Writer) error {
|
||||
setFlag(data, position, flag)
|
||||
}
|
||||
|
||||
if _, err := w.Write(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err := w.Write(data)
|
||||
return err
|
||||
}
|
||||
|
||||
// Compare checks that features are compatible and returns the features which
|
||||
|
@ -1,8 +1,8 @@
|
||||
package lnwire
|
||||
|
||||
import (
|
||||
"io"
|
||||
"github.com/go-errors/errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Init is the first message reveals the features supported or required by this
|
||||
@ -34,15 +34,10 @@ func NewInitMessage(gf, lf *FeatureVector) *Init {
|
||||
func (msg *Init) Decode(r io.Reader, pver uint32) error {
|
||||
// LocalFeatures(~)
|
||||
// GlobalFeatures(~)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&msg.LocalFeatures,
|
||||
&msg.GlobalFeatures,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// A compile time check to ensure Init implements the lnwire.Message
|
||||
@ -54,15 +49,10 @@ var _ Message = (*Init)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (msg *Init) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
msg.LocalFeatures,
|
||||
msg.GlobalFeatures,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -244,11 +244,7 @@ func WriteMessage(w io.Writer, msg Message, pver uint32, btcnet wire.BitcoinNet)
|
||||
// Write payload the payload itself after the header.
|
||||
n, err = w.Write(payload)
|
||||
totalBytes += n
|
||||
if err != nil {
|
||||
return totalBytes, err
|
||||
}
|
||||
|
||||
return totalBytes, nil
|
||||
return totalBytes, err
|
||||
}
|
||||
|
||||
// ReadMessageN reads, validates, and parses the next bitcoin Message from r for
|
||||
|
@ -128,7 +128,7 @@ func (a *NodeAnnouncement) Validate() error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.Signature,
|
||||
&c.Timestamp,
|
||||
&c.Address,
|
||||
@ -137,11 +137,6 @@ func (c *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
&c.pad,
|
||||
&c.Alias,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target NodeAnnouncement into the passed io.Writer
|
||||
@ -149,7 +144,7 @@ func (c *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *NodeAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.Signature,
|
||||
c.Timestamp,
|
||||
c.Address,
|
||||
@ -158,11 +153,6 @@ func (c *NodeAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||
c.pad,
|
||||
c.Alias,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -27,14 +27,9 @@ var _ Message = (*Pong)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (p *Pong) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&p.Nonce,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target Pong into the passed io.Writer observing the
|
||||
@ -42,14 +37,9 @@ func (p *Pong) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (p *Pong) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
p.Nonce,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -26,14 +26,9 @@ var _ Message = (*Ping)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (p *Ping) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&p.Nonce,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target Ping into the passed io.Writer observing the
|
||||
@ -41,14 +36,9 @@ func (p *Ping) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (p *Ping) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
p.Nonce,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -62,17 +62,12 @@ func (c *RevokeAndAck) Decode(r io.Reader, pver uint32) error {
|
||||
// Revocation (32)
|
||||
// NextRevocationKey (33)
|
||||
// NextRevocationHash (32)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelPoint,
|
||||
c.Revocation[:],
|
||||
&c.NextRevocationKey,
|
||||
c.NextRevocationHash[:],
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target RevokeAndAck into the passed io.Writer
|
||||
@ -80,17 +75,12 @@ func (c *RevokeAndAck) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *RevokeAndAck) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelPoint,
|
||||
c.Revocation[:],
|
||||
c.NextRevocationKey,
|
||||
c.NextRevocationHash[:],
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -69,17 +69,12 @@ func (s *SingleFundingComplete) Decode(r io.Reader, pver uint32) error {
|
||||
// FundingOutPoint (36)
|
||||
// CommitmentSignature (73)
|
||||
// RevocationKey (33)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&s.ChannelID,
|
||||
&s.FundingOutPoint,
|
||||
&s.CommitSignature,
|
||||
&s.RevocationKey,
|
||||
s.StateHintObsfucator[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target SingleFundingComplete into the passed io.Writer
|
||||
@ -92,17 +87,12 @@ func (s *SingleFundingComplete) Encode(w io.Writer, pver uint32) error {
|
||||
// FundingOutPoint (36)
|
||||
// Commitment Signature (73)
|
||||
// RevocationKey (33)
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
s.ChannelID,
|
||||
s.FundingOutPoint,
|
||||
s.CommitSignature,
|
||||
s.RevocationKey,
|
||||
s.StateHintObsfucator[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the uint32 code which uniquely identifies this message as a
|
||||
|
0
lnwire/single_funding_open_proof.go
Normal file
0
lnwire/single_funding_open_proof.go
Normal file
@ -40,14 +40,9 @@ func NewSingleFundingSignComplete(chanID uint64,
|
||||
func (c *SingleFundingSignComplete) Decode(r io.Reader, pver uint32) error {
|
||||
// ChannelID (8)
|
||||
// CommitmentSignature (73)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelID,
|
||||
&c.CommitSignature)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target SingleFundingSignComplete into the passed
|
||||
@ -56,14 +51,9 @@ func (c *SingleFundingSignComplete) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *SingleFundingSignComplete) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelID,
|
||||
c.CommitSignature)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the uint32 code which uniquely identifies this message as a
|
||||
|
@ -76,7 +76,7 @@ func (c *UpdateAddHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
// Amount(8)
|
||||
// PaymentHash(32)
|
||||
// OnionBlob(1254)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelPoint,
|
||||
&c.ID,
|
||||
&c.Expiry,
|
||||
@ -84,11 +84,6 @@ func (c *UpdateAddHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
c.PaymentHash[:],
|
||||
c.OnionBlob[:],
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target UpdateAddHTLC into the passed io.Writer observing
|
||||
@ -96,7 +91,7 @@ func (c *UpdateAddHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateAddHTLC) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelPoint,
|
||||
c.ID,
|
||||
c.Expiry,
|
||||
@ -104,11 +99,6 @@ func (c *UpdateAddHTLC) Encode(w io.Writer, pver uint32) error {
|
||||
c.PaymentHash[:],
|
||||
c.OnionBlob[:],
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -108,16 +108,11 @@ func (c *UpdateFailHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
// ChannelPoint(8)
|
||||
// HTLCKey(8)
|
||||
// Reason(??)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelPoint,
|
||||
&c.ID,
|
||||
&c.Reason,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target UpdateFailHTLC into the passed io.Writer observing
|
||||
@ -125,16 +120,11 @@ func (c *UpdateFailHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFailHTLC) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelPoint,
|
||||
c.ID,
|
||||
c.Reason,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -48,16 +48,11 @@ func (c *UpdateFufillHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
// ChannelPoint(8)
|
||||
// ID(8)
|
||||
// PaymentPreimage(32)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelPoint,
|
||||
&c.ID,
|
||||
c.PaymentPreimage[:],
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target UpdateFufillHTLC into the passed io.Writer
|
||||
@ -65,16 +60,11 @@ func (c *UpdateFufillHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFufillHTLC) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelPoint,
|
||||
c.ID,
|
||||
c.PaymentPreimage[:],
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the integer uniquely identifying this message type on the
|
||||
|
@ -541,11 +541,8 @@ func (n *networkHarness) ConnectNodes(ctx context.Context, a, b *lightningNode)
|
||||
Host: b.p2pAddr,
|
||||
},
|
||||
}
|
||||
if _, err := a.ConnectPeer(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err = a.ConnectPeer(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
// RestartNode attempts to restart a lightning node by shutting it down
|
||||
|
@ -668,7 +668,7 @@ func createSweepTx(wallet *lnwallet.LightningWallet,
|
||||
// chain reorganization occurs. This is the final step in the output incubation
|
||||
// process.
|
||||
func deleteGraduatedOutputs(db *channeldb.DB, deleteHeight uint32) error {
|
||||
err := db.Update(func(tx *bolt.Tx) error {
|
||||
return db.Update(func(tx *bolt.Tx) error {
|
||||
kgtnBucket := tx.Bucket(kindergartenBucket)
|
||||
if kgtnBucket == nil {
|
||||
return nil
|
||||
@ -695,18 +695,13 @@ func deleteGraduatedOutputs(db *channeldb.DB, deleteHeight uint32) error {
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// putLastHeightGraduated persists the most recently processed blockheight
|
||||
// to the database. This blockheight is used during restarts to determine if
|
||||
// blocks were missed while the UTXO Nursery was offline.
|
||||
func putLastHeightGraduated(db *channeldb.DB, blockheight uint32) error {
|
||||
err := db.Update(func(tx *bolt.Tx) error {
|
||||
return db.Update(func(tx *bolt.Tx) error {
|
||||
kgtnBucket, err := tx.CreateBucketIfNotExists(kindergartenBucket)
|
||||
if err != nil {
|
||||
return nil
|
||||
@ -714,17 +709,8 @@ func putLastHeightGraduated(db *channeldb.DB, blockheight uint32) error {
|
||||
|
||||
heightBytes := make([]byte, 4)
|
||||
byteOrder.PutUint32(heightBytes, blockheight)
|
||||
if err := kgtnBucket.Put(lastGraduatedHeightKey, heightBytes); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return kgtnBucket.Put(lastGraduatedHeightKey, heightBytes)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// newSweepPkScript creates a new public key script which should be used to
|
||||
@ -808,11 +794,8 @@ func serializeKidOutput(w io.Writer, kid *kidOutput) error {
|
||||
}
|
||||
|
||||
byteOrder.PutUint32(scratch[:4], uint32(kid.signDescriptor.HashType))
|
||||
if _, err := w.Write(scratch[:4]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err := w.Write(scratch[:4])
|
||||
return err
|
||||
}
|
||||
|
||||
// deserializeKidOutput takes a byte array representation of a kidOutput
|
||||
@ -899,11 +882,8 @@ func writeOutpoint(w io.Writer, o *wire.OutPoint) error {
|
||||
}
|
||||
|
||||
byteOrder.PutUint32(scratch, o.Index)
|
||||
if _, err := w.Write(scratch); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err := w.Write(scratch)
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO(bvu): copied from channeldb, remove repetition
|
||||
|
Loading…
Reference in New Issue
Block a user