diff --git a/object.go b/object.go index 5481b35..e18e491 100644 --- a/object.go +++ b/object.go @@ -7,12 +7,18 @@ import ( "github.com/MixinNetwork/mixin/common" ) -func CreateObjectStorageTransaction(ctx context.Context, extra []byte, traceId string, references []string, u *SafeUser) (*SequencerTransactionRequest, error) { +func CreateObjectStorageTransaction(ctx context.Context, extra []byte, traceId string, references []string, limit string, u *SafeUser) (*SequencerTransactionRequest, error) { if len(extra) > common.ExtraSizeStorageCapacity { return nil, fmt.Errorf("too large extra %d > %d", len(extra), common.ExtraSizeStorageCapacity) } step := common.NewIntegerFromString(common.ExtraStoragePriceStep) amount := step.Mul(len(extra)/common.ExtraSizeStorageStep + 1) + if limit != "" { + strl := common.NewIntegerFromString(limit) + if strl.Cmp(amount) > 0 { + amount = strl + } + } addr := common.NewAddressFromSeed(make([]byte, 64)) mix := NewMainnetMixAddress([]string{addr.String()}, 1) mix.Threshold = 64