Fix nil dereference on merge mining tag depth

This commit is contained in:
DataHoarder 2024-04-08 16:44:55 +02:00
parent 68abe04340
commit 4a8971dae1
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk

View file

@ -240,7 +240,7 @@ func NewShareFromExportedBytes(buf []byte, consensus *Consensus, cacheInterface
b.CachedShareVersion = b.CalculateShareVersion(consensus)
//TODO: this is to comply with non-standard p2pool serialization, see https://github.com/SChernykh/p2pool/issues/249
if t := b.Main.Coinbase.Extra.GetTag(transaction.TxExtraTagMergeMining); t == nil && t.VarInt != 32 {
if t := b.Main.Coinbase.Extra.GetTag(transaction.TxExtraTagMergeMining); t == nil || t.VarInt != 32 {
return nil, errors.New("wrong merge mining tag depth")
}
@ -507,7 +507,7 @@ func (b *PoolBlock) FromReader(consensus *Consensus, derivationCache DerivationC
}
//TODO: this is to comply with non-standard p2pool serialization, see https://github.com/SChernykh/p2pool/issues/249
if t := b.Main.Coinbase.Extra.GetTag(transaction.TxExtraTagMergeMining); t == nil && t.VarInt != 32 {
if t := b.Main.Coinbase.Extra.GetTag(transaction.TxExtraTagMergeMining); t == nil || t.VarInt != 32 {
return errors.New("wrong merge mining tag depth")
}
@ -533,7 +533,7 @@ func (b *PoolBlock) FromCompactReader(consensus *Consensus, derivationCache Deri
}
//TODO: this is to comply with non-standard p2pool serialization, see https://github.com/SChernykh/p2pool/issues/249
if t := b.Main.Coinbase.Extra.GetTag(transaction.TxExtraTagMergeMining); t == nil && t.VarInt != 32 {
if t := b.Main.Coinbase.Extra.GetTag(transaction.TxExtraTagMergeMining); t == nil || t.VarInt != 32 {
return errors.New("wrong merge mining tag depth")
}