misc: fix error formatting in multiple files

This commit is contained in:
Andras Banki-Horvath 2020-04-14 19:56:05 +02:00
parent 2b729a78f3
commit 556e3525ea
28 changed files with 91 additions and 91 deletions

@ -648,7 +648,7 @@ func (a *Agent) openChans(availableFunds btcutil.Amount, numChans uint32,
// to open channels to. // to open channels to.
scores, err = chooseN(numChans, scores) scores, err = chooseN(numChans, scores)
if err != nil { if err != nil {
return fmt.Errorf("Unable to make weighted choice: %v", return fmt.Errorf("unable to make weighted choice: %v",
err) err)
} }

@ -130,7 +130,7 @@ func (c *WeightedCombAttachment) NodeScores(g ChannelGraph, chans []Channel,
// Sanity check the new score. // Sanity check the new score.
case score.Score < 0 || score.Score > 1.0: case score.Score < 0 || score.Score > 1.0:
return nil, fmt.Errorf("Invalid node score from "+ return nil, fmt.Errorf("invalid node score from "+
"combination: %v", score.Score) "combination: %v", score.Score)
} }

@ -1358,8 +1358,8 @@ func (rs *retributionStore) Remove(chanPoint *wire.OutPoint) error {
// to remove a finalized retribution state that is not already // to remove a finalized retribution state that is not already
// stored in the db. // stored in the db.
if retBucket == nil { if retBucket == nil {
return errors.New("Unable to remove retribution " + return errors.New("unable to remove retribution " +
"because the retribution bucket doesn't exist.") "because the retribution bucket doesn't exist")
} }
// Serialize the channel point we are intending to remove. // Serialize the channel point we are intending to remove.

@ -492,7 +492,7 @@ func (b *Machine) RecvActOne(actOne [ActOneSize]byte) error {
// If the handshake version is unknown, then the handshake fails // If the handshake version is unknown, then the handshake fails
// immediately. // immediately.
if actOne[0] != HandshakeVersion { if actOne[0] != HandshakeVersion {
return fmt.Errorf("Act One: invalid handshake version: %v, "+ return fmt.Errorf("act one: invalid handshake version: %v, "+
"only %v is valid, msg=%x", actOne[0], HandshakeVersion, "only %v is valid, msg=%x", actOne[0], HandshakeVersion,
actOne[:]) actOne[:])
} }
@ -564,7 +564,7 @@ func (b *Machine) RecvActTwo(actTwo [ActTwoSize]byte) error {
// If the handshake version is unknown, then the handshake fails // If the handshake version is unknown, then the handshake fails
// immediately. // immediately.
if actTwo[0] != HandshakeVersion { if actTwo[0] != HandshakeVersion {
return fmt.Errorf("Act Two: invalid handshake version: %v, "+ return fmt.Errorf("act two: invalid handshake version: %v, "+
"only %v is valid, msg=%x", actTwo[0], HandshakeVersion, "only %v is valid, msg=%x", actTwo[0], HandshakeVersion,
actTwo[:]) actTwo[:])
} }
@ -630,7 +630,7 @@ func (b *Machine) RecvActThree(actThree [ActThreeSize]byte) error {
// If the handshake version is unknown, then the handshake fails // If the handshake version is unknown, then the handshake fails
// immediately. // immediately.
if actThree[0] != HandshakeVersion { if actThree[0] != HandshakeVersion {
return fmt.Errorf("Act Three: invalid handshake version: %v, "+ return fmt.Errorf("act three: invalid handshake version: %v, "+
"only %v is valid, msg=%x", actThree[0], HandshakeVersion, "only %v is valid, msg=%x", actThree[0], HandshakeVersion,
actThree[:]) actThree[:])
} }

@ -1690,7 +1690,7 @@ func (n *TxNotifier) DisconnectTip(blockHeight uint32) error {
defer n.Unlock() defer n.Unlock()
if blockHeight != n.currentHeight { if blockHeight != n.currentHeight {
return fmt.Errorf("Received blocks out of order: "+ return fmt.Errorf("received blocks out of order: "+
"current height=%d, disconnected height=%d", "current height=%d, disconnected height=%d",
n.currentHeight, blockHeight) n.currentHeight, blockHeight)
} }

@ -201,7 +201,7 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB,
defaultLitecoinStaticFeePerKW, 0, defaultLitecoinStaticFeePerKW, 0,
) )
default: default:
return nil, fmt.Errorf("Default routing policy for chain %v is "+ return nil, fmt.Errorf("default routing policy for chain %v is "+
"unknown", registeredChains.PrimaryChain()) "unknown", registeredChains.PrimaryChain())
} }

@ -3086,7 +3086,7 @@ func (c *ChannelGraph) IsPublicNode(pubKey [33]byte) (bool, error) {
// genMultiSigP2WSH generates the p2wsh'd multisig script for 2 of 2 pubkeys. // genMultiSigP2WSH generates the p2wsh'd multisig script for 2 of 2 pubkeys.
func genMultiSigP2WSH(aPub, bPub []byte) ([]byte, error) { func genMultiSigP2WSH(aPub, bPub []byte) ([]byte, error) {
if len(aPub) != 33 || len(bPub) != 33 { if len(aPub) != 33 || len(bPub) != 33 {
return nil, fmt.Errorf("Pubkey size error. Compressed " + return nil, fmt.Errorf("pubkey size error. Compressed " +
"pubkeys only") "pubkeys only")
} }
@ -3833,7 +3833,7 @@ func putChanEdgePolicyUnknown(edges kvdb.RwBucket, channelID uint64,
byteOrder.PutUint64(edgeKey[33:], channelID) byteOrder.PutUint64(edgeKey[33:], channelID)
if edges.Get(edgeKey[:]) != nil { if edges.Get(edgeKey[:]) != nil {
return fmt.Errorf("Cannot write unknown policy for channel %v "+ return fmt.Errorf("cannot write unknown policy for channel %v "+
" when there is already a policy present", channelID) " when there is already a policy present", channelID)
} }

@ -1150,7 +1150,7 @@ func loadConfig() (*config, error) {
// the wallet. // the wallet.
_, err = parseHexColor(cfg.Color) _, err = parseHexColor(cfg.Color)
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to parse node color: %v", err) return nil, fmt.Errorf("unable to parse node color: %v", err)
} }
// Warn about missing config file only after all other configuration is // Warn about missing config file only after all other configuration is

@ -1929,7 +1929,7 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
delete(f.signedReservations, fmsg.msg.ChanID) delete(f.signedReservations, fmsg.msg.ChanID)
f.resMtx.Unlock() f.resMtx.Unlock()
if !ok { if !ok {
err := fmt.Errorf("Unable to find signed reservation for "+ err := fmt.Errorf("unable to find signed reservation for "+
"chan_id=%x", fmsg.msg.ChanID) "chan_id=%x", fmsg.msg.ChanID)
fndgLog.Warnf(err.Error()) fndgLog.Warnf(err.Error())
f.failFundingFlow(fmsg.peer, fmsg.msg.ChanID, err) f.failFundingFlow(fmsg.peer, fmsg.msg.ChanID, err)
@ -2562,7 +2562,7 @@ func (f *fundingManager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
completeChan.FundingBroadcastHeight, completeChan.FundingBroadcastHeight,
) )
if err != nil { if err != nil {
return fmt.Errorf("Unable to register for "+ return fmt.Errorf("unable to register for "+
"confirmation of ChannelPoint(%v): %v", "confirmation of ChannelPoint(%v): %v",
completeChan.FundingOutpoint, err) completeChan.FundingOutpoint, err)
} }
@ -3217,7 +3217,7 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
UpfrontShutdownScript: shutdown, UpfrontShutdownScript: shutdown,
} }
if err := msg.peer.SendMessage(true, &fundingOpen); err != nil { if err := msg.peer.SendMessage(true, &fundingOpen); err != nil {
e := fmt.Errorf("Unable to send funding request message: %v", e := fmt.Errorf("unable to send funding request message: %v",
err) err)
fndgLog.Errorf(e.Error()) fndgLog.Errorf(e.Error())
@ -3501,7 +3501,7 @@ func (f *fundingManager) deleteChannelOpeningState(chanPoint *wire.OutPoint) err
return kvdb.Update(f.cfg.Wallet.Cfg.Database, func(tx kvdb.RwTx) error { return kvdb.Update(f.cfg.Wallet.Cfg.Database, func(tx kvdb.RwTx) error {
bucket := tx.ReadWriteBucket(channelOpeningStateBucket) bucket := tx.ReadWriteBucket(channelOpeningStateBucket)
if bucket == nil { if bucket == nil {
return fmt.Errorf("Bucket not found") return fmt.Errorf("bucket not found")
} }
var outpointBytes bytes.Buffer var outpointBytes bytes.Buffer

@ -2839,7 +2839,7 @@ func TestFundingManagerRejectPush(t *testing.T) {
// Assert Bob responded with an ErrNonZeroPushAmount error. // Assert Bob responded with an ErrNonZeroPushAmount error.
err := assertFundingMsgSent(t, bob.msgChan, "Error").(*lnwire.Error) err := assertFundingMsgSent(t, bob.msgChan, "Error").(*lnwire.Error)
if !strings.Contains(err.Error(), "Non-zero push amounts are disabled") { if !strings.Contains(err.Error(), "non-zero push amounts are disabled") {
t.Fatalf("expected ErrNonZeroPushAmount error, got \"%v\"", t.Fatalf("expected ErrNonZeroPushAmount error, got \"%v\"",
err.Error()) err.Error())
} }

@ -93,7 +93,7 @@ func (d *DecayedLog) Start() error {
kvdb.BoltBackendName, d.dbPath, true, kvdb.BoltBackendName, d.dbPath, true,
) )
if err != nil { if err != nil {
return fmt.Errorf("Could not open boltdb: %v", err) return fmt.Errorf("could not open boltdb: %v", err)
} }
// Initialize the primary buckets used by the decayed log. // Initialize the primary buckets used by the decayed log.
@ -105,7 +105,7 @@ func (d *DecayedLog) Start() error {
if d.notifier != nil { if d.notifier != nil {
epochClient, err := d.notifier.RegisterBlockEpochNtfn(nil) epochClient, err := d.notifier.RegisterBlockEpochNtfn(nil)
if err != nil { if err != nil {
return fmt.Errorf("Unable to register for epoch "+ return fmt.Errorf("unable to register for epoch "+
"notifications: %v", err) "notifications: %v", err)
} }

@ -634,7 +634,7 @@ func (l *channelLink) syncChanStates() error {
} }
if err := l.cfg.Peer.SendMessage(true, localChanSyncMsg); err != nil { if err := l.cfg.Peer.SendMessage(true, localChanSyncMsg); err != nil {
return fmt.Errorf("Unable to send chan sync message for "+ return fmt.Errorf("unable to send chan sync message for "+
"ChannelPoint(%v): %v", l.channel.ChannelPoint(), err) "ChannelPoint(%v): %v", l.channel.ChannelPoint(), err)
} }

@ -421,7 +421,7 @@ func (s *Switch) GetPaymentResult(paymentID uint64, paymentHash lntypes.Hash,
deobfuscator, n, paymentID, paymentHash, deobfuscator, n, paymentID, paymentHash,
) )
if err != nil { if err != nil {
e := fmt.Errorf("Unable to extract result: %v", err) e := fmt.Errorf("unable to extract result: %v", err)
log.Error(e) log.Error(e)
resultChan <- &PaymentResult{ resultChan <- &PaymentResult{
Error: e, Error: e,
@ -770,7 +770,7 @@ func (s *Switch) routeAsync(packet *htlcPacket, errChan chan error,
case <-linkQuit: case <-linkQuit:
return ErrLinkShuttingDown return ErrLinkShuttingDown
case <-s.quit: case <-s.quit:
return errors.New("Htlc Switch was stopped") return errors.New("htlc switch was stopped")
} }
} }
@ -962,7 +962,7 @@ func (s *Switch) extractResult(deobfuscator ErrorDecrypter, n *networkResult,
}, nil }, nil
default: default:
return nil, fmt.Errorf("Received unknown response type: %T", return nil, fmt.Errorf("received unknown response type: %T",
htlc) htlc)
} }
} }

@ -49,7 +49,7 @@ func WitnessScriptHash(witnessScript []byte) ([]byte, error) {
// pubkeys. // pubkeys.
func GenMultiSigScript(aPub, bPub []byte) ([]byte, error) { func GenMultiSigScript(aPub, bPub []byte) ([]byte, error) {
if len(aPub) != 33 || len(bPub) != 33 { if len(aPub) != 33 || len(bPub) != 33 {
return nil, fmt.Errorf("Pubkey size error. Compressed pubkeys only") return nil, fmt.Errorf("pubkey size error: compressed pubkeys only")
} }
// Swap to sort pubkeys if needed. Keys are sorted in lexicographical // Swap to sort pubkeys if needed. Keys are sorted in lexicographical

@ -64,7 +64,7 @@ func (m *MockSigner) SignOutputRaw(tx *wire.MsgTx,
hash160 := btcutil.Hash160(pubkey.SerializeCompressed()) hash160 := btcutil.Hash160(pubkey.SerializeCompressed())
privKey := m.findKey(hash160, signDesc.SingleTweak, signDesc.DoubleTweak) privKey := m.findKey(hash160, signDesc.SingleTweak, signDesc.DoubleTweak)
if privKey == nil { if privKey == nil {
return nil, fmt.Errorf("Mock signer does not have key") return nil, fmt.Errorf("mock signer does not have key")
} }
sig, err := txscript.RawTxInWitnessSignature(tx, signDesc.SigHashes, sig, err := txscript.RawTxInWitnessSignature(tx, signDesc.SigHashes,
@ -93,7 +93,7 @@ func (m *MockSigner) ComputeInputScript(tx *wire.MsgTx, signDesc *SignDescriptor
privKey := m.findKey(addresses[0].ScriptAddress(), signDesc.SingleTweak, privKey := m.findKey(addresses[0].ScriptAddress(), signDesc.SingleTweak,
signDesc.DoubleTweak) signDesc.DoubleTweak)
if privKey == nil { if privKey == nil {
return nil, fmt.Errorf("Mock signer does not have key for "+ return nil, fmt.Errorf("mock signer does not have key for "+
"address %v", addresses[0]) "address %v", addresses[0])
} }
@ -111,7 +111,7 @@ func (m *MockSigner) ComputeInputScript(tx *wire.MsgTx, signDesc *SignDescriptor
privKey := m.findKey(addresses[0].ScriptAddress(), signDesc.SingleTweak, privKey := m.findKey(addresses[0].ScriptAddress(), signDesc.SingleTweak,
signDesc.DoubleTweak) signDesc.DoubleTweak)
if privKey == nil { if privKey == nil {
return nil, fmt.Errorf("Mock signer does not have key for "+ return nil, fmt.Errorf("mock signer does not have key for "+
"address %v", addresses[0]) "address %v", addresses[0])
} }
@ -125,7 +125,7 @@ func (m *MockSigner) ComputeInputScript(tx *wire.MsgTx, signDesc *SignDescriptor
return &Script{Witness: witnessScript}, nil return &Script{Witness: witnessScript}, nil
default: default:
return nil, fmt.Errorf("Unexpected script type: %v", scriptType) return nil, fmt.Errorf("unexpected script type: %v", scriptType)
} }
} }

54
lnd.go

@ -209,7 +209,7 @@ func Main(lisCfg ListenerCfg) error {
if cfg.CPUProfile != "" { if cfg.CPUProfile != "" {
f, err := os.Create(cfg.CPUProfile) f, err := os.Create(cfg.CPUProfile)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to create CPU profile: %v", err := fmt.Errorf("unable to create CPU profile: %v",
err) err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -237,7 +237,7 @@ func Main(lisCfg ListenerCfg) error {
channeldb.OptionSetSyncFreelist(cfg.SyncFreelist), channeldb.OptionSetSyncFreelist(cfg.SyncFreelist),
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to open channeldb: %v", err) err := fmt.Errorf("unable to open channeldb: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -256,7 +256,7 @@ func Main(lisCfg ListenerCfg) error {
cfg.TLSExtraDomains, cfg.RPCListeners, cfg.TLSExtraDomains, cfg.RPCListeners,
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to load TLS credentials: %v", err) err := fmt.Errorf("unable to load TLS credentials: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -289,7 +289,7 @@ func Main(lisCfg ListenerCfg) error {
mainChain.ChainDir, mainChain.ChainDir,
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to initialize neutrino "+ err := fmt.Errorf("unable to initialize neutrino "+
"backend: %v", err) "backend: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -364,7 +364,7 @@ func Main(lisCfg ListenerCfg) error {
restProxyDest, tlsCfg, walletUnlockerListeners, restProxyDest, tlsCfg, walletUnlockerListeners,
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to set up wallet password "+ err := fmt.Errorf("unable to set up wallet password "+
"listeners: %v", err) "listeners: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -388,7 +388,7 @@ func Main(lisCfg ListenerCfg) error {
networkDir, macaroons.IPLockChecker, networkDir, macaroons.IPLockChecker,
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to set up macaroon "+ err := fmt.Errorf("unable to set up macaroon "+
"authentication: %v", err) "authentication: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -398,7 +398,7 @@ func Main(lisCfg ListenerCfg) error {
// Try to unlock the macaroon store with the private password. // Try to unlock the macaroon store with the private password.
err = macaroonService.CreateUnlock(&privateWalletPw) err = macaroonService.CreateUnlock(&privateWalletPw)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to unlock macaroons: %v", err) err := fmt.Errorf("unable to unlock macaroons: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -412,7 +412,7 @@ func Main(lisCfg ListenerCfg) error {
cfg.ReadMacPath, cfg.InvoiceMacPath, cfg.ReadMacPath, cfg.InvoiceMacPath,
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to create macaroons "+ err := fmt.Errorf("unable to create macaroons "+
"%v", err) "%v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -429,7 +429,7 @@ func Main(lisCfg ListenerCfg) error {
walletInitParams.Wallet, neutrinoCS, walletInitParams.Wallet, neutrinoCS,
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to create chain control: %v", err) err := fmt.Errorf("unable to create chain control: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -448,7 +448,7 @@ func Main(lisCfg ListenerCfg) error {
}, },
}) })
if err != nil { if err != nil {
err := fmt.Errorf("Unable to derive node private key: %v", err) err := fmt.Errorf("unable to derive node private key: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -467,7 +467,7 @@ func Main(lisCfg ListenerCfg) error {
var err error var err error
towerClientDB, err = wtdb.OpenClientDB(graphDir) towerClientDB, err = wtdb.OpenClientDB(graphDir)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to open watchtower client "+ err := fmt.Errorf("unable to open watchtower client "+
"database: %v", err) "database: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -508,7 +508,7 @@ func Main(lisCfg ListenerCfg) error {
towerDB, err := wtdb.OpenTowerDB(towerDBDir) towerDB, err := wtdb.OpenTowerDB(towerDBDir)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to open watchtower "+ err := fmt.Errorf("unable to open watchtower "+
"database: %v", err) "database: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -524,7 +524,7 @@ func Main(lisCfg ListenerCfg) error {
}, },
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to derive watchtower "+ err := fmt.Errorf("unable to derive watchtower "+
"private key: %v", err) "private key: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -561,7 +561,7 @@ func Main(lisCfg ListenerCfg) error {
wtConfig, err := cfg.Watchtower.Apply(wtCfg, lncfg.NormalizeAddresses) wtConfig, err := cfg.Watchtower.Apply(wtCfg, lncfg.NormalizeAddresses)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to configure watchtower: %v", err := fmt.Errorf("unable to configure watchtower: %v",
err) err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -569,7 +569,7 @@ func Main(lisCfg ListenerCfg) error {
tower, err = watchtower.New(wtConfig) tower, err = watchtower.New(wtConfig)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to create watchtower: %v", err) err := fmt.Errorf("unable to create watchtower: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -586,7 +586,7 @@ func Main(lisCfg ListenerCfg) error {
torController, torController,
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to create server: %v", err) err := fmt.Errorf("unable to create server: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -596,19 +596,19 @@ func Main(lisCfg ListenerCfg) error {
// it at will. // it at will.
atplCfg, err := initAutoPilot(server, cfg.Autopilot, mainChain) atplCfg, err := initAutoPilot(server, cfg.Autopilot, mainChain)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to initialize autopilot: %v", err) err := fmt.Errorf("unable to initialize autopilot: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
atplManager, err := autopilot.NewManager(atplCfg) atplManager, err := autopilot.NewManager(atplCfg)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to create autopilot manager: %v", err) err := fmt.Errorf("unable to create autopilot manager: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
if err := atplManager.Start(); err != nil { if err := atplManager.Start(); err != nil {
err := fmt.Errorf("Unable to start autopilot manager: %v", err) err := fmt.Errorf("unable to start autopilot manager: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -636,12 +636,12 @@ func Main(lisCfg ListenerCfg) error {
tower, tlsCfg, rpcListeners, chainedAcceptor, tower, tlsCfg, rpcListeners, chainedAcceptor,
) )
if err != nil { if err != nil {
err := fmt.Errorf("Unable to create RPC server: %v", err) err := fmt.Errorf("unable to create RPC server: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
if err := rpcServer.Start(); err != nil { if err := rpcServer.Start(); err != nil {
err := fmt.Errorf("Unable to start RPC server: %v", err) err := fmt.Errorf("unable to start RPC server: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -656,7 +656,7 @@ func Main(lisCfg ListenerCfg) error {
_, bestHeight, err := activeChainControl.chainIO.GetBestBlock() _, bestHeight, err := activeChainControl.chainIO.GetBestBlock()
if err != nil { if err != nil {
err := fmt.Errorf("Unable to determine chain tip: %v", err := fmt.Errorf("unable to determine chain tip: %v",
err) err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -672,7 +672,7 @@ func Main(lisCfg ListenerCfg) error {
synced, _, err := activeChainControl.wallet.IsSynced() synced, _, err := activeChainControl.wallet.IsSynced()
if err != nil { if err != nil {
err := fmt.Errorf("Unable to determine if "+ err := fmt.Errorf("unable to determine if "+
"wallet is synced: %v", err) "wallet is synced: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -687,7 +687,7 @@ func Main(lisCfg ListenerCfg) error {
_, bestHeight, err = activeChainControl.chainIO.GetBestBlock() _, bestHeight, err = activeChainControl.chainIO.GetBestBlock()
if err != nil { if err != nil {
err := fmt.Errorf("Unable to determine chain tip: %v", err := fmt.Errorf("unable to determine chain tip: %v",
err) err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -700,7 +700,7 @@ func Main(lisCfg ListenerCfg) error {
// With all the relevant chains initialized, we can finally start the // With all the relevant chains initialized, we can finally start the
// server itself. // server itself.
if err := server.Start(); err != nil { if err := server.Start(); err != nil {
err := fmt.Errorf("Unable to start server: %v", err) err := fmt.Errorf("unable to start server: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }
@ -711,7 +711,7 @@ func Main(lisCfg ListenerCfg) error {
// stopped together with the autopilot service. // stopped together with the autopilot service.
if cfg.Autopilot.Active { if cfg.Autopilot.Active {
if err := atplManager.StartAgent(); err != nil { if err := atplManager.StartAgent(); err != nil {
err := fmt.Errorf("Unable to start autopilot agent: %v", err := fmt.Errorf("unable to start autopilot agent: %v",
err) err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
@ -720,7 +720,7 @@ func Main(lisCfg ListenerCfg) error {
if cfg.Watchtower.Active { if cfg.Watchtower.Active {
if err := tower.Start(); err != nil { if err := tower.Start(); err != nil {
err := fmt.Errorf("Unable to start watchtower: %v", err) err := fmt.Errorf("unable to start watchtower: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
return err return err
} }

@ -685,7 +685,7 @@ func (n *NetworkHarness) SaveProfilesPages() {
for _, node := range n.activeNodes { for _, node := range n.activeNodes {
if err := saveProfilesPage(node); err != nil { if err := saveProfilesPage(node); err != nil {
fmt.Println(err) fmt.Printf("Error: %v\n", err)
} }
} }
} }
@ -699,16 +699,16 @@ func saveProfilesPage(node *HarnessNode) error {
), ),
) )
if err != nil { if err != nil {
return fmt.Errorf("Failed to get profile page "+ return fmt.Errorf("failed to get profile page "+
"(node_id=%d, name=%s): %v\n", "(node_id=%d, name=%s): %v",
node.NodeID, node.Cfg.Name, err) node.NodeID, node.Cfg.Name, err)
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("Failed to read profile page "+ return fmt.Errorf("failed to read profile page "+
"(node_id=%d, name=%s): %v\n", "(node_id=%d, name=%s): %v",
node.NodeID, node.Cfg.Name, err) node.NodeID, node.Cfg.Name, err)
} }
@ -719,16 +719,16 @@ func saveProfilesPage(node *HarnessNode) error {
logFile, err := os.Create(fileName) logFile, err := os.Create(fileName)
if err != nil { if err != nil {
return fmt.Errorf("Failed to create file for profile page "+ return fmt.Errorf("failed to create file for profile page "+
"(node_id=%d, name=%s): %v\n", "(node_id=%d, name=%s): %v",
node.NodeID, node.Cfg.Name, err) node.NodeID, node.Cfg.Name, err)
} }
defer logFile.Close() defer logFile.Close()
_, err = logFile.Write(body) _, err = logFile.Write(body)
if err != nil { if err != nil {
return fmt.Errorf("Failed to save profile page "+ return fmt.Errorf("failed to save profile page "+
"(node_id=%d, name=%s): %v\n", "(node_id=%d, name=%s): %v",
node.NodeID, node.Cfg.Name, err) node.NodeID, node.Cfg.Name, err)
} }
return nil return nil
@ -872,10 +872,10 @@ func (n *NetworkHarness) OpenChannel(ctx context.Context,
// prevents any funding workflows from being kicked off if the chain // prevents any funding workflows from being kicked off if the chain
// isn't yet synced. // isn't yet synced.
if err := srcNode.WaitForBlockchainSync(ctx); err != nil { if err := srcNode.WaitForBlockchainSync(ctx); err != nil {
return nil, fmt.Errorf("Unable to sync srcNode chain: %v", err) return nil, fmt.Errorf("enable to sync srcNode chain: %v", err)
} }
if err := destNode.WaitForBlockchainSync(ctx); err != nil { if err := destNode.WaitForBlockchainSync(ctx); err != nil {
return nil, fmt.Errorf("Unable to sync destNode chain: %v", err) return nil, fmt.Errorf("unable to sync destNode chain: %v", err)
} }
minConfs := int32(1) minConfs := int32(1)
@ -941,10 +941,10 @@ func (n *NetworkHarness) OpenPendingChannel(ctx context.Context,
// Wait until srcNode and destNode have blockchain synced // Wait until srcNode and destNode have blockchain synced
if err := srcNode.WaitForBlockchainSync(ctx); err != nil { if err := srcNode.WaitForBlockchainSync(ctx); err != nil {
return nil, fmt.Errorf("Unable to sync srcNode chain: %v", err) return nil, fmt.Errorf("unable to sync srcNode chain: %v", err)
} }
if err := destNode.WaitForBlockchainSync(ctx); err != nil { if err := destNode.WaitForBlockchainSync(ctx); err != nil {
return nil, fmt.Errorf("Unable to sync destNode chain: %v", err) return nil, fmt.Errorf("unable to sync destNode chain: %v", err)
} }
openReq := &lnrpc.OpenChannelRequest{ openReq := &lnrpc.OpenChannelRequest{

@ -1122,7 +1122,7 @@ func (hn *HarnessNode) WaitForBlockchainSync(ctx context.Context) error {
case err := <-errChan: case err := <-errChan:
return err return err
case <-ctx.Done(): case <-ctx.Done():
return fmt.Errorf("Timeout while waiting for blockchain sync") return fmt.Errorf("timeout while waiting for blockchain sync")
} }
} }

@ -3920,7 +3920,7 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment,
// Make sure there are more signatures left. // Make sure there are more signatures left.
if i >= len(htlcSigs) { if i >= len(htlcSigs) {
return nil, fmt.Errorf("not enough HTLC " + return nil, fmt.Errorf("not enough HTLC " +
"signatures.") "signatures")
} }
// With the sighash generated, we'll also store the // With the sighash generated, we'll also store the
@ -3974,7 +3974,7 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment,
// Make sure there are more signatures left. // Make sure there are more signatures left.
if i >= len(htlcSigs) { if i >= len(htlcSigs) {
return nil, fmt.Errorf("not enough HTLC " + return nil, fmt.Errorf("not enough HTLC " +
"signatures.") "signatures")
} }
// With the sighash generated, we'll also store the // With the sighash generated, we'll also store the

@ -34,7 +34,7 @@ func ErrZeroCapacity() ReservationError {
func ErrChainMismatch(knownChain, func ErrChainMismatch(knownChain,
unknownChain *chainhash.Hash) ReservationError { unknownChain *chainhash.Hash) ReservationError {
return ReservationError{ return ReservationError{
fmt.Errorf("Unknown chain=%v. Supported chain=%v", fmt.Errorf("unknown chain=%v, supported chain=%v",
unknownChain, knownChain), unknownChain, knownChain),
} }
} }
@ -44,7 +44,7 @@ func ErrChainMismatch(knownChain,
func ErrFunderBalanceDust(commitFee, funderBalance, func ErrFunderBalanceDust(commitFee, funderBalance,
minBalance int64) ReservationError { minBalance int64) ReservationError {
return ReservationError{ return ReservationError{
fmt.Errorf("Funder balance too small (%v) with fee=%v sat, "+ fmt.Errorf("funder balance too small (%v) with fee=%v sat, "+
"minimum=%v sat required", funderBalance, "minimum=%v sat required", funderBalance,
commitFee, minBalance), commitFee, minBalance),
} }
@ -73,7 +73,7 @@ func ErrChanReserveTooSmall(reserve, dustLimit btcutil.Amount) ReservationError
func ErrChanReserveTooLarge(reserve, func ErrChanReserveTooLarge(reserve,
maxReserve btcutil.Amount) ReservationError { maxReserve btcutil.Amount) ReservationError {
return ReservationError{ return ReservationError{
fmt.Errorf("Channel reserve is too large: %v sat, max "+ fmt.Errorf("channel reserve is too large: %v sat, max "+
"is %v sat", int64(reserve), int64(maxReserve)), "is %v sat", int64(reserve), int64(maxReserve)),
} }
} }
@ -82,7 +82,7 @@ func ErrChanReserveTooLarge(reserve,
// FundingOpen request for a channel with non-zero push amount while // FundingOpen request for a channel with non-zero push amount while
// they have 'rejectpush' enabled. // they have 'rejectpush' enabled.
func ErrNonZeroPushAmount() ReservationError { func ErrNonZeroPushAmount() ReservationError {
return ReservationError{errors.New("Non-zero push amounts are disabled")} return ReservationError{errors.New("non-zero push amounts are disabled")}
} }
// ErrMinHtlcTooLarge returns an error indicating that the MinHTLC value the // ErrMinHtlcTooLarge returns an error indicating that the MinHTLC value the
@ -90,7 +90,7 @@ func ErrNonZeroPushAmount() ReservationError {
func ErrMinHtlcTooLarge(minHtlc, func ErrMinHtlcTooLarge(minHtlc,
maxMinHtlc lnwire.MilliSatoshi) ReservationError { maxMinHtlc lnwire.MilliSatoshi) ReservationError {
return ReservationError{ return ReservationError{
fmt.Errorf("Minimum HTLC value is too large: %v, max is %v", fmt.Errorf("minimum HTLC value is too large: %v, max is %v",
minHtlc, maxMinHtlc), minHtlc, maxMinHtlc),
} }
} }

@ -43,7 +43,7 @@ var (
// ErrDoubleSpend is returned from PublishTransaction in case the // ErrDoubleSpend is returned from PublishTransaction in case the
// tx being published is spending an output spent by a conflicting // tx being published is spending an output spent by a conflicting
// transaction. // transaction.
ErrDoubleSpend = errors.New("Transaction rejected: output already spent") ErrDoubleSpend = errors.New("transaction rejected: output already spent")
// ErrNotMine is an error denoting that a WalletController instance is // ErrNotMine is an error denoting that a WalletController instance is
// unable to spend a specified output. // unable to spend a specified output.

@ -753,7 +753,7 @@ func testReservationInitiatorBalanceBelowDustCancel(miner *rpctest.Harness,
t.Fatalf("initialization should have failed due to " + t.Fatalf("initialization should have failed due to " +
"insufficient local amount") "insufficient local amount")
case !strings.Contains(err.Error(), "Funder balance too small"): case !strings.Contains(err.Error(), "funder balance too small"):
t.Fatalf("incorrect error: %v", err) t.Fatalf("incorrect error: %v", err)
} }
} }

@ -419,7 +419,7 @@ func WriteElement(w io.Writer, element interface{}) error {
return err return err
} }
default: default:
return fmt.Errorf("Unknown type in WriteElement: %T", e) return fmt.Errorf("unknown type in WriteElement: %T", e)
} }
return nil return nil
@ -818,14 +818,14 @@ func ReadElement(r io.Reader, element interface{}) error {
var addrBytes [deliveryAddressMaxSize]byte var addrBytes [deliveryAddressMaxSize]byte
if length > deliveryAddressMaxSize { if length > deliveryAddressMaxSize {
return fmt.Errorf("Cannot read %d bytes into addrBytes", length) return fmt.Errorf("cannot read %d bytes into addrBytes", length)
} }
if _, err = io.ReadFull(r, addrBytes[:length]); err != nil { if _, err = io.ReadFull(r, addrBytes[:length]); err != nil {
return err return err
} }
*e = addrBytes[:length] *e = addrBytes[:length]
default: default:
return fmt.Errorf("Unknown type in ReadElement: %T", e) return fmt.Errorf("unknown type in ReadElement: %T", e)
} }
return nil return nil

@ -1115,7 +1115,7 @@ func (p *peer) readHandler() {
// We'll stop the timer after a new messages is received, and also // We'll stop the timer after a new messages is received, and also
// reset it after we process the next message. // reset it after we process the next message.
idleTimer := time.AfterFunc(idleTimeout, func() { idleTimer := time.AfterFunc(idleTimeout, func() {
err := fmt.Errorf("Peer %s no answer for %s -- disconnecting", err := fmt.Errorf("peer %s no answer for %s -- disconnecting",
p, idleTimeout) p, idleTimeout)
p.Disconnect(err) p.Disconnect(err)
}) })
@ -1657,7 +1657,7 @@ func (p *peer) writeHandler() {
// We'll stop the timer after a new messages is sent, and also reset it // We'll stop the timer after a new messages is sent, and also reset it
// after we process the next message. // after we process the next message.
idleTimer := time.AfterFunc(idleTimeout, func() { idleTimer := time.AfterFunc(idleTimeout, func() {
err := fmt.Errorf("Peer %s no write for %s -- disconnecting", err := fmt.Errorf("peer %s no write for %s -- disconnecting",
p, idleTimeout) p, idleTimeout)
p.Disconnect(err) p.Disconnect(err)
}) })
@ -2724,7 +2724,7 @@ func (p *peer) resendChanSyncMsg(cid lnwire.ChannelID) error {
"peer %v", cid, p) "peer %v", cid, p)
if err := p.SendMessage(true, c.LastChanSyncMsg); err != nil { if err := p.SendMessage(true, c.LastChanSyncMsg); err != nil {
return fmt.Errorf("Failed resending channel sync "+ return fmt.Errorf("failed resending channel sync "+
"message to peer %v: %v", p, err) "message to peer %v: %v", p, err)
} }

@ -39,7 +39,7 @@ func validateAtplCfg(cfg *autoPilotConfig) ([]*autopilot.WeightedHeuristic,
a, ok := autopilot.AvailableHeuristics[name] a, ok := autopilot.AvailableHeuristics[name]
if !ok { if !ok {
// No heuristic matching this config option was found. // No heuristic matching this config option was found.
return nil, fmt.Errorf("Heuristic %v not available. %v", return nil, fmt.Errorf("heuristic %v not available. %v",
name, availStr) name, availStr)
} }
@ -58,11 +58,11 @@ func validateAtplCfg(cfg *autoPilotConfig) ([]*autopilot.WeightedHeuristic,
// Check found heuristics. We must have at least one to operate. // Check found heuristics. We must have at least one to operate.
if len(heuristics) == 0 { if len(heuristics) == 0 {
return nil, fmt.Errorf("No active heuristics. %v", availStr) return nil, fmt.Errorf("no active heuristics: %v", availStr)
} }
if sum != 1.0 { if sum != 1.0 {
return nil, fmt.Errorf("Heuristic weights must sum to 1.0") return nil, fmt.Errorf("heuristic weights must sum to 1.0")
} }
return heuristics, nil return heuristics, nil
} }

@ -386,7 +386,7 @@ func addToTopologyChange(graph *channeldb.ChannelGraph, update *TopologyChange,
return nil return nil
default: default:
return fmt.Errorf("Unable to add to topology change, "+ return fmt.Errorf("unable to add to topology change, "+
"unknown message type %T", msg) "unknown message type %T", msg)
} }
} }

@ -2197,7 +2197,7 @@ func (r *ChannelRouter) ForAllOutgoingChannels(cb func(*channeldb.ChannelEdgeInf
e, _ *channeldb.ChannelEdgePolicy) error { e, _ *channeldb.ChannelEdgePolicy) error {
if e == nil { if e == nil {
return fmt.Errorf("Channel from self node has no policy") return fmt.Errorf("channel from self node has no policy")
} }
return cb(c, e) return cb(c, e)

@ -547,7 +547,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB,
pmp, err := nat.DiscoverPMP(discoveryTimeout) pmp, err := nat.DiscoverPMP(discoveryTimeout)
if err != nil { if err != nil {
err := fmt.Errorf("Unable to discover a "+ err := fmt.Errorf("unable to discover a "+
"NAT-PMP enabled device on the local "+ "NAT-PMP enabled device on the local "+
"network: %v", err) "network: %v", err)
srvrLog.Error(err) srvrLog.Error(err)
@ -1995,7 +1995,7 @@ func (s *server) createNewHiddenService() error {
}, },
) )
if err != nil { if err != nil {
return fmt.Errorf("Unable to generate new node "+ return fmt.Errorf("unable to generate new node "+
"announcement: %v", err) "announcement: %v", err)
} }