multi: formatting and comment fixes

This commit is contained in:
Oliver Gugger committed 2022-02-10 11:02:02 +01:00
1 parent ffee7d1bcf
commit 895a2e497b
160 files changed
+159 -260

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ var (
ErrConfirmHintNotFound = errors.New("confirm hint not found")
)
// CacheConfig contains the HeightHintCache configuration
// CacheConfig contains the HeightHintCache configuration.
type CacheConfig struct {
// QueryDisable prevents reliance on the Height Hint Cache. This is
// necessary to recover from an edge case when the height recorded in
+2 -2
View File
@@ -901,7 +901,7 @@ var (
// the network seed.
//
// TODO(roasbeef): extend and collapse these and chainparams.go into
// struct like chaincfg.Params
// struct like chaincfg.Params.
ChainDNSSeeds = map[chainhash.Hash][][2]string{
BitcoinMainnetGenesis: {
{
@@ -935,7 +935,7 @@ var (
}
)
// ChainRegistry keeps track of the current chains
// ChainRegistry keeps track of the current chains.
type ChainRegistry struct {
sync.RWMutex
-1
View File
@@ -402,7 +402,6 @@ func TestGetOnlinePeriod(t *testing.T) {
require.Equal(t, test.expectedOnline, online)
})
}
}
-1
View File
@@ -155,7 +155,6 @@ func TestMonitorChannelEvents(t *testing.T) {
testEventStore(t, gen, peer1, 1)
})
}
// testEventStore creates a new test contexts, generates a set of events for it
+1 -1
View File
@@ -49,7 +49,7 @@ var (
// outpointBucket stores all of our channel outpoints and a tlv
// stream containing channel data.
//
// outpoint -> tlv stream
// outpoint -> tlv stream.
//
outpointBucket = []byte("outpoint-bucket")
+1
View File
@@ -658,6 +658,7 @@ func TestChannelStateTransition(t *testing.T) {
if !reflect.DeepEqual(
dbUnsignedAckedUpdates[0], unsignedAckedUpdates[0],
) {
t.Fatalf("unexpected update: expected %v, got %v",
spew.Sdump(unsignedAckedUpdates[0]),
spew.Sdump(dbUnsignedAckedUpdates))
-1
View File
@@ -759,5 +759,4 @@ func TestFetchHistoricalChannel(t *testing.T) {
if err != ErrChannelNotFound {
t.Fatalf("expected chan not found, got: %v", err)
}
}
-1
View File
@@ -150,7 +150,6 @@ func fetchDuplicatePayment(bucket kvdb.RBucket) (*MPPayment, error) {
creationInfo, err := deserializeDuplicatePaymentCreationInfo(r)
if err != nil {
return nil, err
}
// Get failure reason if available.
-3
View File
@@ -520,7 +520,6 @@ func (c *ChannelGraph) FetchNodeFeatures(
// Fallback that uses the database.
targetNode, err := c.FetchLightningNode(node)
switch err {
// If the node exists and has features, return them directly.
case nil:
return targetNode.Features, nil
@@ -592,7 +591,6 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
channels[e.ChannelID] = directedChannel
return nil
})
if err != nil {
return err
@@ -2429,7 +2427,6 @@ func makeZombiePubkeys(info *ChannelEdgeInfo,
e1, e2 *ChannelEdgePolicy) ([33]byte, [33]byte) {
switch {
// If we don't have either edge policy, we'll return both pubkeys so
// that the channel can be resurrected by either party.
case e1 == nil && e2 == nil:
-1
View File
@@ -467,7 +467,6 @@ func (c *GraphCache) ForEachChannel(node route.Vertex,
if err := cb(channel); err != nil {
return err
}
}
return nil
+1 -1
View File
@@ -1279,6 +1279,7 @@ func TestGraphCacheTraversal(t *testing.T) {
if !bytes.Equal(
inPolicyNodeKey[:], node.PubKeyBytes[:],
) {
return fmt.Errorf("wrong outgoing edge")
}
@@ -3784,7 +3785,6 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
var numChans int
err = graph.ForEachNodeChannel(nil, node1.PubKeyBytes,
func(channel *DirectedChannel) error {
numChans++
return nil
})
+1 -3
View File
@@ -1010,7 +1010,6 @@ func TestScanInvoices(t *testing.T) {
invoices = make(map[lntypes.Hash]*Invoice)
callCount = 0
resetCount++
}
scanFunc := func(paymentHash lntypes.Hash, invoice *Invoice) error {
@@ -1661,7 +1660,6 @@ func TestHTLCSet(t *testing.T) {
ampData = &InvoiceHtlcAMPData{
Record: *record.NewAMP([32]byte{0}, *h.setID, 0),
}
}
// Add the HTLC to the invoice's set of HTLCs.
@@ -2045,7 +2043,7 @@ func TestUnexpectedInvoicePreimage(t *testing.T) {
getUpdateInvoice(invoice.Terms.Value),
)
//Assert that we get ErrUnexpectedInvoicePreimage.
// Assert that we get ErrUnexpectedInvoicePreimage.
require.Error(t, ErrUnexpectedInvoicePreimage, err)
}
+1 -9
View File
@@ -422,7 +422,7 @@ func (c ContractState) String() string {
return "Unknown"
}
// IsFinal returns a boolean indicating whether an invoice state is final
// IsFinal returns a boolean indicating whether an invoice state is final.
func (c ContractState) IsFinal() bool {
return c == ContractSettled || c == ContractCanceled
}
@@ -1156,7 +1156,6 @@ func fetchInvoiceNumByRef(invoiceIndex, payAddrIndex, setIDIndex kvdb.RBucket,
invoiceNumByHash := getInvoiceNumByHash()
invoiceNumByAddr := getInvoiceNumByAddr()
switch {
// If payment address and payment hash both reference an existing
// invoice, ensure they reference the _same_ invoice.
case invoiceNumByAddr != nil && invoiceNumByHash != nil:
@@ -2814,7 +2813,6 @@ func (d *DB) updateInvoice(hash *lntypes.Hash, refSetID *SetID, invoices,
if setID != nil && update.State != nil {
preimage, ok := update.State.HTLCPreimages[key]
switch {
// If we don't already have a preimage for this HTLC, we
// can set it now.
case ok && htlc.AMP.Preimage == nil:
@@ -2890,7 +2888,6 @@ func (d *DB) updateInvoice(hash *lntypes.Hash, refSetID *SetID, invoices,
if !invoiceIsAMP {
invoice.AmtPaid = amtPaid
} else {
invoice.AmtPaid += amtPaid
}
@@ -2941,7 +2938,6 @@ func updateInvoiceState(invoice *Invoice, hash *lntypes.Hash,
}
switch invoice.State {
// Once a contract is accepted, we can only transition to settled or
// canceled. Forbid transitioning back into this state. Otherwise this
// state is identical to ContractOpen, so we fallthrough to apply the
@@ -2979,7 +2975,6 @@ func updateInvoiceState(invoice *Invoice, hash *lntypes.Hash,
}
switch {
// If an invoice-level preimage was supplied, but the InvoiceRef
// doesn't specify a hash (e.g. AMP invoices) we fail.
case update.Preimage != nil && hash == nil:
@@ -3063,7 +3058,6 @@ func updateHtlc(resolveTime time.Time, htlc *InvoiceHTLC,
// the invoice level. For AMP HTLCs, verify that the
// per-HTLC preimage-hash pair is valid.
switch {
// Non-AMP HTLCs can be settle immediately since we
// already know the preimage is valid due to checks at
// the invoice level.
@@ -3112,7 +3106,6 @@ func updateHtlc(resolveTime time.Time, htlc *InvoiceHTLC,
}
switch invState {
case ContractCanceled:
if htlc.State == HtlcStateAccepted {
htlc.State = HtlcStateCanceled
@@ -3369,7 +3362,6 @@ func (d *DB) DeleteInvoice(invoicesToDelete []InvoiceDeleteRef) error {
if err != nil {
return err
}
}
// In addition to deleting the main invoice state, if
@@ -257,7 +257,8 @@ func readChanConfig(b io.Reader, c *common.ChannelConfig) error { // nolint: dup
)
}
func DeserializeCloseChannelSummary(r io.Reader) (*common.ChannelCloseSummary, error) { // nolint: dupl
func DeserializeCloseChannelSummary(
r io.Reader) (*common.ChannelCloseSummary, error) { // nolint: dupl
c := &common.ChannelCloseSummary{}
+3 -1
View File
@@ -175,7 +175,6 @@ var (
// migrate three areas: open channel commit diffs, open channel unacked updates,
// and network results in the switch.
func TestMigrateDatabaseWireMessages(t *testing.T) {
var pub [33]byte
copy(pub[:], key[:])
@@ -344,6 +343,7 @@ func TestMigrateDatabaseWireMessages(t *testing.T) {
if !reflect.DeepEqual(
newUpdates, testCommitDiff.LogUpdates,
) {
return fmt.Errorf("updates mismatch: expected "+
"%v, got %v",
spew.Sdump(testCommitDiff.LogUpdates),
@@ -365,6 +365,7 @@ func TestMigrateDatabaseWireMessages(t *testing.T) {
if !reflect.DeepEqual(
newUpdates, testCommitDiff.LogUpdates,
) {
return fmt.Errorf("updates mismatch: expected "+
"%v, got %v",
spew.Sdump(testCommitDiff.LogUpdates),
@@ -402,6 +403,7 @@ func TestMigrateDatabaseWireMessages(t *testing.T) {
if !reflect.DeepEqual(
newChanCloseSummary, testChanCloseSummary,
) {
return fmt.Errorf("summary mismatch: expected "+
"%v, got %v",
spew.Sdump(testChanCloseSummary),
-1
View File
@@ -140,7 +140,6 @@ func migrateHtlcsBucket(htlcs kvdb.RwBucket) error {
if err := htlcs.Put(newKey, settleInfo); err != nil {
return err
}
}
failInfo := attempt.Get(oldFailInfoKey)
-2
View File
@@ -72,7 +72,6 @@ func restoreDB(bucket kvdb.RwBucket, data map[string]interface{}) error {
key := []byte(k)
switch value := v.(type) {
// Key contains value.
case string:
err := bucket.Put(key, []byte(value))
@@ -114,7 +113,6 @@ func verifyDB(bucket kvdb.RBucket, data map[string]interface{}) error {
key := []byte(k)
switch value := v.(type) {
// Key contains value.
case string:
expectedValue := []byte(value)
-1
View File
@@ -10,7 +10,6 @@ import (
// TestDefaultOptions tests the default options are created as intended.
func TestDefaultOptions(t *testing.T) {
opts := channeldb.DefaultOptions()
require.True(t, opts.NoFreelistSync)
-1
View File
@@ -69,7 +69,6 @@ func (p paginator) cursorStart() ([]byte, []byte) {
// handle a few offset cases.
if p.reversed {
switch {
// This indicates the default case, where no offset was
// specified. In that case we just start from the last
// entry.
-1
View File
@@ -324,7 +324,6 @@ func (p *PaymentControl) RegisterAttempt(paymentHash lntypes.Hash,
hMpp := h.Route.FinalHop().MPP
switch {
// We tried to register a non-MPP attempt for a MPP
// payment.
case mpp == nil && hMpp != nil:
-1
View File
@@ -1254,7 +1254,6 @@ func createTestPayments(t *testing.T, p *PaymentControl, payments []*payment) {
require.NoError(t, err, "unable to send htlc message")
switch payments[i].status {
// Fail the attempt and the payment overall.
case StatusFailed:
htlcFailure := HTLCFailUnreadable
-2
View File
@@ -357,7 +357,6 @@ func fetchPayment(bucket kvdb.RBucket) (*MPPayment, error) {
var paymentStatus PaymentStatus
switch {
// If any of the the HTLCs did succeed and there are no HTLCs in
// flight, the payment succeeded.
case !inflight && settled:
@@ -1093,7 +1092,6 @@ func deserializeHTLCAttemptInfo(r io.Reader) (*HTLCAttemptInfo, error) {
_, err = io.ReadFull(r, hash[:])
switch {
// Older payment attempts wouldn't have the hash set, in which case we
// can just return.
case err == io.EOF, err == io.ErrUnexpectedEOF:
+1
View File
@@ -487,6 +487,7 @@ func TestQueryPayments(t *testing.T) {
}
if tt.firstIndex != querySlice.FirstIndexOffset ||
tt.lastIndex != querySlice.LastIndexOffset {
t.Errorf("First or last index does not match "+
"expected index. Want (%d, %d), got (%d, %d).",
tt.firstIndex, tt.lastIndex,
-1
View File
@@ -133,7 +133,6 @@ func (c *chanDBRestorer) openChannelShell(backup chanbackup.Single) (
var chanType channeldb.ChannelType
switch backup.Version {
case chanbackup.DefaultSingleVersion:
chanType = channeldb.SingleFunderBit
+2 -1
View File
@@ -63,7 +63,7 @@ Signed base64 encoded PSBT or hex encoded raw wire TX (or path to text file): `
channelTypeAnchors = "anchors"
)
// TODO(roasbeef): change default number of confirmations
// TODO(roasbeef): change default number of confirmations.
var openChannelCommand = cli.Command{
Name: "openchannel",
Category: "Channels",
@@ -289,6 +289,7 @@ func openChannel(ctx *cli.Context) error {
_, err := client.ConnectPeer(ctxc, req)
if err != nil &&
!strings.Contains(err.Error(), "already connected") {
return err
}
}
+3 -2
View File
@@ -201,7 +201,6 @@ var sendPaymentCommand = cli.Command{
// default.
func retrieveFeeLimit(ctx *cli.Context, amt int64) (int64, error) {
switch {
case ctx.IsSet("fee_limit") && ctx.IsSet("fee_limit_percent"):
return 0, fmt.Errorf("either fee_limit or fee_limit_percent " +
"can be set, but not both")
@@ -404,6 +403,7 @@ func sendPayment(ctx *cli.Context) error {
func sendPaymentRequest(ctx *cli.Context,
req *routerrpc.SendPaymentRequest) error {
ctxc := getContext()
conn := getClientConn(ctx, false)
@@ -702,6 +702,7 @@ func formatMsat(amt int64) string {
// formatPayment formats the payment state as an ascii table.
func formatPayment(ctxc context.Context, payment *lnrpc.Payment,
aliases *aliasCache) string {
t := table.NewWriter()
// Build table header.
@@ -1521,7 +1522,7 @@ func deletePayments(ctx *cli.Context) error {
return nil
}
// ESC is the ASCII code for escape character
// ESC is the ASCII code for escape character.
const ESC = 27
// clearCode defines a terminal escape code to clear the currently line and move
-1
View File
@@ -149,7 +149,6 @@ func create(ctx *cli.Context) error {
warningLoop:
for {
fmt.Println()
fmt.Printf("WARNING: You are attempting to restore from a " +
"static channel backup (SCB) file.\nThis action will CLOSE " +
-1
View File
@@ -952,7 +952,6 @@ func waitForWalletPassword(cfg *Config,
// for creation or unlocking, as a new wallet db will be created if
// none exists when creating the chain control.
select {
// The wallet is being created for the first time, we'll check to see
// if the user provided any entropy for seed creation. If so, then
// we'll create the wallet early to load the seed.
-1
View File
@@ -125,7 +125,6 @@ func (c *anchorResolver) Resolve() (ContractResolver, error) {
select {
case sweepRes := <-resultChan:
switch sweepRes.Err {
// Anchor was swept successfully.
case nil:
sweepTxID := sweepRes.Tx.TxHash()
+2 -3
View File
@@ -532,7 +532,7 @@ func (b *BreachArbiter) waitForSpendEvent(breachInfo *retributionInfo,
// spends it to the second level, and mutates the breach output into one that
// is able to properly sweep that second level output. We'll use this function
// when we go to sweep a breached commitment transaction, but the cheating
// party has already attempted to take it to the second level
// party has already attempted to take it to the second level.
func convertToSecondLevelRevoke(bo *breachedOutput, breachInfo *retributionInfo,
spendDetails *chainntnfs.SpendDetail) {
@@ -625,7 +625,6 @@ func updateBreachInfo(breachInfo *retributionInfo, spends []spend) (
// count the total and revoked funds swept depending on the
// input type.
switch breachedOutput.witnessType {
// If the output being revoked is the remote commitment
// output or an offered HTLC output, it's amount
// contributes to the value of funds being revoked from
@@ -758,7 +757,6 @@ justiceTxBroadcast:
Loop:
for {
select {
case spends := <-spendChan:
// Update the breach info with the new spends.
@@ -1333,6 +1331,7 @@ func (b *BreachArbiter) createJusticeTx(
// createSweepTx creates a tx that sweeps the passed inputs back to our wallet.
func (b *BreachArbiter) createSweepTx(inputs []input.Input) (*wire.MsgTx,
error) {
if len(inputs) == 0 {
return nil, nil
}
-2
View File
@@ -1949,7 +1949,6 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
maxIndex = uint32(len(forceCloseTx.TxOut)) - 1
)
for i := 0; i < 2; i++ {
var tx *wire.MsgTx
select {
case tx = <-publTx:
@@ -1989,7 +1988,6 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
}
select {
// The published tx should spend the same inputs as our second split.
case tx := <-publTx:
require.Len(t, tx.TxIn, len(splits[1].TxIn))
+1 -1
View File
@@ -181,7 +181,7 @@ const (
// | |
// | |-> StateFullyResolved: contract resolutions empty
// |
// |-> StateFullyResolved: coop/breach(legacy) close trigger
// |-> StateFullyResolved: coop/breach(legacy) close trigger.
// StateDefault is the default state. In this state, no major actions
// need to be executed.
-2
View File
@@ -429,7 +429,6 @@ func (c *ChainArbitrator) getArbChannel(
// This is only to be done once all contracts which were live on the channel
// before hitting the chain have been resolved.
func (c *ChainArbitrator) ResolveContract(chanPoint wire.OutPoint) error {
log.Infof("Marking ChannelPoint(%v) fully resolved", chanPoint)
// First, we'll we'll mark the channel as fully closed from the PoV of
@@ -874,7 +873,6 @@ func (c *ChainArbitrator) rebroadcast(channel *channeldb.OpenChannel,
}
switch {
// This can happen for channels that had their closing tx published
// before we started storing it to disk.
case err == channeldb.ErrNoCloseTx:
-2
View File
@@ -787,7 +787,6 @@ func (c *chainWatcher) handleKnownRemoteState(
)
switch {
// If we had no log entry at this height, this was not a revoked state.
case err == channeldb.ErrLogEntryNotFound:
return false, nil
@@ -869,7 +868,6 @@ func (c *chainWatcher) handleUnknownRemoteState(
"sweep our funds...",
commitPoint.SerializeCompressed(),
c.cfg.chanState.FundingOutpoint)
} else {
log.Infof("ChannelPoint(%v) is tweakless, "+
"moving to sweep directly on chain",
+2 -4
View File
@@ -1548,7 +1548,6 @@ func TestChannelArbitratorForceCloseBreachedChannel(t *testing.T) {
// TestChannelArbitratorCommitFailure tests that the channel arbitrator is able
// to recover from a failed CommitState call at restart.
func TestChannelArbitratorCommitFailure(t *testing.T) {
testCases := []struct {
// closeType is the type of channel close we want ot test.
@@ -2221,6 +2220,7 @@ func TestRemoteCloseInitiator(t *testing.T) {
if !alice.State().HasChanStatus(
channeldb.ChanStatusRemoteCloseInitiator,
) {
t.Fatalf("expected remote close initiator, "+
"got: %v", alice.State().ChanStatus())
}
@@ -2350,7 +2350,6 @@ func TestFindCommitmentDeadline(t *testing.T) {
require.Equal(t, tc.deadline, deadline)
})
}
}
// TestSweepAnchors checks the sweep transactions are created using the
@@ -2473,7 +2472,6 @@ func TestSweepAnchors(t *testing.T) {
t, expectedRemoteDeadline, deadlines[2],
"remote deadline not matched",
)
}
// TestChannelArbitratorAnchors asserts that the commitment tx anchor is swept.
@@ -2702,7 +2700,6 @@ func TestChannelArbitratorAnchors(t *testing.T) {
htlcWithPreimage.RefundTimeout-heightHint,
chanArbCtx.sweeper.deadlines[1],
)
}
// putResolverReportInChannel returns a put report function which will pipe
@@ -2738,6 +2735,7 @@ type mockChannel struct {
func (m *mockChannel) NewAnchorResolutions() (*lnwallet.AnchorResolutions,
error) {
if m.anchorResolutions != nil {
return m.anchorResolutions, nil
}
-1
View File
@@ -262,7 +262,6 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
// commitment this is.
var witnessType input.WitnessType
switch {
// Delayed output to us on our local commitment for a channel lease in
// which we are the initiator.
case isLocalCommitTx && c.hasCLTV():
@@ -347,7 +347,6 @@ func testCommitSweepResolverDelay(t *testing.T, sweepErr error) {
t.Fatalf("unexpected resolver report. want=%v got=%v",
expectedReport, report)
}
}
// TestCommitSweepResolverDelay tests resolution of a direct commitment output
@@ -180,7 +180,6 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
// Take action based on the type of resolution we have
// received.
switch resolution := e.(type) {
// If the htlc resolution was a settle, apply the
// preimage and return a success resolver.
case *invoices.HtlcSettleResolution:
@@ -442,7 +441,6 @@ func (h *htlcIncomingContestResolver) SupplementState(_ *channeldb.OpenChannel)
// decodePayload (re)decodes the hop payload of a received htlc.
func (h *htlcIncomingContestResolver) decodePayload() (*hop.Payload, error) {
onionReader := bytes.NewReader(h.htlc.OnionBlob)
iterator, err := h.OnionProcessor.ReconstructHopIterator(
onionReader, h.htlc.RHash[:],
@@ -140,6 +140,7 @@ func TestHtlcIncomingResolverExitSettle(t *testing.T) {
if !bytes.Equal(
ctx.onionProcessor.offeredOnionBlob, testOnionBlob,
) {
t.Fatal("unexpected onion blob")
}
}
@@ -389,7 +389,6 @@ func TestHtlcSuccessSecondStageResolutionSweeper(t *testing.T) {
SpendingHeight: 10,
}
return nil
},
// incubating=true is used to signal that the
// second-level transaction was confirmed.
@@ -555,7 +554,6 @@ func runFromCheckpoint(t *testing.T, ctx *htlcResolverTestContext,
t.Fatalf("expected checkpoint to be have "+
"incubating=%v, had %v", cp.incubating,
incubating)
}
// Check we go the expected reports.
@@ -595,7 +593,6 @@ func runFromCheckpoint(t *testing.T, ctx *htlcResolverTestContext,
if err := cp.preCheckpoint(ctx, resumed); err != nil {
t.Fatalf("failure at stage %d: %v", i, err)
}
}
resumed = false
-2
View File
@@ -329,7 +329,6 @@ func (h *htlcTimeoutResolver) Resolve() (ContractResolver, error) {
// transaction.
func (h *htlcTimeoutResolver) spendHtlcOutput() (*chainntnfs.SpendDetail, error) {
switch {
// If we have non-nil SignDetails, this means that have a 2nd level
// HTLC transaction that is signed using sighash SINGLE|ANYONECANPAY
// (the case for anchor type channels). In this case we can re-sign it
@@ -441,7 +440,6 @@ func (h *htlcTimeoutResolver) handleCommitSpend(
)
switch {
// If the sweeper is handling the second level transaction, wait for
// the CSV and possible CLTV lock to expire, before sweeping the output
// on the second-level.
@@ -138,6 +138,7 @@ func TestHtlcTimeoutResolver(t *testing.T) {
if reflect.DeepEqual(
templateTx.TxIn[0].Witness, witness,
) {
return templateTx, nil
}
templateTx.TxIn[0].Witness = witness
@@ -169,6 +170,7 @@ func TestHtlcTimeoutResolver(t *testing.T) {
if reflect.DeepEqual(
templateTx.TxIn[0].Witness, witness,
) {
return templateTx, nil
}
@@ -206,6 +208,7 @@ func TestHtlcTimeoutResolver(t *testing.T) {
if reflect.DeepEqual(
templateTx.TxIn[0].Witness, witness,
) {
return templateTx, nil
}
@@ -239,6 +242,7 @@ func TestHtlcTimeoutResolver(t *testing.T) {
if reflect.DeepEqual(
templateTx.TxIn[0].Witness, witness,
) {
return templateTx, nil
}
-3
View File
@@ -291,7 +291,6 @@ func (ns *NurseryStore) Incubate(kids []kidOutput, babies []babyOutput) error {
// will be stored as it waits out the kidOutput's CSV delay.
func (ns *NurseryStore) CribToKinder(bby *babyOutput) error {
return kvdb.Update(ns.db, func(tx kvdb.RwTx) error {
// First, retrieve or create the channel bucket corresponding to
// the baby output's origin channel point.
chanPoint := bby.OriginChanPoint()
@@ -472,7 +471,6 @@ func (ns *NurseryStore) PreschoolToKinder(kid *kidOutput,
// pruned from the height index as outputs are removed.
func (ns *NurseryStore) GraduateKinder(height uint32, kid *kidOutput) error {
return kvdb.Update(ns.db, func(tx kvdb.RwTx) error {
hghtBucket := ns.getHeightBucket(tx, height)
if hghtBucket == nil {
// Nothing to delete, bucket has already been removed.
@@ -597,7 +595,6 @@ func (ns *NurseryStore) FetchClass(
func (ns *NurseryStore) FetchPreschools() ([]kidOutput, error) { // nolint:golint
var kids []kidOutput
if err := kvdb.View(ns.db, func(tx kvdb.RTx) error {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.ReadBucket(ns.pfxChainKey)
if chainBucket == nil {
+3 -2
View File
@@ -884,7 +884,8 @@ func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) erro
// notification for an htlc timeout transaction. If successful, a goroutine
// will be spawned that will transition the provided baby output into the
// kindergarten state within the nursery store.
func (u *UtxoNursery) registerTimeoutConf(baby *babyOutput, heightHint uint32) error {
func (u *UtxoNursery) registerTimeoutConf(baby *babyOutput,
heightHint uint32) error {
birthTxID := baby.timeoutTx.TxHash()
@@ -1052,7 +1053,7 @@ type ContractMaturityReport struct {
}
// HtlcMaturityReport provides a summary of a single htlc output, and is
// embedded as party of the overarching ContractMaturityReport
// embedded as party of the overarching ContractMaturityReport.
type HtlcMaturityReport struct {
// Outpoint is the final output that will be swept back to the wallet.
Outpoint wire.OutPoint
+1
View File
@@ -308,6 +308,7 @@ var _ NetworkPeerBootstrapper = (*ChannelGraphBootstrapper)(nil)
func NewDNSSeedBootstrapper(
seeds [][2]string, net tor.Net,
timeout time.Duration) NetworkPeerBootstrapper {
return &DNSSeedBootstrapper{dnsSeeds: seeds, net: net, timeout: timeout}
}
+5 -1
View File
@@ -1178,6 +1178,7 @@ func (d *AuthenticatedGossiper) networkHandler() {
announcement.msg,
sourceToPub(announcement.source),
) {
announcement.err <- fmt.Errorf("recently " +
"rejected")
continue
@@ -1205,6 +1206,7 @@ func (d *AuthenticatedGossiper) networkHandler() {
routing.ErrVBarrierShuttingDown,
routing.ErrParentValidationFailed,
) {
log.Warnf("unexpected error "+
"during validation "+
"barrier shutdown: %v",
@@ -1787,6 +1789,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
routing.ErrIgnored,
routing.ErrVBarrierShuttingDown,
) {
log.Error(err)
}
@@ -2314,8 +2317,8 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
routing.ErrIgnored,
routing.ErrVBarrierShuttingDown,
) {
log.Debug(err)
log.Debug(err)
} else {
key := newRejectCacheKey(
msg.ShortChannelID.ToUint64(),
@@ -2929,6 +2932,7 @@ func IsKeepAliveUpdate(update *lnwire.ChannelUpdate,
// Both updates should be from the same direction.
if update.ChannelFlags&lnwire.ChanUpdateDirection !=
prev.ChannelFlags&lnwire.ChanUpdateDirection {
return false
}
+1
View File
@@ -2893,6 +2893,7 @@ func TestRetransmit(t *testing.T) {
if chanAnn != chanAnns || chanUpd != chanUpds ||
nodeAnn != nodeAnns {
t.Fatalf("unexpected number of announcements: "+
"chanAnn=%d, chanUpd=%d, nodeAnn=%d",
chanAnn, chanUpd, nodeAnn)
-1
View File
@@ -76,7 +76,6 @@ func TestSyncManagerNumActiveSyncers(t *testing.T) {
pinnedSyncers[vertex] = struct{}{}
pinnedPubkeys[vertex] = pubkey
}
syncMgr := newPinnedTestSyncManager(numActiveSyncers, pinnedSyncers)
+2
View File
@@ -842,6 +842,7 @@ func (g *GossipSyncer) processChanRangeReply(msg *lnwire.ReplyChannelRange) erro
// behind a few blocks from us.
if replyLastHeight < queryLastHeight &&
g.numChanRangeRepliesRcvd < maxReplies {
return nil
}
}
@@ -1377,6 +1378,7 @@ func (g *GossipSyncer) ProcessQueryMsg(msg lnwire.Message, peerQuit <-chan struc
syncState := g.syncState()
if syncState != waitingQueryRangeReply &&
syncState != waitingQueryChanReply {
return fmt.Errorf("received unexpected query reply "+
"message %T", msg)
}
+1 -2
View File
@@ -951,7 +951,7 @@ func TestGossipSyncerReplyChanRangeQuery(t *testing.T) {
// TestGossipSyncerReplyChanRangeQuery tests a variety of
// QueryChannelRange messages to ensure the underlying queries are
// executed with the correct block range
// executed with the correct block range.
func TestGossipSyncerReplyChanRangeQueryBlockRange(t *testing.T) {
t.Parallel()
@@ -1027,7 +1027,6 @@ func TestGossipSyncerReplyChanRangeQueryBlockRange(t *testing.T) {
resultsCh <- capFilterReqs
return
}
}
}()
-1
View File
@@ -162,6 +162,5 @@ func testValidateDeps(t *testing.T, test depTest) {
if !reflect.DeepEqual(err, test.expErr) {
t.Fatalf("validation mismatch, want: %v, got: %v",
test.expErr, err)
}
}
+2
View File
@@ -76,6 +76,7 @@ func explicitNegotiateCommitmentType(channelType lnwire.ChannelType,
lnwire.AnchorsZeroFeeHtlcTxOptional,
lnwire.StaticRemoteKeyOptional,
) {
return 0, errUnsupportedChannelType
}
return lnwallet.CommitmentTypeScriptEnforcedLease, nil
@@ -90,6 +91,7 @@ func explicitNegotiateCommitmentType(channelType lnwire.ChannelType,
lnwire.AnchorsZeroFeeHtlcTxOptional,
lnwire.StaticRemoteKeyOptional,
) {
return 0, errUnsupportedChannelType
}
return lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx, nil
+5 -6
View File
@@ -84,7 +84,7 @@ const (
// MaxBtcFundingAmountWumbo is a soft-limit on the maximum size of wumbo
// channels. This limit is 10 BTC and is the only thing standing between
// you and limitless channel size (apart from 21 million cap)
// you and limitless channel size (apart from 21 million cap).
MaxBtcFundingAmountWumbo = btcutil.Amount(1000000000)
// MaxLtcFundingAmount is a soft-limit of the maximum channel size
@@ -92,7 +92,7 @@ const (
// Protocol.
MaxLtcFundingAmount = MaxBtcFundingAmount * chainreg.BtcToLtcConversionRate
// TODO(roasbeef): tune
// TODO(roasbeef): tune.
msgBufferSize = 50
// maxWaitNumBlocksFundingConf is the maximum number of blocks to wait
@@ -723,7 +723,6 @@ func (f *Manager) nextPendingChanID() [32]byte {
// passed node. This will ensure any outputs which have been pre committed,
// (and thus locked from coin selection), are properly freed.
func (f *Manager) CancelPeerReservations(nodePub [33]byte) {
log.Debugf("Cancelling all reservations for peer %x", nodePub[:])
f.resMtx.Lock()
@@ -939,7 +938,6 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,
chanID, shortChanID, channelState)
switch channelState {
// The funding transaction was confirmed, but we did not successfully
// send the fundingLocked message to the peer, so let's do that now.
case markedOpen:
@@ -1112,7 +1110,6 @@ func (f *Manager) advancePendingChannelState(
}()
return timeoutErr
} else if err != nil {
return fmt.Errorf("error waiting for funding "+
"confirmation for ChannelPoint(%v): %v",
@@ -1149,7 +1146,7 @@ func (f *Manager) ProcessFundingMsg(msg lnwire.Message, peer lnpeer.Peer) {
// the funding workflow.
//
// TODO(roasbeef): add error chan to all, let channelManager handle
// error+propagate
// error+propagate.
func (f *Manager) handleFundingOpen(peer lnpeer.Peer,
msg *lnwire.OpenChannel) {
@@ -2382,6 +2379,7 @@ func (f *Manager) waitForFundingConfirmation(
// NOTE: This MUST be run as a goroutine.
func (f *Manager) waitForTimeout(completeChan *channeldb.OpenChannel,
cancelChan <-chan struct{}, timeoutChan chan<- error) {
defer f.wg.Done()
epochClient, err := f.cfg.Notifier.RegisterBlockEpochNtfn(nil)
@@ -3295,6 +3293,7 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) {
// maximum.
if commitType.HasAnchors() &&
commitFeePerKw > f.cfg.MaxAnchorsCommitFeeRate {
commitFeePerKw = f.cfg.MaxAnchorsCommitFeeRate
}
+1 -1
View File
@@ -996,6 +996,7 @@ func assertAddedToRouterGraph(t *testing.T, alice, bob *testNode,
func assertChannelAnnouncements(t *testing.T, alice, bob *testNode,
capacity btcutil.Amount, customMinHtlc []lnwire.MilliSatoshi,
customMaxHtlc []lnwire.MilliSatoshi) {
t.Helper()
// After the FundingLocked message is sent, Alice and Bob will each
@@ -3362,7 +3363,6 @@ func TestGetUpfrontShutdownScript(t *testing.T) {
t.Fatalf("expected address: %x, got: %x",
test.expectedScript, addr)
}
})
}
}
-1
View File
@@ -411,7 +411,6 @@ func (cm *circuitMap) cleanClosedChannels() error {
return nil
})
return err
}, func() {
// Reset the sets.
circuitKeySet = make(map[CircuitKey]struct{})
-2
View File
@@ -265,10 +265,8 @@ func TestCircuitMapCleanClosedChannels(t *testing.T) {
for _, ks := range test.untouched {
assertKeystoneNotDeleted(t, circuitMap, ks)
}
})
}
}
// createTestCircuit creates a circuit for testing with its incoming key being
+1 -1
View File
@@ -1130,6 +1130,7 @@ func (l *channelLink) htlcManager() {
if !shouldAdjustCommitFee(
newCommitFee, commitFee, minRelayFee,
) {
continue
}
@@ -2571,7 +2572,6 @@ func (l *channelLink) ShutdownIfChannelClean() error {
// updateChannelFee updates the commitment fee-per-kw on this channel by
// committing to an update_fee message.
func (l *channelLink) updateChannelFee(feePerKw chainfee.SatPerKWeight) error {
l.log.Infof("updating commit fee to %v sat/kw", feePerKw)
// We skip sending the UpdateFee message if the channel is not
-1
View File
@@ -5752,7 +5752,6 @@ func TestForwardingAsymmetricTimeLockPolicies(t *testing.T) {
// TestCheckHtlcForward tests that a link is properly enforcing the HTLC
// forwarding policy.
func TestCheckHtlcForward(t *testing.T) {
fetchLastChannelUpdate := func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate, error) {
+2 -1
View File
@@ -590,7 +590,6 @@ func (m *memoryMailBox) AddMessage(msg lnwire.Message) error {
func (m *memoryMailBox) AddPacket(pkt *htlcPacket) error {
m.pktCond.L.Lock()
switch htlc := pkt.htlc.(type) {
// Split off Settle/Fail packets into the repPkts queue.
case *lnwire.UpdateFulfillHTLC, *lnwire.UpdateFailHTLC:
if _, ok := m.repIndex[pkt.inKey()]; ok {
@@ -674,6 +673,7 @@ func (m *memoryMailBox) DustPackets() (lnwire.MilliSatoshi,
if m.isDust(
m.feeRate, false, true, addPkt.amount.ToSatoshis(),
) {
localDustSum += addPkt.amount
}
@@ -681,6 +681,7 @@ func (m *memoryMailBox) DustPackets() (lnwire.MilliSatoshi,
if m.isDust(
m.feeRate, false, false, addPkt.amount.ToSatoshis(),
) {
remoteDustSum += addPkt.amount
}
}
+5 -4
View File
@@ -986,17 +986,18 @@ var _ htlcNotifier = (*mockHTLCNotifier)(nil)
type mockHTLCNotifier struct{}
func (h *mockHTLCNotifier) NotifyForwardingEvent(key HtlcKey, info HtlcInfo,
eventType HtlcEventType) {
eventType HtlcEventType) { // nolint:whitespace
}
func (h *mockHTLCNotifier) NotifyLinkFailEvent(key HtlcKey, info HtlcInfo,
eventType HtlcEventType, linkErr *LinkError, incoming bool) {
eventType HtlcEventType, linkErr *LinkError,
incoming bool) { // nolint:whitespace
}
func (h *mockHTLCNotifier) NotifyForwardingFailEvent(key HtlcKey,
eventType HtlcEventType) {
eventType HtlcEventType) { // nolint:whitespace
}
func (h *mockHTLCNotifier) NotifySettleEvent(key HtlcKey,
preimage lntypes.Preimage, eventType HtlcEventType) {
preimage lntypes.Preimage, eventType HtlcEventType) { // nolint:whitespace
}
-1
View File
@@ -215,6 +215,5 @@ func TestNetworkResultStore(t *testing.T) {
if i >= 2 && err != ErrPaymentIDNotFound {
t.Fatalf("expected ErrPaymentIDNotFound, got %v", err)
}
}
}
+1 -1
View File
@@ -728,7 +728,7 @@ func (s *Switch) ForwardPackets(linkQuit chan struct{},
return nil
}
// logFwdErrs logs any errors received on `fwdChan`
// logFwdErrs logs any errors received on `fwdChan`.
func (s *Switch) logFwdErrs(num *int, wg *sync.WaitGroup, fwdChan chan error) {
defer s.wg.Done()
-1
View File
@@ -2961,7 +2961,6 @@ func testHtcNotifier(t *testing.T, testOpts []serverOption, iterations int,
checkHtlcEvents(t, aliceEvents.Updates(), alice)
checkHtlcEvents(t, bobEvents.Updates(), bob)
checkHtlcEvents(t, carolEvents.Updates(), carol)
}
}
+2 -1
View File
@@ -381,6 +381,7 @@ func IsHtlcSpendRevoke(txIn *wire.TxIn, signDesc *SignDescriptor) (
if len(txIn.Witness) == 3 &&
bytes.Equal(txIn.Witness[1], revokeKey.SerializeCompressed()) {
return true, nil
}
@@ -798,7 +799,7 @@ func SecondLevelHtlcScript(revocationKey, delayKey *btcec.PublicKey,
// OP_DROP
// <delay key>
// OP_ENDIF
// OP_CHECKSIG
// OP_CHECKSIG.
func LeaseSecondLevelHtlcScript(revocationKey, delayKey *btcec.PublicKey,
csvDelay, cltvExpiry uint32) ([]byte, error) {
+1
View File
@@ -22,6 +22,7 @@ import (
// prints debug information to stdout.
func assertEngineExecution(t *testing.T, testNum int, valid bool,
newEngine func() (*txscript.Engine, error)) {
t.Helper()
// Get a new VM to execute.
+12 -12
View File
@@ -47,7 +47,7 @@ const (
// - max-size: 40 bytes
UnknownWitnessSize = 1 + 1 + 40
// P2PKHSize 25 bytes
// P2PKHSize 25 bytes.
P2PKHSize = 25
// P2PKHOutputSize 34 bytes
@@ -68,7 +68,7 @@ const (
// - pkscript (p2wsh): 34 bytes
P2WSHOutputSize = 8 + 1 + P2WSHSize
// P2SHSize 23 bytes
// P2SHSize 23 bytes.
P2SHSize = 23
// P2SHOutputSize 32 bytes
@@ -205,16 +205,16 @@ const (
BaseAnchorCommitmentTxSize = 4 + 1 + FundingInputSize + 3 +
2*CommitmentDelayOutput + 2*CommitmentAnchorOutput + 4
// BaseAnchorCommitmentTxWeight 900 weight
// BaseAnchorCommitmentTxWeight 900 weight.
BaseAnchorCommitmentTxWeight = witnessScaleFactor * BaseAnchorCommitmentTxSize
// CommitWeight 724 weight
// CommitWeight 724 weight.
CommitWeight = BaseCommitmentTxWeight + WitnessCommitmentTxWeight
// AnchorCommitWeight 1124 weight
// AnchorCommitWeight 1124 weight.
AnchorCommitWeight = BaseAnchorCommitmentTxWeight + WitnessCommitmentTxWeight
// HTLCWeight 172 weight
// HTLCWeight 172 weight.
HTLCWeight = witnessScaleFactor * HTLCSize
// HtlcTimeoutWeight 663 weight
@@ -358,7 +358,7 @@ const (
AcceptedHtlcScriptSize = 3*1 + 20 + 5*1 + 33 + 8*1 + 20 + 4*1 +
33 + 5*1 + 4 + 5*1
// AcceptedHtlcScriptSizeConfirmed 143 bytes
// AcceptedHtlcScriptSizeConfirmed 143 bytes.
AcceptedHtlcScriptSizeConfirmed = AcceptedHtlcScriptSize +
HtlcConfirmedScriptOverhead
@@ -371,7 +371,7 @@ const (
// - witness_script: (accepted_htlc_script)
AcceptedHtlcTimeoutWitnessSize = 1 + 1 + 73 + 1 + 1 + AcceptedHtlcScriptSize
// AcceptedHtlcTimeoutWitnessSizeConfirmed 220 bytes
// AcceptedHtlcTimeoutWitnessSizeConfirmed 220 bytes.
AcceptedHtlcTimeoutWitnessSizeConfirmed = 1 + 1 + 73 + 1 + 1 +
AcceptedHtlcScriptSizeConfirmed
@@ -385,7 +385,7 @@ const (
// - witness_script (accepted_htlc_script)
AcceptedHtlcPenaltyWitnessSize = 1 + 1 + 73 + 1 + 33 + 1 + AcceptedHtlcScriptSize
// AcceptedHtlcPenaltyWitnessSizeConfirmed 253 bytes
// AcceptedHtlcPenaltyWitnessSizeConfirmed 253 bytes.
AcceptedHtlcPenaltyWitnessSizeConfirmed = 1 + 1 + 73 + 1 + 33 + 1 +
AcceptedHtlcScriptSizeConfirmed
@@ -448,7 +448,7 @@ const (
// - OP_ENDIF: 1 byte
OfferedHtlcScriptSize = 3*1 + 20 + 5*1 + 33 + 10*1 + 33 + 5*1 + 20 + 4*1
// OfferedHtlcScriptSizeConfirmed 136 bytes
// OfferedHtlcScriptSizeConfirmed 136 bytes.
OfferedHtlcScriptSizeConfirmed = OfferedHtlcScriptSize +
HtlcConfirmedScriptOverhead
@@ -462,7 +462,7 @@ const (
// - witness_script (offered_htlc_script)
OfferedHtlcSuccessWitnessSize = 1 + 1 + 73 + 1 + 32 + 1 + OfferedHtlcScriptSize
// OfferedHtlcSuccessWitnessSizeConfirmed 245 bytes
// OfferedHtlcSuccessWitnessSizeConfirmed 245 bytes.
OfferedHtlcSuccessWitnessSizeConfirmed = 1 + 1 + 73 + 1 + 32 + 1 +
OfferedHtlcScriptSizeConfirmed
@@ -497,7 +497,7 @@ const (
// - witness_script (offered_htlc_script)
OfferedHtlcPenaltyWitnessSize = 1 + 1 + 73 + 1 + 33 + 1 + OfferedHtlcScriptSize
// OfferedHtlcPenaltyWitnessSizeConfirmed 246 bytes
// OfferedHtlcPenaltyWitnessSizeConfirmed 246 bytes.
OfferedHtlcPenaltyWitnessSizeConfirmed = 1 + 1 + 73 + 1 + 33 + 1 +
OfferedHtlcScriptSizeConfirmed
-1
View File
@@ -938,7 +938,6 @@ func genSuccessTx(chanType channeldb.ChannelType) (*wire.MsgTx, error) {
successTx.TxIn[0].Witness = successWitness
return successTx, nil
}
type txSizeTest struct {
-1
View File
@@ -405,7 +405,6 @@ func (wt StandardWitnessType) WitnessGenerator(signer Signer,
// NOTE: This is part of the WitnessType interface.
func (wt StandardWitnessType) SizeUpperBound() (int, bool, error) {
switch wt {
// Outputs on a remote commitment transaction that pay directly to us.
case CommitSpendNoDelayTweakless:
fallthrough
-2
View File
@@ -404,7 +404,6 @@ func (ew *InvoiceExpiryWatcher) mainLoop(blockNtfns *chainntnfs.BlockEpochEvent)
cancelNext()
select {
case newInvoices := <-ew.newInvoices:
// Take newly forwarded invoices with higher priority
// in order to not block the newInvoices channel.
@@ -413,7 +412,6 @@ func (ew *InvoiceExpiryWatcher) mainLoop(blockNtfns *chainntnfs.BlockEpochEvent)
default:
select {
// Wait until the next invoice expires.
case <-ew.nextTimestampExpiry():
cancelNext = ew.cancelNextExpiredInvoice
+2 -4
View File
@@ -176,8 +176,8 @@ func (i *InvoiceRegistry) scanInvoicesOnStart() error {
removable = make([]channeldb.InvoiceDeleteRef, 0)
}
scanFunc := func(
paymentHash lntypes.Hash, invoice *channeldb.Invoice) error {
scanFunc := func(paymentHash lntypes.Hash,
invoice *channeldb.Invoice) error {
if invoice.IsPending() {
expiryRef := makeInvoiceExpiry(paymentHash, invoice)
@@ -428,7 +428,6 @@ func (i *InvoiceRegistry) dispatchToClients(event *invoiceEvent) {
// event is added while we're catching up a new client.
invState := event.invoice.State
switch {
case invState == channeldb.ContractSettled:
client.settleIndex = invoice.SettleIndex
@@ -908,7 +907,6 @@ func (i *InvoiceRegistry) NotifyExitHopHtlc(rHash lntypes.Hash,
}
switch {
// If we are accepting spontaneous AMP payments and this payload
// contains an AMP record, create an AMP invoice that will be settled
// below.
-1
View File
@@ -128,7 +128,6 @@ func updateMpp(ctx *invoiceUpdateCtx,
// Reject HTLCs to AMP invoices if they are missing an AMP payload, and
// HTLCs to MPP invoices if they have an AMP payload.
switch {
case inv.Terms.Features.RequiresFeature(lnwire.AMPRequired) &&
ctx.amp == nil:
-1
View File
@@ -57,7 +57,6 @@ func (c *Cluster) Validate() error {
}
switch c.LeaderElector {
case cluster.EtcdLeaderElector:
if c.EtcdElectionPrefix == "" {
return fmt.Errorf("etcd-election-prefix must be set")
-1
View File
@@ -24,7 +24,6 @@ func TestParseHexColor(t *testing.T) {
// Perform the table driven tests.
for _, ct := range colorTestCases {
color, err := ParseHexColor(ct.test)
if !ct.valid && err == nil {
t.Fatalf("Invalid color string: %s, should return "+
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"io/ioutil"
"net"
"net/http"
_ "net/http/pprof" // Blank import to set up profiling HTTP handlers.
_ "net/http/pprof" // nolint:gosec // used to set up profiling HTTP handlers.
"os"
"runtime/pprof"
"strings"
+1 -4
View File
@@ -157,7 +157,6 @@ func (d *AddInvoiceData) paymentHashAndPreimage() (
// The preimage will always be nil.
func (d *AddInvoiceData) ampPaymentHashAndPreimage() (*lntypes.Preimage, lntypes.Hash, error) {
switch {
// Preimages cannot be set on AMP invoice.
case d.Preimage != nil:
return nil, lntypes.Hash{},
@@ -285,7 +284,6 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
}
switch {
// If expiry is set, specify it. If it is not provided, no expiry time
// will be explicitly added to this payment request, which will imply
// the default 3600 seconds.
@@ -313,7 +311,6 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
// Otherwise, use the default AMP expiry.
default:
options = append(options, zpay32.Expiry(DefaultAMPInvoiceExpiry))
}
// If the description hash is set, then we add it do the list of options.
@@ -661,7 +658,7 @@ func sufficientHints(numHints, maxHints, scalingFactor int, amount,
// channels. The set of hop hints will be returned as a slice of functional
// options that'll append the route hint to the set of all route hints.
//
// TODO(roasbeef): do proper sub-set sum max hints usually << numChans
// TODO(roasbeef): do proper sub-set sum max hints usually << numChans.
func SelectHopHints(amtMSat lnwire.MilliSatoshi, cfg *SelectHopHintsCfg,
openChannels []*HopHintInfo,
numMaxHophints int) [][]zpay32.HopHint {
-1
View File
@@ -461,7 +461,6 @@ func TestSelectHopHints(t *testing.T) {
setMockChannelUsed(
h, private1ShortID, privateChan1Policy,
)
},
// Add two channels that we'd want to use, but the
// second one will be cut off due to our hop hint count
-2
View File
@@ -38,7 +38,6 @@ func decodePayReq(invoice *channeldb.Invoice,
"request: %v", err)
}
return decoded, nil
}
// CreateRPCInvoice creates an *lnrpc.Invoice from the *channeldb.Invoice.
@@ -179,7 +178,6 @@ func CreateRPCInvoice(invoice *channeldb.Invoice,
rpcInvoice.AmpInvoiceState = make(map[string]*lnrpc.AMPInvoiceState)
for setID, ampState := range invoice.AMPState {
setIDStr := hex.EncodeToString(setID[:])
var state lnrpc.InvoiceHTLCState
-2
View File
@@ -27,7 +27,6 @@ func CalculateFeeLimit(feeLimit *FeeLimit,
amount lnwire.MilliSatoshi) lnwire.MilliSatoshi {
switch feeLimit.GetLimit().(type) {
case *FeeLimit_Fixed:
return lnwire.NewMSatFromSatoshis(
btcutil.Amount(feeLimit.GetFixed()),
@@ -89,7 +88,6 @@ func MarshalUtxos(utxos []*lnwallet.Utxo, activeNetParams *chaincfg.Params) (
// address type.
var addrType AddressType
switch utxo.AddressType {
case lnwallet.WitnessPubKey:
addrType = AddressType_WITNESS_PUBKEY_HASH
+1 -5
View File
@@ -31,7 +31,7 @@ const (
// for MPP when the user is attempting to send a payment.
//
// TODO(roasbeef): make this value dynamic based on expected number of
// attempts for given amount
// attempts for given amount.
DefaultMaxParts = 16
)
@@ -1008,7 +1008,6 @@ func UnmarshalMPP(reqMPP *lnrpc.MPPRecord) (*record.MPP, error) {
reqAddr := reqMPP.PaymentAddr
switch {
// No MPP fields were provided.
case reqTotal == 0 && len(reqAddr) == 0:
return nil, fmt.Errorf("missing total_msat and payment_addr")
@@ -1110,7 +1109,6 @@ func marshallHtlcFailure(failure *channeldb.HTLCFailInfo) (*lnrpc.Failure,
}
switch failure.Reason {
case channeldb.HTLCFailUnknown:
rpcFailure.Code = lnrpc.Failure_UNKNOWN_FAILURE
@@ -1191,7 +1189,6 @@ func marshallWireError(msg lnwire.FailureMessage,
response *lnrpc.Failure) error {
switch onionErr := msg.(type) {
case *lnwire.FailIncorrectDetails:
response.Code = lnrpc.Failure_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS
response.Height = onionErr.Height()
@@ -1412,7 +1409,6 @@ func marshallPaymentFailureReason(reason *channeldb.FailureReason) (
}
switch *reason {
case channeldb.FailureReasonTimeout:
return lnrpc.PaymentFailureReason_FAILURE_REASON_TIMEOUT, nil
-1
View File
@@ -336,7 +336,6 @@ func TestUnmarshalMPP(t *testing.T) {
func testUnmarshalMPP(t *testing.T, test unmarshalMPPTest) {
mpp, err := UnmarshalMPP(test.mpp)
switch test.outcome {
// Valid arguments should result in no error, a non-nil MPP record, and
// the fields should be set correctly.
case valid:
-2
View File
@@ -141,9 +141,7 @@ func rpcFailReason(linkErr *htlcswitch.LinkError) (lnrpc.Failure_FailureCode,
default:
return 0, 0, fmt.Errorf("unknown failure "+
"detail type: %T", linkErr.FailureDetail)
}
}
// rpcFailureResolution maps an invoice failure resolution to a rpc failure
-1
View File
@@ -632,7 +632,6 @@ func (s *Server) DeriveSharedKey(_ context.Context, in *SharedKeyRequest) (
// is zero.
func parseRawKeyBytes(rawKeyBytes []byte) (*btcec.PublicKey, error) {
switch {
case len(rawKeyBytes) == 33:
// If a proper raw key was provided, then we'll attempt
// to decode and parse it.
+1 -1
View File
@@ -15,7 +15,7 @@ import (
const (
// SubServerName is the name of the sub rpc server. We'll use this name
// to register ourselves, and we also require that the main
// SubServerConfigDispatcher instance recognize as the name of our
// SubServerConfigDispatcher instance recognize as the name of our.
SubServerName = "WalletKitRPC"
)
+1
View File
@@ -1399,6 +1399,7 @@ func (w *WalletKit) ListAccounts(ctx context.Context,
// wallet in the response if they don't have any keys imported.
if account.AccountName == waddrmgr.ImportedAddrAccountName &&
account.ImportedKeyCount == 0 {
continue
}
+2 -7
View File
@@ -295,7 +295,7 @@ func (cfg *BaseNodeConfig) GenArgs() []string {
// ]
// },
// "chanPoint2": ...
// }
// }.
type policyUpdateMap map[string]map[string][]*lnrpc.RoutingPolicy
// HarnessNode represents an instance of lnd running within our test network
@@ -1189,7 +1189,6 @@ func (hn *HarnessNode) stop() error {
return fmt.Errorf("error attempting to stop "+
"grpc client: %v", err)
}
}
return nil
@@ -1207,7 +1206,7 @@ func (hn *HarnessNode) shutdown() error {
return nil
}
// kill kills the lnd process
// kill kills the lnd process.
func (hn *HarnessNode) kill() error {
return hn.cmd.Process.Kill()
}
@@ -1244,7 +1243,6 @@ type chanWatchRequest struct {
}
func (hn *HarnessNode) checkChanPointInGraph(chanPoint wire.OutPoint) bool {
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel()
@@ -1288,7 +1286,6 @@ func (hn *HarnessNode) lightningNetworkWatcher() {
for {
select {
// A new graph update has just been received, so we'll examine
// the current set of registered clients to see if we can
// dispatch any requests.
@@ -1767,7 +1764,6 @@ func (hn *HarnessNode) handlePolicyUpdateWatchRequest(req *chanWatchRequest) {
// getChannelPolicies queries the channel graph and formats the policies into
// the format defined in type policyUpdateMap.
func (hn *HarnessNode) getChannelPolicies(include bool) policyUpdateMap {
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel()
@@ -1782,7 +1778,6 @@ func (hn *HarnessNode) getChannelPolicies(include bool) policyUpdateMap {
policyUpdates := policyUpdateMap{}
for _, e := range graph.Edges {
policies := policyUpdates[e.ChanPoint]
// If the map[op] is nil, we need to initialize the map first.
+5 -1
View File
@@ -527,7 +527,6 @@ func assertConnected(t *harnessTest, alice, bob *lntest.HarnessNode) {
}
return nil
}, defaultTimeout)
require.NoError(t.t, err)
}
@@ -1004,6 +1003,7 @@ func assertChannelConstraintsEqual(
func assertAmountPaid(t *harnessTest, channelName string,
node *lntest.HarnessNode, chanPoint wire.OutPoint, amountSent,
amountReceived int64) {
ctxb := context.Background()
checkAmountPaid := func() error {
@@ -1027,6 +1027,7 @@ func assertAmountPaid(t *harnessTest, channelName string,
}
if channel.TotalSatoshisReceived !=
amountReceived {
return fmt.Errorf("%v: incorrect amount"+
" received: %v != %v",
channelName,
@@ -1068,6 +1069,7 @@ func assertAmountPaid(t *harnessTest, channelName string,
// node reports the expected number of pending channels.
func assertNumPendingChannels(t *harnessTest, node *lntest.HarnessNode,
expWaitingClose, expPendingForceClose int) {
ctxb := context.Background()
var predErr error
@@ -1394,6 +1396,7 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
case *lnrpc.ChannelEventUpdate_ClosedChannel:
if chanUpdate.Type !=
lnrpc.ChannelEventUpdate_CLOSED_CHANNEL {
return fmt.Errorf("update type mismatch: expected %v, got %v",
lnrpc.ChannelEventUpdate_CLOSED_CHANNEL,
chanUpdate.Type)
@@ -1432,6 +1435,7 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
// reaches the desired number of total channels.
func assertNodeNumChannels(t *harnessTest, node *lntest.HarnessNode,
numChannels int) {
ctxb := context.Background()
// Poll node for its list of channels.
@@ -1085,7 +1085,6 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
numBlocks := uint32(defaultCSV - 1)
if channelType == lnrpc.CommitmentType_ANCHORS {
numBlocks = defaultCSV - 2
}
_, err = net.Miner.Client.Generate(numBlocks)
if err != nil {
-1
View File
@@ -909,5 +909,4 @@ func testUpdateChannelPolicyFeeRateAccuracy(net *lntest.NetworkHarness,
assertPolicyUpdate(
t, nodes, net.Alice.PubKeyStr, expectedPolicy, chanPoint,
)
}
-1
View File
@@ -153,7 +153,6 @@ func testEtcdFailoverCase(net *lntest.NetworkHarness, ht *harnessTest,
}
failoverTimeout = 2 * time.Minute
} else {
shutdownAndAssert(net, ht, carol1)
failoverTimeout = 30 * time.Second
@@ -425,7 +425,6 @@ func testForwardInterceptorBasic(net *lntest.NetworkHarness, t *harnessTest) {
return err == nil && len(channels.Channels) > 0
}, defaultTimeout)
require.NoError(t.t, err, "alice <> bob channel didn't re-activate")
}
// interceptorTestContext is a helper struct to hold the test context and
-1
View File
@@ -77,7 +77,6 @@ func testBasicChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
expType := carolCommitType
switch daveCommitType {
// Dave supports anchors, type will be what
// Carol supports.
case lnrpc.CommitmentType_ANCHORS:
+1 -2
View File
@@ -473,7 +473,6 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
assertChannelConstraintsEqual(
t, aliceChannel.RemoteConstraints, bobChannel.LocalConstraints,
)
}
// testMaxPendingChannels checks that error is returned from remote peer if
@@ -523,6 +522,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
} else if !strings.Contains(
err.Error(), lnwire.ErrMaxPendingChannels.Error(),
) {
t.Fatalf("not expected error was received: %v", err)
}
@@ -773,7 +773,6 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
predErr = checkNumForceClosedChannels(pendingChanResp, 0)
return predErr == nil
}, defaultTimeout)
if err != nil {
t.Fatalf("channels not marked as fully resolved: %v", predErr)
@@ -369,6 +369,7 @@ func assertHtlcEvents(t *harnessTest, fwdCount, fwdFailCount, settleCount int,
// type is different from the htlc event type (forward, link failure etc).
func assertEventAndType(t *harnessTest, eventType routerrpc.HtlcEvent_EventType,
client routerrpc.Router_SubscribeHtlcEventsClient) *routerrpc.HtlcEvent {
event, err := client.Recv()
if err != nil {
t.Fatalf("could not get event")
@@ -299,7 +299,6 @@ func testMultiHopHtlcAggregation(net *lntest.NetworkHarness, t *harnessTest,
break
}
}
}
// In case of anchor we expect all the timeout and success second
@@ -311,7 +310,6 @@ func testMultiHopHtlcAggregation(net *lntest.NetworkHarness, t *harnessTest,
} else {
require.Len(t.t, timeoutTxs, numInvoices)
require.Len(t.t, successTxs, numInvoices)
}
// All mempool transactions should be spending from the commitment
-3
View File
@@ -16,7 +16,6 @@ import (
)
func testMultiHopHtlcClaims(net *lntest.NetworkHarness, t *harnessTest) {
type testCase struct {
name string
test func(net *lntest.NetworkHarness, t *harnessTest, alice,
@@ -180,7 +179,6 @@ func checkPaymentStatus(node *lntest.HarnessNode, preimage lntypes.Preimage,
}
switch status {
// If this expected status is SUCCEEDED, we expect the final preimage.
case lnrpc.Payment_SUCCEEDED:
if p.PaymentPreimage != preimage.String() {
@@ -195,7 +193,6 @@ func checkPaymentStatus(node *lntest.HarnessNode, preimage lntypes.Preimage,
p.PaymentPreimage)
}
}
}
if !found {
+1
View File
@@ -77,6 +77,7 @@ func testGetRecoveryInfo(net *lntest.NetworkHarness, t *harnessTest) {
if recoveryMode != expectedRecoveryMode ||
recoveryFinished != expectedRecoveryFinished ||
progress != expectedProgress {
return false
}
-1
View File
@@ -1072,7 +1072,6 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
)
if err != nil {
return err
}
if bkpStats == nil {
return errors.New("no active backup sessions")
+3 -4
View File
@@ -725,9 +725,8 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
// At this place we should get an rpc error with notification
// that edge is not found on hop(0)
if _, err := alicePayStream.Recv(); err != nil && strings.Contains(err.Error(),
"edge not found") {
_, err = alicePayStream.Recv()
if err != nil && strings.Contains(err.Error(), "edge not found") {
} else if err != nil {
t.Fatalf("payment stream has been closed but fake route has consumed: %v", err)
}
@@ -1423,7 +1422,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
closeChannelAndAssert(t, net, carol, chanPointCarol, false)
}
// computeFee calculates the payment fee as specified in BOLT07
// computeFee calculates the payment fee as specified in BOLT07.
func computeFee(baseFee, feeRate, amt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
return baseFee + amt*feeRate/1000000
}
@@ -129,7 +129,6 @@ func testSendMultiPathPayment(net *lntest.NetworkHarness, t *harnessTest) {
if htlc.State == lnrpc.InvoiceHTLCState_SETTLED {
settled++
}
}
if settled != succeeded {
t.Fatalf("expected invoice to be settled "+
-2
View File
@@ -211,7 +211,6 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
err = wait.Predicate(func() bool {
predErr = assertNumActiveHtlcs(nodes, 0)
return predErr == nil
}, defaultTimeout)
if err != nil {
t.Fatalf("htlc mismatch: %v", predErr)
@@ -737,7 +736,6 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
err = wait.Predicate(func() bool {
predErr = assertNumActiveHtlcs(nodes, numPayments)
return predErr == nil
}, defaultTimeout)
if err != nil {
t.Fatalf("htlc mismatch: %v", predErr)
Loaded 100 of 160 files, more files were not shown because too many files have changed in this diff. Show more