@@ -10,6 +10,7 @@ import (
1010 "fmt"
1111 "math/big"
1212 "sort"
13+ "strings"
1314 "sync"
1415
1516 "github.com/btcsuite/btcd/btcec/v2"
@@ -155,6 +156,10 @@ func ComputeTweaksForBlockV3(block *types.Block) ([]types.Tweak, error) {
155156 }(batch )
156157 }
157158
159+ if errG != nil {
160+ panic (errG )
161+ }
162+
158163 wg .Wait ()
159164 return tweaks , nil
160165}
@@ -217,11 +222,15 @@ func ComputeTweaksForBlockV2(block *types.Block) ([]types.Tweak, error) {
217222 }(tx )
218223 }
219224
225+ if errG != nil {
226+ panic (errG )
227+ }
220228 wg .Wait ()
221229 //common.InfoLogger.Println("Tweaks computed...")
222230 return tweaks , nil
223231}
224232
233+ // Deprecated: slowest of them all, do not use anywhere
225234func ComputeTweaksForBlockV1 (block * types.Block ) ([]types.Tweak , error ) {
226235 //common.InfoLogger.Println("Computing tweaks...")
227236 var tweaks []types.Tweak
@@ -260,6 +269,10 @@ func ComputeTweakPerTx(tx types.Transaction) (*types.Tweak, error) {
260269 }
261270 summedKey , err := sumPublicKeys (pubKeys )
262271 if err != nil {
272+ if strings .Contains (err .Error (), "not on secp256k1 curve" ) {
273+ common .WarningLogger .Println (err )
274+ return nil , nil
275+ }
263276 common .DebugLogger .Println ("tx:" , tx .Txid )
264277 common .ErrorLogger .Println (err )
265278 return nil , err
@@ -459,7 +472,6 @@ func sumPublicKeys(pubKeys []string) (*btcec.PublicKey, error) {
459472 if err != nil {
460473 common .ErrorLogger .Println (err )
461474 // todo remove panics
462- panic (err )
463475 return nil , err
464476 }
465477
@@ -471,7 +483,6 @@ func sumPublicKeys(pubKeys []string) (*btcec.PublicKey, error) {
471483 publicKey , err := btcec .ParsePubKey (bytesPubKey )
472484 if err != nil {
473485 common .ErrorLogger .Println (err )
474- panic (err )
475486 return nil , err
476487 }
477488
@@ -489,14 +500,12 @@ func sumPublicKeys(pubKeys []string) (*btcec.PublicKey, error) {
489500 decodeString , err = hex .DecodeString (fmt .Sprintf ("04%s%s" , sX , sY ))
490501 if err != nil {
491502 common .ErrorLogger .Println (err )
492- panic (err )
493503 return nil , err
494504 }
495505
496506 lastPubKey , err = btcec .ParsePubKey (decodeString )
497507 if err != nil {
498508 common .ErrorLogger .Println (err )
499- panic (err )
500509 return nil , err
501510 }
502511 }
0 commit comments