@@ -3,6 +3,7 @@ package snapshotcreator
3
3
import (
4
4
"os"
5
5
6
+ "github.com/iotaledger/hive.go/core/safemath"
6
7
"github.com/iotaledger/hive.go/ierrors"
7
8
"github.com/iotaledger/hive.go/lo"
8
9
"github.com/iotaledger/hive.go/log"
@@ -137,8 +138,18 @@ func CreateSnapshot(opts ...options.Option[Options]) error {
137
138
return accumulator + details .Amount
138
139
}, iotago .BaseToken (0 ))
139
140
141
+ supplyMinusAccounts , err := safemath .SafeSub (opt .ProtocolParameters .TokenSupply (), totalAccountAmount )
142
+ if err != nil {
143
+ return ierrors .Wrapf (err , "failed to calculate genesis output balance, remaining funds: %d, needed account funds: %d" , opt .ProtocolParameters .TokenSupply (), totalAccountAmount )
144
+ }
145
+
146
+ genesisOutputBalance , err := safemath .SafeSub (supplyMinusAccounts , totalBasicOutputAmount )
147
+ if err != nil {
148
+ return ierrors .Wrapf (err , "failed to calculate genesis output balance, remaining funds: %d, needed basic output funds: %d" , supplyMinusAccounts , totalBasicOutputAmount )
149
+ }
150
+
140
151
var genesisTransactionOutputs iotago.TxEssenceOutputs
141
- genesisOutput , err := createGenesisOutput (api , opt . ProtocolParameters . TokenSupply () - totalAccountAmount - totalBasicOutputAmount , iotago .MaxMana / 100 , opt .GenesisKeyManager )
152
+ genesisOutput , err := createGenesisOutput (api , genesisOutputBalance , iotago .MaxMana / 100 , opt .GenesisKeyManager )
142
153
if err != nil {
143
154
return ierrors .Wrap (err , "failed to create genesis outputs" )
144
155
}
0 commit comments