Improve handling of invalid addresses
This commit is contained in:
parent
fb93c9ff7a
commit
a04e38f0f7
@ -324,7 +324,7 @@ func (d *RocksDB) writeAddressesUTXO(wb *gorocksdb.WriteBatch, block *bchain.Blo
|
|||||||
glog.Warningf("rocksdb: addrID: %v - height %d, tx %v, output %v", err, block.Height, tx.Txid, output)
|
glog.Warningf("rocksdb: addrID: %v - height %d, tx %v, output %v", err, block.Height, tx.Txid, output)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glog.Infof("rocksdb: block %d, skipping addrID of length %d", block.Height, len(addrID))
|
glog.Infof("rocksdb: height %d, tx %v, vout %v, skipping addrID of length %d", block.Height, tx.Txid, i, len(addrID))
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -397,8 +397,12 @@ func (d *RocksDB) writeAddressesUTXO(wb *gorocksdb.WriteBatch, block *bchain.Blo
|
|||||||
}
|
}
|
||||||
tai.addrID = ot.addrID
|
tai.addrID = ot.addrID
|
||||||
tai.valueSat = ot.valueSat
|
tai.valueSat = ot.valueSat
|
||||||
// mark the output tx as spent
|
// mark the output as spent in tx
|
||||||
ot.spent = true
|
ot.spent = true
|
||||||
|
if len(ot.addrID) == 0 {
|
||||||
|
glog.Warningf("rocksdb: height %d, tx %v, input tx %v vout %v skipping empty address", block.Height, tx.Txid, input.Txid, input.Vout)
|
||||||
|
continue
|
||||||
|
}
|
||||||
strAddrID := string(ot.addrID)
|
strAddrID := string(ot.addrID)
|
||||||
// check that the address was used already in this block
|
// check that the address was used already in this block
|
||||||
o, processed := addresses[strAddrID]
|
o, processed := addresses[strAddrID]
|
||||||
@ -428,10 +432,11 @@ func (d *RocksDB) writeAddressesUTXO(wb *gorocksdb.WriteBatch, block *bchain.Blo
|
|||||||
ab.balanceSat.Sub(&ab.balanceSat, &ot.valueSat)
|
ab.balanceSat.Sub(&ab.balanceSat, &ot.valueSat)
|
||||||
if ab.balanceSat.Sign() < 0 {
|
if ab.balanceSat.Sign() < 0 {
|
||||||
ad, err := d.chainParser.OutputScriptToAddresses(ot.addrID)
|
ad, err := d.chainParser.OutputScriptToAddresses(ot.addrID)
|
||||||
|
had := hex.EncodeToString(ot.addrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("rocksdb: unparsable address reached negative balance %v, resetting to 0. Parser error %v", ab.balanceSat.String(), err)
|
glog.Warningf("rocksdb: unparsable address hex '%v' reached negative balance %v, resetting to 0. Parser error %v", had, ab.balanceSat.String(), err)
|
||||||
} else {
|
} else {
|
||||||
glog.Warningf("rocksdb: address %v reached negative balance %v, resetting to 0", ab.balanceSat.String(), ad)
|
glog.Warningf("rocksdb: address %v hex '%v' reached negative balance %v, resetting to 0", ad, had, ab.balanceSat.String())
|
||||||
}
|
}
|
||||||
ab.balanceSat.SetInt64(0)
|
ab.balanceSat.SetInt64(0)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user