Skip to content

Commit 26c3ce1

Browse files
committed
multi: fix lint findings from btcd v2 migration
The btcd v2 module migration re-touched several lines that the line-length linter then flagged, and left one error return unchecked. Wrap the over-length lines in input/test_utils.go and zpay32 (the address-decode helpers and test fixtures whose btcutil->address rename lengthened them), and check the LoadTxFilter error return in routing/chainview/btcd.go.
1 parent 77ab72b commit 26c3ce1

4 files changed

Lines changed: 46 additions & 14 deletions

File tree

input/test_utils.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ func (m *MockSigner) findKey(needleHash160 []byte, singleTweak []byte,
223223
for _, privkey := range m.Privkeys {
224224
// First check whether public key is directly derived from
225225
// private key.
226-
hash160 := address.Hash160(privkey.PubKey().SerializeCompressed())
226+
hash160 := address.Hash160(
227+
privkey.PubKey().SerializeCompressed(),
228+
)
227229
if bytes.Equal(hash160, needleHash160) {
228230
return privkey
229231
}
@@ -238,7 +240,9 @@ func (m *MockSigner) findKey(needleHash160 []byte, singleTweak []byte,
238240
default:
239241
continue
240242
}
241-
hash160 = address.Hash160(privkey.PubKey().SerializeCompressed())
243+
hash160 = address.Hash160(
244+
privkey.PubKey().SerializeCompressed(),
245+
)
242246
if bytes.Equal(hash160, needleHash160) {
243247
return privkey
244248
}

routing/chainview/btcd.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,12 @@ func (b *BtcdFilteredChainView) chainFilterer() {
344344
// Apply the new TX filter to btcd, which will cause
345345
// all following notifications from and calls to it
346346
// return blocks filtered with the new filter.
347-
b.btcdConn.LoadTxFilter(false, []address.Address{},
348-
update.newUtxos)
347+
err := b.btcdConn.LoadTxFilter(
348+
false, []address.Address{}, update.newUtxos,
349+
)
350+
if err != nil {
351+
log.Errorf("Unable to load tx filter: %v", err)
352+
}
349353

350354
// All blocks gotten after we loaded the filter will
351355
// have the filter applied, but we will need to rescan

zpay32/decode.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,9 @@ func parseMinFinalCLTVExpiry(data []byte) (*uint64, error) {
527527

528528
// parseFallbackAddr converts the data (encoded in base32) into a fallback
529529
// on-chain address.
530-
func parseFallbackAddr(data []byte, net *chaincfg.Params) (address.Address, error) { // nolint:dupl
530+
func parseFallbackAddr(data []byte,
531+
net *chaincfg.Params) (address.Address, error) { //nolint:dupl
532+
531533
// Checks if the data is empty or contains a version without an address.
532534
if len(data) < 2 {
533535
return nil, fmt.Errorf("empty fallback address field")
@@ -545,9 +547,13 @@ func parseFallbackAddr(data []byte, net *chaincfg.Params) (address.Address, erro
545547

546548
switch len(witness) {
547549
case 20:
548-
addr, err = address.NewAddressWitnessPubKeyHash(witness, net)
550+
addr, err = address.NewAddressWitnessPubKeyHash(
551+
witness, net,
552+
)
549553
case 32:
550-
addr, err = address.NewAddressWitnessScriptHash(witness, net)
554+
addr, err = address.NewAddressWitnessScriptHash(
555+
witness, net,
556+
)
551557
default:
552558
return nil, fmt.Errorf("unknown witness program length %d",
553559
len(witness))
@@ -581,7 +587,9 @@ func parseFallbackAddr(data []byte, net *chaincfg.Params) (address.Address, erro
581587
return nil, err
582588
}
583589

584-
addr, err = address.NewAddressScriptHashFromHash(scriptHash, net)
590+
addr, err = address.NewAddressScriptHashFromHash(
591+
scriptHash, net,
592+
)
585593
if err != nil {
586594
return nil, err
587595
}

zpay32/invoice_test.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,28 @@ var (
6666
testExpiry0 = time.Duration(0) * time.Second
6767
testExpiry60 = time.Duration(60) * time.Second
6868

69-
testAddrTestnet, _ = address.DecodeAddress("mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP", &chaincfg.TestNet3Params)
70-
testRustyAddr, _ = address.DecodeAddress("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T", &chaincfg.MainNetParams)
71-
testAddrMainnetP2SH, _ = address.DecodeAddress("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX", &chaincfg.MainNetParams)
72-
testAddrMainnetP2WPKH, _ = address.DecodeAddress("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", &chaincfg.MainNetParams)
73-
testAddrMainnetP2WSH, _ = address.DecodeAddress("bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3", &chaincfg.MainNetParams)
74-
testAddrMainnetP2TR, _ = address.DecodeAddress("bc1pptdvg0d2nj99568"+
69+
testAddrTestnet, _ = address.DecodeAddress(
70+
"mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP",
71+
&chaincfg.TestNet3Params,
72+
)
73+
testRustyAddr, _ = address.DecodeAddress(
74+
"1RustyRX2oai4EYYDpQGWvEL62BBGqN9T",
75+
&chaincfg.MainNetParams,
76+
)
77+
testAddrMainnetP2SH, _ = address.DecodeAddress(
78+
"3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX",
79+
&chaincfg.MainNetParams,
80+
)
81+
testAddrMainnetP2WPKH, _ = address.DecodeAddress(
82+
"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4",
83+
&chaincfg.MainNetParams,
84+
)
85+
testAddrMainnetP2WSH, _ = address.DecodeAddress(
86+
"bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0"+
87+
"gdcccefvpysxf3qccfmv3",
88+
&chaincfg.MainNetParams,
89+
)
90+
testAddrMainnetP2TR, _ = address.DecodeAddress("bc1pptdvg0d2nj99568"+
7591
"qn6ssdy4cygnwuxgw2ukmnwgwz7jpqjz2kszse2s3lm",
7692
&chaincfg.MainNetParams)
7793

0 commit comments

Comments
 (0)