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 -2
View File
@@ -940,11 +940,9 @@ func (b *BtcWallet) ListUnspentWitness(minConfs, maxConfs int32,
// network (either in the mempool or chain) no error will be returned.
func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx, label string) error {
if err := b.wallet.PublishTransaction(tx, label); err != nil {
// If we failed to publish the transaction, check whether we
// got an error of known type.
switch err.(type) {
// If the wallet reports a double spend, convert it to our
// internal ErrDoubleSpend and return.
case *base.ErrDoubleSpend:
@@ -1384,6 +1382,7 @@ func (b *BtcWallet) GetRecoveryInfo() (bool, float64, error) {
// rollback happens. In that case, we will return zero progress here.
if syncState.Height < birthdayBlock.Height ||
bestHeight < birthdayBlock.Height {
return isRecoveryMode, progress, nil
}
-1
View File
@@ -85,7 +85,6 @@ type StaticEstimator struct {
// NewStaticEstimator returns a new static fee estimator instance.
func NewStaticEstimator(feePerKW, relayFee SatPerKWeight) *StaticEstimator {
return &StaticEstimator{
feePerKW: feePerKW,
relayFee: relayFee,
-1
View File
@@ -321,5 +321,4 @@ func TestGetCachedFee(t *testing.T) {
require.ErrorIs(t, err, tc.expectErr)
})
}
}
-2
View File
@@ -334,7 +334,6 @@ func (c *ChanCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message,
bool, error) {
switch c.state {
// If we're in the close idle state, and we're receiving a channel closure
// related message, then this indicates that we're on the receiving side of
// an initiated channel closure.
@@ -662,7 +661,6 @@ func calcCompromiseFee(chanPoint wire.OutPoint, ourIdealFee, lastSentFee,
// Otherwise, we'll need to attempt to make a fee compromise if this is the
// second round, and neither side has agreed on fees.
switch {
// If their proposed fee is identical to our ideal fee, then we'll go with
// that as we can short circuit the fee negotiation. Similarly, if we
// haven't sent an offer yet, we'll default to our ideal fee.
-3
View File
@@ -73,7 +73,6 @@ func calculateFees(utxos []Coin, feeRate chainfee.SatPerKWeight) (btcutil.Amount
var weightEstimate input.TxWeightEstimator
for _, utxo := range utxos {
switch {
case txscript.IsPayToWitnessPubKeyHash(utxo.PkScript):
weightEstimate.AddP2WKHInput()
@@ -151,7 +150,6 @@ func CoinSelect(feeRate chainfee.SatPerKWeight, amt, dustLimit btcutil.Amount,
var changeAmt btcutil.Amount
switch {
// If the excess amount isn't enough to pay for fees based on
// fee rate and estimated size without using a change output,
// then increase the requested coin amount by the estimate
@@ -171,7 +169,6 @@ func CoinSelect(feeRate chainfee.SatPerKWeight, amt, dustLimit btcutil.Amount,
// change output.
default:
changeAmt = 0
}
if changeAmt < dustLimit {
-2
View File
@@ -428,7 +428,6 @@ func (i *PsbtIntent) Inputs() []wire.OutPoint {
var inputs []wire.OutPoint
switch i.State {
// We return the inputs to the pending psbt.
case PsbtVerified:
for _, in := range i.PendingPsbt.UnsignedTx.TxIn {
@@ -453,7 +452,6 @@ func (i *PsbtIntent) Inputs() []wire.OutPoint {
// know about. These are only known after the PSBT has been verified.
func (i *PsbtIntent) Outputs() []*wire.TxOut {
switch i.State {
// We return the outputs of the pending psbt.
case PsbtVerified:
return i.PendingPsbt.UnsignedTx.TxOut
+9 -8
View File
@@ -1541,7 +1541,6 @@ func (lc *LightningChannel) localLogUpdateToPayDesc(logUpdate *channeldb.LogUpda
// Since Add updates aren't saved to disk under this key, the update will
// never be an Add.
switch wireMsg := logUpdate.UpdateMsg.(type) {
// For HTLCs that we settled, we'll fetch the original offered HTLC from
// the remote update log so we can retrieve the same PaymentDescriptor that
// ReceiveHTLCSettle would produce.
@@ -1621,7 +1620,6 @@ func (lc *LightningChannel) remoteLogUpdateToPayDesc(logUpdate *channeldb.LogUpd
error) {
switch wireMsg := logUpdate.UpdateMsg.(type) {
case *lnwire.UpdateAddHTLC:
pd := &PaymentDescriptor{
RHash: wireMsg.PaymentHash,
@@ -1884,7 +1882,6 @@ func (lc *LightningChannel) restoreStateLogs(
// To ensure proper channel operation, we restore the add's addCommitHeightLocal
// field to the height of our local commitment.
for _, logUpdate := range unsignedAckedUpdates {
var htlcIdx uint64
switch wireMsg := logUpdate.UpdateMsg.(type) {
case *lnwire.UpdateFulfillHTLC:
@@ -1912,7 +1909,6 @@ func (lc *LightningChannel) restoreStateLogs(
// To ensure proper channel operation, we restore the add's addCommitHeightRemote
// field to the height of the remote commitment.
for _, logUpdate := range remoteUnsignedLocalUpdates {
var htlcIdx uint64
switch wireMsg := logUpdate.UpdateMsg.(type) {
case *lnwire.UpdateFulfillHTLC:
@@ -3004,6 +3000,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing,
chanType, true, false, feePerKw,
htlc.Amount.ToSatoshis(), dustLimit,
) {
continue
}
@@ -3058,6 +3055,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing,
chanType, false, false, feePerKw,
htlc.Amount.ToSatoshis(), dustLimit,
) {
continue
}
@@ -3507,7 +3505,8 @@ func (lc *LightningChannel) validateCommitmentSanity(theirLogCounter,
// any). The HTLC signatures are sorted according to the BIP 69 order of the
// HTLC's on the commitment transaction. Finally, the new set of pending HTLCs
// for the remote party's commitment are also returned.
func (lc *LightningChannel) SignNextCommitment() (lnwire.Sig, []lnwire.Sig, []channeldb.HTLC, error) {
func (lc *LightningChannel) SignNextCommitment() (lnwire.Sig, []lnwire.Sig,
[]channeldb.HTLC, error) {
lc.Lock()
defer lc.Unlock()
@@ -3531,7 +3530,6 @@ func (lc *LightningChannel) SignNextCommitment() (lnwire.Sig, []lnwire.Sig, []ch
// new state, we consume a prior revocation point.
commitPoint := lc.channelState.RemoteNextRevocation
if lc.remoteCommitChain.hasUnackedCommitment() || commitPoint == nil {
return sig, htlcSigs, nil, ErrNoWindow
}
@@ -4054,6 +4052,7 @@ func (lc *LightningChannel) computeView(view *htlcView, remoteChain bool,
lc.channelState.ChanType, false, !remoteChain,
feePerKw, htlc.Amount.ToSatoshis(), dustLimit,
) {
continue
}
@@ -4064,6 +4063,7 @@ func (lc *LightningChannel) computeView(view *htlcView, remoteChain bool,
lc.channelState.ChanType, true, !remoteChain,
feePerKw, htlc.Amount.ToSatoshis(), dustLimit,
) {
continue
}
@@ -4567,7 +4567,6 @@ func (lc *LightningChannel) oweCommitment(local bool) bool {
// have added to our remote commitment tx yet.
remoteUpdatesPending = lastLocalCommit.theirMessageIndex !=
lastRemoteCommit.theirMessageIndex
} else {
perspective = "remote"
@@ -5029,6 +5028,7 @@ func (lc *LightningChannel) GetDustSum(remote bool) lnwire.MilliSatoshi {
if HtlcIsDust(
chanType, false, !remote, feeRate, amt, dustLimit,
) {
dustSum += pd.Amount
}
}
@@ -5047,6 +5047,7 @@ func (lc *LightningChannel) GetDustSum(remote bool) lnwire.MilliSatoshi {
if HtlcIsDust(
chanType, true, !remote, feeRate, amt, dustLimit,
) {
dustSum += pd.Amount
}
}
@@ -6152,6 +6153,7 @@ func extractHtlcResolutions(feePerKw chainfee.SatPerKWeight, ourCommit bool,
chanType, htlc.Incoming, ourCommit, feePerKw,
htlc.Amt.ToSatoshis(), dustLimit,
) {
continue
}
@@ -7071,7 +7073,6 @@ func (lc *LightningChannel) IdealCommitFeeRate(netFeeRate, minRelayFeeRate,
// Otherwise, cap the fee rate at the max fee rate.
switch lc.channelState.ChanType.HasAnchors() &&
maxFeeRate > maxAnchorCommitFeeRate {
case true:
commitFeeRate = chainfee.SatPerKWeight(
math.Min(
+18 -1
View File
@@ -2576,6 +2576,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) == fee {
t.Fatalf("bob's feePerKw was unexpectedly locked in")
}
@@ -2589,6 +2590,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) != fee {
t.Fatalf("bob's feePerKw was not locked in")
}
@@ -2617,6 +2619,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) == fee {
t.Fatalf("alice's feePerKw was unexpectedly locked in")
}
@@ -2630,6 +2633,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) != fee {
t.Fatalf("alice's feePerKw was not locked in")
}
@@ -2728,6 +2732,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) == fee {
t.Fatalf("bob's feePerKw was unexpectedly locked in")
}
@@ -2742,6 +2747,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) != fee {
t.Fatalf("bob's feePerKw was not locked in")
}
@@ -2769,6 +2775,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) == fee {
t.Fatalf("alice's feePerKw was unexpectedly locked in")
}
@@ -2782,6 +2789,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) != fee {
t.Fatalf("Alice's feePerKw was not locked in")
}
@@ -2871,6 +2879,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) == fee {
t.Fatalf("bob's feePerKw was unexpectedly locked in")
}
@@ -2896,6 +2905,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) != fee {
t.Fatalf("bob's feePerKw was not locked in")
}
@@ -2923,6 +2933,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) == fee {
t.Fatalf("alice's feePerKw was unexpectedly locked in")
}
@@ -2936,6 +2947,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) != fee {
t.Fatalf("alice's feePerKw was not locked in")
}
@@ -4632,11 +4644,13 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) != newFeeRate {
t.Fatalf("alice's feePerKw was not locked in")
}
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) != newFeeRate {
t.Fatalf("bob's feePerKw was not locked in")
}
@@ -4851,11 +4865,13 @@ func TestFeeUpdateOldDiskFormat(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) != newFeeRate {
t.Fatalf("alice's feePerKw was not locked in")
}
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) != newFeeRate {
t.Fatalf("bob's feePerKw was not locked in")
}
@@ -4880,11 +4896,13 @@ func TestFeeUpdateOldDiskFormat(t *testing.T) {
if chainfee.SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
) != newFeeRate {
t.Fatalf("alice's feePerKw was not locked in")
}
if chainfee.SatPerKWeight(
bobChannel.channelState.LocalCommitment.FeePerKw,
) != newFeeRate {
t.Fatalf("bob's feePerKw was not locked in")
}
}
@@ -8506,7 +8524,6 @@ func TestFetchParent(t *testing.T) {
test.parentIndex, parent.HtlcIndex)
}
})
}
}
+4 -1
View File
@@ -293,7 +293,6 @@ func CommitScriptToRemote(chanType channeldb.ChannelType, initiator bool,
WitnessScript: p2wkh,
PkScript: p2wkh,
}, 0, nil
}
}
@@ -554,6 +553,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
cb.chanState.ChanType, false, isOurs, feePerKw,
htlc.Amount.ToSatoshis(), dustLimit,
) {
continue
}
@@ -564,6 +564,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
cb.chanState.ChanType, true, isOurs, feePerKw,
htlc.Amount.ToSatoshis(), dustLimit,
) {
continue
}
@@ -647,6 +648,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
cb.chanState.ChanType, false, isOurs, feePerKw,
htlc.Amount.ToSatoshis(), dustLimit,
) {
continue
}
@@ -664,6 +666,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
cb.chanState.ChanType, true, isOurs, feePerKw,
htlc.Amount.ToSatoshis(), dustLimit,
) {
continue
}
+1 -1
View File
@@ -349,7 +349,6 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
default:
chanType |= channeldb.NoFundingTxBit
}
} else {
// Otherwise, this is a dual funder channel, and no side is
// technically the "initiator"
@@ -435,6 +434,7 @@ func (r *ChannelReservation) SetNumConfsRequired(numConfs uint16) {
// if the parameters are seemed unsound.
func (r *ChannelReservation) CommitConstraints(c *channeldb.ChannelConstraints,
maxLocalCSVDelay uint16, responder bool) error {
r.Lock()
defer r.Unlock()
+5
View File
@@ -1735,6 +1735,7 @@ func txFromOutput(tx *wire.MsgTx, signer input.Signer, fromPubKey,
// new, unconfirmed tx that spends this output to pubKey.
func newTx(t *testing.T, r *rpctest.Harness, pubKey *btcec.PublicKey,
alice *lnwallet.LightningWallet, rbf bool) *wire.MsgTx {
t.Helper()
keyScript, err := scriptFromKey(pubKey)
@@ -3224,6 +3225,7 @@ func TestLightningWallet(t *testing.T, targetBackEnd string) {
if !runTests(t, walletDriver, backEnd, miningNode,
rpcConfig, chainNotifier) {
return
}
}
@@ -3521,10 +3523,12 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver,
success := t.Run(testName, func(t *testing.T) {
if backEnd == "neutrino" &&
strings.Contains(walletTest.name, "dual funder") {
t.Skip("skipping dual funder tests for neutrino")
}
if backEnd == "neutrino" &&
strings.Contains(walletTest.name, "spend unconfirmed") {
t.Skip("skipping spend unconfirmed tests for neutrino")
}
@@ -3539,6 +3543,7 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver,
// wipe buckets
if err := clearWalletStates(alice, bob); err !=
nil && err != kvdb.ErrBucketNotFound {
t.Fatalf("unable to wipe wallet state: %v", err)
}
}
-2
View File
@@ -941,7 +941,6 @@ func (l *LightningWallet) currentNumAnchorChans() (int, error) {
if c.ChanType.HasAnchors() {
numAnchors++
}
}
for _, c := range chans {
@@ -1084,7 +1083,6 @@ func (l *LightningWallet) CheckReservedValueTx(req CheckReservedValueTxReq) (
inputs, req.Tx.TxOut, numAnchors,
)
switch {
// If the error returned from CheckReservedValue is
// ErrReservedValueInvalidated, then it did nonetheless return
// the required reserved value and we check for the optional