Make upper limit for gap in xpub address derivation

xpub
Martin Boehm 2019-02-25 14:09:24 +01:00
parent c7808b87d5
commit e1eadda6bf
1 changed files with 4 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import (
const xpubLen = 111
const defaultAddressesGap = 20
const maxAddressesGap = 10000
const txInput = 1
const txOutput = 2
@ -244,6 +245,9 @@ func (w *Worker) getXpubData(xpub string, page int, txsOnPage int, option GetAdd
)
if gap <= 0 {
gap = defaultAddressesGap
} else if gap > maxAddressesGap {
// limit the maximum gap to protect against unreasonably big values that could cause high load of the server
gap = maxAddressesGap
}
// gap is increased one as there must be gap of empty addresses before the derivation is stopped
gap++