@@ -198,6 +198,41 @@ func (d *Pegnetd) MintTokensForBalance(ctx context.Context, tx *sql.Tx, height u
198198 return nil
199199}
200200
201+ func (d * Pegnetd ) NullifyMintTokens (ctx context.Context , tx * sql.Tx , height uint32 ) error {
202+ fLog := log .WithFields (log.Fields {"height" : height })
203+
204+ FAGlobalMintAddress , err := factom .NewFAAddress (GlobalMintAddress )
205+ if err != nil {
206+ log .WithFields (log.Fields {
207+ "error" : err ,
208+ }).Info ("error getting mint address" )
209+ return err
210+ }
211+
212+ // Get all balances for the address
213+ balances , err := d .Pegnet .SelectBalances (& FAGlobalMintAddress )
214+ if err != nil {
215+ fLog .WithFields (log.Fields {
216+ "err" : err ,
217+ }).Info ("zeroing burn | balances retrieval failed" )
218+ }
219+
220+ for _ , tokenSupply := range MintTotalSupplyMap {
221+ // Substract from every issuance
222+ ticker := tokenSupply .Ticker
223+ value , _ := balances [ticker ]
224+ _ , _ , err := d .Pegnet .SubFromBalance (tx , & FAGlobalMintAddress , ticker , value ) // lastInd, txErr, err
225+ if err != nil {
226+ fLog .WithFields (log.Fields {
227+ "ticker" : ticker ,
228+ "balance" : value ,
229+ }).Info ("zeroing burn | substract from balance failed" )
230+ return err
231+ }
232+ }
233+ return nil
234+ }
235+
201236func (d * Pegnetd ) NullifyBurnAddress (ctx context.Context , tx * sql.Tx , height uint32 ) error {
202237 fLog := log .WithFields (log.Fields {"height" : height })
203238
@@ -310,6 +345,12 @@ func (d *Pegnetd) SyncBlock(ctx context.Context, tx *sql.Tx, height uint32) erro
310345 }
311346 }
312347
348+ if height == V204BurnMintTokenActivation {
349+ if err := d .NullifyMintTokens (ctx , tx , d .Sync .Synced + 1 ); err != nil {
350+ return err
351+ }
352+ }
353+
313354 dblock := new (factom.DBlock )
314355 dblock .Height = height
315356 if err := dblock .Get (nil , d .FactomClient ); err != nil {
0 commit comments