diff --git a/htlcswitch/link.go b/htlcswitch/link.go index b60b43f1..d02c4672 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -1566,8 +1566,13 @@ func (l *channelLink) updateCommitTx() error { if err == lnwallet.ErrNoWindow { l.tracef("revocation window exhausted, unable to send: %v, "+ "dangling_opens=%v, dangling_closes%v", - l.batchCounter, spew.Sdump(l.openedCircuits), - spew.Sdump(l.closedCircuits)) + l.batchCounter, newLogClosure(func() string { + return spew.Sdump(l.openedCircuits) + }), + newLogClosure(func() string { + return spew.Sdump(l.closedCircuits) + }), + ) return nil } else if err != nil { return err diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 12240238..30f4e28f 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -1251,7 +1251,7 @@ func (s *Switch) closeCircuit(pkt *htlcPacket) (*PaymentCircuit, error) { // we're the originator of the payment, so the link stops attempting to // re-broadcast. func (s *Switch) ackSettleFail(settleFailRef channeldb.SettleFailRef) error { - return s.cfg.DB.Update(func(tx *bolt.Tx) error { + return s.cfg.DB.Batch(func(tx *bolt.Tx) error { return s.cfg.SwitchPackager.AckSettleFails(tx, settleFailRef) }) } diff --git a/routing/router.go b/routing/router.go index 4f3a5bfb..d03f1634 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1458,7 +1458,10 @@ func generateSphinxPacket(route *Route, paymentHash []byte) ([]byte, hopPayloads := route.ToHopPayloads() log.Tracef("Constructed per-hop payloads for payment_hash=%x: %v", - paymentHash[:], spew.Sdump(hopPayloads)) + paymentHash[:], newLogClosure(func() string { + return spew.Sdump(hopPayloads) + }), + ) sessionKey, err := btcec.NewPrivateKey(btcec.S256()) if err != nil { @@ -1467,8 +1470,9 @@ func generateSphinxPacket(route *Route, paymentHash []byte) ([]byte, // Next generate the onion routing packet which allows us to perform // privacy preserving source routing across the network. - sphinxPacket, err := sphinx.NewOnionPacket(nodes, sessionKey, - hopPayloads, paymentHash) + sphinxPacket, err := sphinx.NewOnionPacket( + nodes, sessionKey, hopPayloads, paymentHash, + ) if err != nil { return nil, nil, err } diff --git a/rpcserver.go b/rpcserver.go index 99de1e34..98241511 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -11,11 +11,11 @@ import ( "math" "sort" "strings" + "sync" "time" "gopkg.in/macaroon-bakery.v2/bakery" - "sync" "sync/atomic" "github.com/coreos/bbolt" @@ -51,6 +51,8 @@ const ( ) var ( + zeroHash [32]byte + // maxPaymentMSat is the maximum allowed payment currently permitted as // defined in BOLT-002. This value depends on which chain is active. // It is set to the value under the Bitcoin chain as default. @@ -2061,9 +2063,10 @@ func extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPaymentIntent, error payIntent.cltvDelta = uint16(rpcPayReq.FinalCltvDelta) - // If the user is manually specifying payment details, then the - // payment hash may be encoded as a string. - if rpcPayReq.PaymentHashString != "" { + // If the user is manually specifying payment details, then the payment + // hash may be encoded as a string. + switch { + case rpcPayReq.PaymentHashString != "": paymentHash, err := hex.DecodeString( rpcPayReq.PaymentHashString, ) @@ -2072,15 +2075,15 @@ func extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPaymentIntent, error } copy(payIntent.rHash[:], paymentHash) - } else { - copy(payIntent.rHash[:], rpcPayReq.PaymentHash) - } // If we're in debug HTLC mode, then all outgoing HTLCs will pay to the // same debug rHash. Otherwise, we pay to the rHash specified within // the RPC request. - if cfg.DebugHTLC && len(payIntent.rHash) == 0 { + case cfg.DebugHTLC && bytes.Equal(payIntent.rHash[:], zeroHash[:]): copy(payIntent.rHash[:], debugHash[:]) + + default: + copy(payIntent.rHash[:], rpcPayReq.PaymentHash) } // Currently, within the bootstrap phase of the network, we limit the