Skip to content

Commit

Permalink
fix: check change addresses too
Browse files Browse the repository at this point in the history
  • Loading branch information
tyzbit committed Apr 27, 2022
1 parent cc95c66 commit 47543eb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,13 @@ func (w WatcherConfig) WatchPubkey(c btcapi.Config, nickPubkey string) {
log.Errorf("error calling btcapi: %v", err)
}
pubkeyTxCount := 0
for _, address := range pubKeyPage.ReceiveAddresses {
addresses := []string{}
// Zipper join addresses
// ChangeAddresses and ReceiveAddresses should be the same length
for i := 0; i < len(pubKeyPage.ChangeAddresses); i++ {
addresses = append(addresses, pubKeyPage.ReceiveAddresses[i], pubKeyPage.ChangeAddresses[i])
}
for _, address := range addresses {
addressSummary, err := c.AddressSummary(address)
if err != nil {
log.Errorf("error calling btcapi: %v", err)
Expand All @@ -247,7 +253,7 @@ func (w WatcherConfig) WatchPubkey(c btcapi.Config, nickPubkey string) {
totalPubkeyBalance = totalPubkeyBalance + addressSummary.TXHistory.BalanceSat
totalPubkeyTxCount = totalPubkeyTxCount + addressSummary.TXHistory.TXCount
if pubkeyTxCount == addressSummary.TXHistory.TXCount {
if NoTXCount > w.Lookahead {
if NoTXCount > w.Lookahead*2 {
break pubkey
}
NoTXCount++
Expand Down

0 comments on commit 47543eb

Please sign in to comment.