Skip to content

Commit a060068

Browse files
authored
cms: Re-add treasury subsidy check (#1469)
1 parent 945c3e0 commit a060068

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

politeiawww/cmsaddresswatcher.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,18 @@ func (p *politeiawww) checkHistoricalPayments(ctx context.Context, payment *data
224224
log.Debugf("Reviewing transactions for address: %v", payment.Address)
225225
for i, tx := range txs {
226226
// Check to see if running mainnet, if so, only accept transactions
227-
// that originate from the Treasury Subsidy.
227+
// that originate from a treasury spend OR from the subsidy.
228+
validTreasurySpends := true
228229
if !p.cfg.TestNet && !p.cfg.SimNet {
229-
if !tx.TreasuryGen {
230+
for _, address := range tx.InputAddresses {
231+
if address != mainnetSubsidyAddr {
232+
// All input addresses should be from the subsidy address
233+
validTreasurySpends = false
234+
break
235+
}
236+
}
237+
// Skip all transactions that are not a valid treasury spend
238+
if !validTreasurySpends && !tx.TreasuryGen {
230239
continue
231240
}
232241
}
@@ -292,10 +301,19 @@ func (p *politeiawww) checkPayments(ctx context.Context, payment *database.Payme
292301
amountReceived := dcrutil.Amount(0)
293302
log.Debugf("Reviewing transactions for address: %v", payment.Address)
294303

295-
// Check to see if running mainnet, if so, only accept transactions that
296-
// are determined to be Treasury Spends.
304+
// Check to see if running mainnet, if so, only accept transactions
305+
// that originate from a treasury spend OR from the subsidy.
306+
validTreasurySpends := true
297307
if !p.cfg.TestNet && !p.cfg.SimNet {
298-
if !tx.TreasuryGen {
308+
for _, address := range tx.InputAddresses {
309+
if address != mainnetSubsidyAddr {
310+
// All input addresses should be from the subsidy address
311+
validTreasurySpends = false
312+
break
313+
}
314+
}
315+
// Skip all transactions that are not a valid treasury spend
316+
if !validTreasurySpends && !tx.TreasuryGen {
299317
return false
300318
}
301319
}

0 commit comments

Comments
 (0)