From 357bb2fb0a6f94d2fc247dda5bb18df678cbbe81 Mon Sep 17 00:00:00 2001 From: muXxer Date: Mon, 26 Feb 2024 17:16:41 +0100 Subject: [PATCH 1/2] Ident to owner/address renames --- builder/transaction_builder_test.go | 12 +- feat_issuer.go | 4 +- feat_sender.go | 2 +- output.go | 60 +- output_account.go | 6 +- output_anchor.go | 10 +- output_basic.go | 6 +- output_delegation.go | 6 +- output_foundry.go | 8 +- output_id_proof_test.go | 10 +- output_nft.go | 6 +- output_test.go | 126 ++-- signed_transaction.go | 4 +- tpkg/rand_ed25519.go | 2 +- transaction_test.go | 24 +- unlock_cond.go | 36 +- unlock_cond_address.go | 2 +- unlock_cond_expiration.go | 8 +- unlock_cond_governor.go | 2 +- unlock_cond_state_ctrl.go | 2 +- unlock_cond_storage_return.go | 4 +- vm/nova/stvf_test.go | 174 ++--- vm/nova/vm.go | 20 +- vm/nova/vm_test.go | 1026 +++++++++++++-------------- vm/vm.go | 236 +++--- 25 files changed, 898 insertions(+), 898 deletions(-) diff --git a/builder/transaction_builder_test.go b/builder/transaction_builder_test.go index 754a8467b..1459a8258 100644 --- a/builder/transaction_builder_test.go +++ b/builder/transaction_builder_test.go @@ -14,10 +14,10 @@ import ( ) func TestTransactionBuilder(t *testing.T) { - identityOne := tpkg.RandEd25519PrivateKey() + prvKey := tpkg.RandEd25519PrivateKey() //nolint:forcetypeassert // we can safely assume that this is an ed25519.PublicKey - inputAddr := iotago.Ed25519AddressFromPubKey(identityOne.Public().(ed25519.PublicKey)) - addrKeys := iotago.AddressKeys{Address: inputAddr, Keys: identityOne} + inputAddr := iotago.Ed25519AddressFromPubKey(prvKey.Public().(ed25519.PublicKey)) + addrKeys := iotago.AddressKeys{Address: inputAddr, Keys: prvKey} type test struct { name string @@ -138,10 +138,10 @@ func TestTransactionBuilder(t *testing.T) { }) // wrong address/keys - wrongIdentity := tpkg.RandEd25519PrivateKey() + wrongAddress := tpkg.RandEd25519PrivateKey() //nolint:forcetypeassert // we can safely assume that this is a ed25519.PublicKey - wrongAddr := iotago.Ed25519AddressFromPubKey(wrongIdentity.Public().(ed25519.PublicKey)) - wrongAddrKeys := iotago.AddressKeys{Address: wrongAddr, Keys: wrongIdentity} + wrongAddr := iotago.Ed25519AddressFromPubKey(wrongAddress.Public().(ed25519.PublicKey)) + wrongAddrKeys := iotago.AddressKeys{Address: wrongAddr, Keys: wrongAddress} return &test{ name: "err - missing address keys (wrong address)", diff --git a/feat_issuer.go b/feat_issuer.go index 4d9b45534..88314cbdd 100644 --- a/feat_issuer.go +++ b/feat_issuer.go @@ -8,10 +8,10 @@ import ( ) // IssuerFeature is a feature which associates an output -// with an issuer identity. Unlike the SenderFeature, the issuer identity +// with an issuer address. Unlike the SenderFeature, the issuer address // only has to be unlocked when the ChainOutput is first created, // afterwards, the issuer feature must not change, meaning that subsequent outputs -// must always define the same issuer identity (the identity does not need to be unlocked anymore though). +// must always define the same issuer address (the address does not need to be unlocked anymore though). type IssuerFeature struct { Address Address `serix:""` } diff --git a/feat_sender.go b/feat_sender.go index b84519493..ba432b1ef 100644 --- a/feat_sender.go +++ b/feat_sender.go @@ -7,7 +7,7 @@ import ( ) // SenderFeature is a feature which associates an output -// with a sender identity. The sender identity needs to be unlocked in the transaction +// with a sender address. The sender address needs to be unlocked in the transaction // for the SenderFeature to be valid. type SenderFeature struct { Address Address `serix:""` diff --git a/output.go b/output.go index acb28c0a4..4bc34b9ea 100644 --- a/output.go +++ b/output.go @@ -95,10 +95,10 @@ var outputNames = [OutputDelegation + 1]string{ } var ( - // ErrTransDepIdentOutputNonUTXOChainID gets returned when a TransDepIdentOutput has a ChainID which is not a UTXOIDChainID. - ErrTransDepIdentOutputNonUTXOChainID = ierrors.New("transition dependable ident outputs must have UTXO chain IDs") - // ErrTransDepIdentOutputNextInvalid gets returned when a TransDepIdentOutput's next state is invalid. - ErrTransDepIdentOutputNextInvalid = ierrors.New("transition dependable ident output's next output is invalid") + // ErrOwnerTransitionDependentOutputNonUTXOChainID gets returned when a OwnerTransitionDependentOutput has a ChainID which is not a UTXOIDChainID. + ErrOwnerTransitionDependentOutputNonUTXOChainID = ierrors.New("owner transition dependent outputs must have UTXO chain IDs") + // ErrOwnerTransitionDependentOutputNextInvalid gets returned when a OwnerTransitionDependentOutput's next state is invalid. + ErrOwnerTransitionDependentOutputNextInvalid = ierrors.New("owner transition dependent output's next output is invalid") // ErrArrayValidationOrderViolatesLexicalOrder gets returned if the array elements are not in lexical order. ErrArrayValidationOrderViolatesLexicalOrder = ierrors.New("array elements must be in their lexical order") // ErrArrayValidationViolatesUniqueness gets returned if the array elements are not unique. @@ -277,24 +277,24 @@ func (outputs Outputs[T]) NativeTokenSum() (NativeTokenSum, error) { } // This is a helper function to check if an output is unlockable by a given target. -func outputUnlockableBy(output Output, next TransDepIdentOutput, target Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) (bool, error) { +func outputUnlockableBy(output Output, next OwnerTransitionDependentOutput, target Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) (bool, error) { unlockConds := output.UnlockConditionSet() - var ownerIdent Address + var owner Address switch x := output.(type) { - case TransIndepIdentOutput: - ownerIdent = x.Ident() - case TransDepIdentOutput: - targetToUnlock, err := x.Ident(next) + case OwnerTransitionIndependentOutput: + owner = x.Owner() + case OwnerTransitionDependentOutput: + targetToUnlock, err := x.Owner(next) if err != nil { return false, err } - ownerIdent = targetToUnlock + owner = targetToUnlock default: panic("invalid output type in outputUnlockableBy") } - targetIdentCanUnlock := unlockConds.unlockableBy(target, ownerIdent, pastBoundedSlotIndex, futureBoundedSlotIndex) - if !targetIdentCanUnlock { + targetAddrCanUnlock := unlockConds.unlockableBy(target, owner, pastBoundedSlotIndex, futureBoundedSlotIndex) + if !targetAddrCanUnlock { return false, nil } @@ -320,30 +320,30 @@ func PotentialMana(manaDecayProvider *ManaDecayProvider, storageScoreStructure * return manaDecayProvider.GenerateManaAndDecayBySlots(excessBaseTokens, creationSlot, targetSlot) } -// TransIndepIdentOutput is a type of Output where the identity to unlock is independent +// OwnerTransitionIndependentOutput is a type of Output where the address to unlock is independent // of any transition the output does (without considering Feature(s)). -type TransIndepIdentOutput interface { +type OwnerTransitionIndependentOutput interface { Output - // Ident returns the default identity to which this output is locked to. - Ident() Address - // UnlockableBy tells whether the given ident can unlock this Output + // Owner returns the default address to which this output is locked to. + Owner() Address + // UnlockableBy tells whether the given address can unlock this Output // while also taking into consideration constraints enforced by UnlockConditions(s) within this Output (if any). - UnlockableBy(ident Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool + UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool } -// TransDepIdentOutput is a type of Output where the identity to unlock is dependent +// OwnerTransitionDependentOutput is a type of Output where the address to unlock is dependent // on the transition the output does (without considering UnlockConditions(s)). -type TransDepIdentOutput interface { +type OwnerTransitionDependentOutput interface { ChainOutput - // Ident computes the identity to which this output is locked to by examining - // the transition to the next output state. If next is nil, then this TransDepIdentOutput - // treats the ident computation as being for ChainTransitionTypeDestroy. - Ident(next TransDepIdentOutput) (Address, error) - // UnlockableBy tells whether the given ident can unlock this Output + // Owner computes the address to which this output is locked to by examining + // the transition to the next output state. If next is nil, then this OwnerTransitionDependentOutput + // treats the owner computation as being for ChainTransitionTypeDestroy. + Owner(next OwnerTransitionDependentOutput) (Address, error) + // UnlockableBy tells whether the given address can unlock this Output // while also taking into consideration constraints enforced by UnlockConditions(s) within this Output - // and the next state of this TransDepIdentOutput. To indicate that this TransDepIdentOutput + // and the next state of this OwnerTransitionDependentOutput. To indicate that this OwnerTransitionDependentOutput // is to be destroyed, pass nil as next. - UnlockableBy(ident Address, next TransDepIdentOutput, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) (bool, error) + UnlockableBy(addr Address, next OwnerTransitionDependentOutput, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) (bool, error) } // OutputsSyntacticalDepositAmount returns an ElementValidationFunc[Output] which checks that: @@ -472,7 +472,7 @@ func OutputsSyntacticalAccount() ElementValidationFunc[Output] { } } - if addr, ok := accountOutput.Ident().(*AccountAddress); ok && AccountAddress(accountOutput.AccountID) == *addr { + if addr, ok := accountOutput.Owner().(*AccountAddress); ok && AccountAddress(accountOutput.AccountID) == *addr { return ierrors.WithMessagef(ErrAccountOutputCyclicAddress, "output %d", index) } @@ -564,7 +564,7 @@ func OutputsSyntacticalNFT() ElementValidationFunc[Output] { return nil } - if addr, ok := nftOutput.Ident().(*NFTAddress); ok && NFTAddress(nftOutput.NFTID) == *addr { + if addr, ok := nftOutput.Owner().(*NFTAddress); ok && NFTAddress(nftOutput.NFTID) == *addr { return ierrors.WithMessagef(ErrNFTOutputCyclicAddress, "output %d", index) } diff --git a/output_account.go b/output_account.go index 6aa4e5ce8..f13a2d757 100644 --- a/output_account.go +++ b/output_account.go @@ -94,8 +94,8 @@ func (a *AccountOutput) Equal(other Output) bool { return true } -func (a *AccountOutput) UnlockableBy(ident Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool { - ok, _ := outputUnlockableBy(a, nil, ident, pastBoundedSlotIndex, futureBoundedSlotIndex) +func (a *AccountOutput) UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool { + ok, _ := outputUnlockableBy(a, nil, addr, pastBoundedSlotIndex, futureBoundedSlotIndex) return ok } @@ -126,7 +126,7 @@ func (a *AccountOutput) WorkScore(workScoreParameters *WorkScoreParameters) (Wor return workScoreParameters.Output.Add(workScoreConditions, workScoreFeatures, workScoreImmutableFeatures) } -func (a *AccountOutput) Ident() Address { +func (a *AccountOutput) Owner() Address { return a.UnlockConditions.MustSet().Address().Address } diff --git a/output_anchor.go b/output_anchor.go index a92defe47..692cdc28b 100644 --- a/output_anchor.go +++ b/output_anchor.go @@ -98,8 +98,8 @@ func (a *AnchorOutput) Equal(other Output) bool { return true } -func (a *AnchorOutput) UnlockableBy(ident Address, next TransDepIdentOutput, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) (bool, error) { - return outputUnlockableBy(a, next, ident, pastBoundedSlotIndex, futureBoundedSlotIndex) +func (a *AnchorOutput) UnlockableBy(addr Address, next OwnerTransitionDependentOutput, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) (bool, error) { + return outputUnlockableBy(a, next, addr, pastBoundedSlotIndex, futureBoundedSlotIndex) } func (a *AnchorOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore { @@ -129,14 +129,14 @@ func (a *AnchorOutput) WorkScore(workScoreParameters *WorkScoreParameters) (Work return workScoreParameters.Output.Add(workScoreConditions, workScoreFeatures, workScoreImmutableFeatures) } -func (a *AnchorOutput) Ident(nextState TransDepIdentOutput) (Address, error) { +func (a *AnchorOutput) Owner(nextState OwnerTransitionDependentOutput) (Address, error) { // if there isn't a next state, then only the governance address can destroy the anchor if nextState == nil { return a.GovernorAddress(), nil } otherAnchorOutput, isAnchorOutput := nextState.(*AnchorOutput) if !isAnchorOutput { - return nil, ierrors.Wrapf(ErrTransDepIdentOutputNextInvalid, "expected AnchorOutput but got %s for ident computation", nextState.Type()) + return nil, ierrors.Wrapf(ErrOwnerTransitionDependentOutputNextInvalid, "expected AnchorOutput but got %s for owner computation", nextState.Type()) } switch { case a.StateIndex == otherAnchorOutput.StateIndex: @@ -144,7 +144,7 @@ func (a *AnchorOutput) Ident(nextState TransDepIdentOutput) (Address, error) { case a.StateIndex+1 == otherAnchorOutput.StateIndex: return a.StateController(), nil default: - return nil, ierrors.Wrap(ErrTransDepIdentOutputNextInvalid, "can not compute right ident for anchor output as state index delta is invalid") + return nil, ierrors.Wrap(ErrOwnerTransitionDependentOutputNextInvalid, "can not compute right owner for anchor output as state index delta is invalid") } } diff --git a/output_basic.go b/output_basic.go index 7d6dfdb71..67dc592f9 100644 --- a/output_basic.go +++ b/output_basic.go @@ -65,8 +65,8 @@ func (e *BasicOutput) Equal(other Output) bool { return true } -func (e *BasicOutput) UnlockableBy(ident Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool { - ok, _ := outputUnlockableBy(e, nil, ident, pastBoundedSlotIndex, futureBoundedSlotIndex) +func (e *BasicOutput) UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool { + ok, _ := outputUnlockableBy(e, nil, addr, pastBoundedSlotIndex, futureBoundedSlotIndex) return ok } @@ -107,7 +107,7 @@ func (e *BasicOutput) StoredMana() Mana { return e.Mana } -func (e *BasicOutput) Ident() Address { +func (e *BasicOutput) Owner() Address { return e.UnlockConditions.MustSet().Address().Address } diff --git a/output_delegation.go b/output_delegation.go index 229381812..e27ddf42e 100644 --- a/output_delegation.go +++ b/output_delegation.go @@ -166,12 +166,12 @@ func (d *DelegationOutput) Equal(other Output) bool { return true } -func (d *DelegationOutput) Ident() Address { +func (d *DelegationOutput) Owner() Address { return d.UnlockConditions.MustSet().Address().Address } -func (d *DelegationOutput) UnlockableBy(ident Address, pastBoundedSlot SlotIndex, futureBoundedSlot SlotIndex) bool { - ok, _ := outputUnlockableBy(d, nil, ident, pastBoundedSlot, futureBoundedSlot) +func (d *DelegationOutput) UnlockableBy(addr Address, pastBoundedSlot SlotIndex, futureBoundedSlot SlotIndex) bool { + ok, _ := outputUnlockableBy(d, nil, addr, pastBoundedSlot, futureBoundedSlot) return ok } diff --git a/output_foundry.go b/output_foundry.go index 80eafa19b..c556536f6 100644 --- a/output_foundry.go +++ b/output_foundry.go @@ -172,12 +172,12 @@ func (f *FoundryOutput) Equal(other Output) bool { return true } -func (f *FoundryOutput) Ident() Address { +func (f *FoundryOutput) Owner() Address { return f.UnlockConditionSet().ImmutableAccount().Address } -func (f *FoundryOutput) UnlockableBy(ident Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool { - ok, _ := outputUnlockableBy(f, nil, ident, pastBoundedSlotIndex, futureBoundedSlotIndex) +func (f *FoundryOutput) UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool { + ok, _ := outputUnlockableBy(f, nil, addr, pastBoundedSlotIndex, futureBoundedSlotIndex) return ok } @@ -225,7 +225,7 @@ func (f *FoundryOutput) ChainID() ChainID { // FoundryID returns the FoundryID of this FoundryOutput. func (f *FoundryOutput) FoundryID() (FoundryID, error) { - return FoundryIDFromAddressAndSerialNumberAndTokenScheme(f.Ident(), f.SerialNumber, f.TokenScheme.Type()) + return FoundryIDFromAddressAndSerialNumberAndTokenScheme(f.Owner(), f.SerialNumber, f.TokenScheme.Type()) } // MustFoundryID works like FoundryID but panics if an error occurs. diff --git a/output_id_proof_test.go b/output_id_proof_test.go index 853ec4510..79c4de15c 100644 --- a/output_id_proof_test.go +++ b/output_id_proof_test.go @@ -17,7 +17,7 @@ type outputIDProofTest struct { } func TestOutputIDProof(t *testing.T) { - ident1 := tpkg.RandEd25519Address() + addr1 := tpkg.RandEd25519Address() inputIDs := tpkg.RandOutputIDs(1) @@ -36,7 +36,7 @@ func TestOutputIDProof(t *testing.T) { return &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, } }), @@ -56,7 +56,7 @@ func TestOutputIDProof(t *testing.T) { return &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, } }), @@ -76,7 +76,7 @@ func TestOutputIDProof(t *testing.T) { return &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, } }), @@ -96,7 +96,7 @@ func TestOutputIDProof(t *testing.T) { return &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, } }), diff --git a/output_nft.go b/output_nft.go index e3bde2df8..f480d73be 100644 --- a/output_nft.go +++ b/output_nft.go @@ -152,12 +152,12 @@ func (n *NFTOutput) Equal(other Output) bool { return true } -func (n *NFTOutput) Ident() Address { +func (n *NFTOutput) Owner() Address { return n.UnlockConditions.MustSet().Address().Address } -func (n *NFTOutput) UnlockableBy(ident Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool { - ok, _ := outputUnlockableBy(n, nil, ident, pastBoundedSlotIndex, futureBoundedSlotIndex) +func (n *NFTOutput) UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool { + ok, _ := outputUnlockableBy(n, nil, addr, pastBoundedSlotIndex, futureBoundedSlotIndex) return ok } diff --git a/output_test.go b/output_test.go index 02b5af589..5d357c5fc 100644 --- a/output_test.go +++ b/output_test.go @@ -953,11 +953,11 @@ func TestOutputsSyntacticaDelegation(t *testing.T) { } } -func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { +func TestOwnerTransitionIndependentOutput_UnlockableBy(t *testing.T) { type test struct { name string - output iotago.TransIndepIdentOutput - targetIdent iotago.Address + output iotago.OwnerTransitionIndependentOutput + targetAddr iotago.Address commitmentInputTime iotago.SlotIndex minCommittableAge iotago.SlotIndex maxCommittableAge iotago.SlotIndex @@ -965,16 +965,16 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { } tests := []*test{ func() *test { - receiverIdent := tpkg.RandEd25519Address() + receiverAddr := tpkg.RandEd25519Address() return &test{ name: "can unlock - target is source (no unlock conditions)", output: &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: receiverIdent}, + &iotago.AddressUnlockCondition{Address: receiverAddr}, }, }, - targetIdent: receiverIdent, + targetAddr: receiverAddr, commitmentInputTime: iotago.SlotIndex(0), minCommittableAge: iotago.SlotIndex(0), maxCommittableAge: iotago.SlotIndex(0), @@ -990,7 +990,7 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { &iotago.AddressUnlockCondition{Address: tpkg.RandEd25519Address()}, }, }, - targetIdent: tpkg.RandEd25519Address(), + targetAddr: tpkg.RandEd25519Address(), commitmentInputTime: iotago.SlotIndex(0), minCommittableAge: iotago.SlotIndex(0), maxCommittableAge: iotago.SlotIndex(0), @@ -998,20 +998,20 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { } }(), func() *test { - receiverIdent := tpkg.RandEd25519Address() + receiverAddr := tpkg.RandEd25519Address() return &test{ - name: "expiration - receiver ident can unlock", + name: "expiration - receiver addr can unlock", output: &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: receiverIdent}, + &iotago.AddressUnlockCondition{Address: receiverAddr}, &iotago.ExpirationUnlockCondition{ ReturnAddress: tpkg.RandEd25519Address(), Slot: 26, }, }, }, - targetIdent: receiverIdent, + targetAddr: receiverAddr, commitmentInputTime: iotago.SlotIndex(5), minCommittableAge: iotago.SlotIndex(10), maxCommittableAge: iotago.SlotIndex(20), @@ -1019,21 +1019,21 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { } }(), func() *test { - receiverIdent := tpkg.RandEd25519Address() - returnIdent := tpkg.RandEd25519Address() + receiverAddr := tpkg.RandEd25519Address() + returnAddr := tpkg.RandEd25519Address() return &test{ - name: "expiration - receiver ident can not unlock", + name: "expiration - receiver addr can not unlock", output: &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: receiverIdent}, + &iotago.AddressUnlockCondition{Address: receiverAddr}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: returnIdent, + ReturnAddress: returnAddr, Slot: 25, }, }, }, - targetIdent: receiverIdent, + targetAddr: receiverAddr, commitmentInputTime: iotago.SlotIndex(5), minCommittableAge: iotago.SlotIndex(10), maxCommittableAge: iotago.SlotIndex(20), @@ -1041,21 +1041,21 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { } }(), func() *test { - receiverIdent := tpkg.RandEd25519Address() - returnIdent := tpkg.RandEd25519Address() + receiverAddr := tpkg.RandEd25519Address() + returnAddr := tpkg.RandEd25519Address() return &test{ - name: "expiration - return ident can unlock", + name: "expiration - return addr can unlock", output: &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: receiverIdent}, + &iotago.AddressUnlockCondition{Address: receiverAddr}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: returnIdent, + ReturnAddress: returnAddr, Slot: 15, }, }, }, - targetIdent: returnIdent, + targetAddr: returnAddr, commitmentInputTime: iotago.SlotIndex(5), minCommittableAge: iotago.SlotIndex(10), maxCommittableAge: iotago.SlotIndex(20), @@ -1063,21 +1063,21 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { } }(), func() *test { - receiverIdent := tpkg.RandEd25519Address() - returnIdent := tpkg.RandEd25519Address() + receiverAddr := tpkg.RandEd25519Address() + returnAddr := tpkg.RandEd25519Address() return &test{ - name: "expiration - return ident can not unlock", + name: "expiration - return addr can not unlock", output: &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: receiverIdent}, + &iotago.AddressUnlockCondition{Address: receiverAddr}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: returnIdent, + ReturnAddress: returnAddr, Slot: 16, }, }, }, - targetIdent: returnIdent, + targetAddr: returnAddr, commitmentInputTime: iotago.SlotIndex(5), minCommittableAge: iotago.SlotIndex(10), maxCommittableAge: iotago.SlotIndex(20), @@ -1085,17 +1085,17 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { } }(), func() *test { - receiverIdent := tpkg.RandEd25519Address() + receiverAddr := tpkg.RandEd25519Address() return &test{ name: "timelock - expired timelock is unlockable", output: &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: receiverIdent}, + &iotago.AddressUnlockCondition{Address: receiverAddr}, &iotago.TimelockUnlockCondition{Slot: 15}, }, }, - targetIdent: receiverIdent, + targetAddr: receiverAddr, commitmentInputTime: iotago.SlotIndex(5), minCommittableAge: iotago.SlotIndex(10), maxCommittableAge: iotago.SlotIndex(20), @@ -1103,17 +1103,17 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { } }(), func() *test { - receiverIdent := tpkg.RandEd25519Address() + receiverAddr := tpkg.RandEd25519Address() return &test{ name: "timelock - non-expired timelock is not unlockable", output: &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: receiverIdent}, + &iotago.AddressUnlockCondition{Address: receiverAddr}, &iotago.TimelockUnlockCondition{Slot: 16}, }, }, - targetIdent: receiverIdent, + targetAddr: receiverAddr, commitmentInputTime: iotago.SlotIndex(5), minCommittableAge: iotago.SlotIndex(10), maxCommittableAge: iotago.SlotIndex(20), @@ -1125,7 +1125,7 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.canUnlock, tt.output.UnlockableBy(tt.targetIdent, tt.commitmentInputTime+tt.maxCommittableAge, tt.commitmentInputTime+tt.minCommittableAge)) + require.Equal(t, tt.canUnlock, tt.output.UnlockableBy(tt.targetAddr, tt.commitmentInputTime+tt.maxCommittableAge, tt.commitmentInputTime+tt.minCommittableAge)) }) }) } @@ -1133,16 +1133,16 @@ func TestTransIndepIdentOutput_UnlockableBy(t *testing.T) { func TestAnchorOutput_UnlockableBy(t *testing.T) { type test struct { - name string - current iotago.TransDepIdentOutput - next iotago.TransDepIdentOutput - targetIdent iotago.Address - identCanUnlockInstead iotago.Address - commitmentInputTime iotago.SlotIndex - minCommittableAge iotago.SlotIndex - maxCommittableAge iotago.SlotIndex - wantErr error - canUnlock bool + name string + current iotago.OwnerTransitionDependentOutput + next iotago.OwnerTransitionDependentOutput + targetAddr iotago.Address + addrCanUnlockInstead iotago.Address + commitmentInputTime iotago.SlotIndex + minCommittableAge iotago.SlotIndex + maxCommittableAge iotago.SlotIndex + wantErr error + canUnlock bool } tests := []*test{ func() *test { @@ -1167,7 +1167,7 @@ func TestAnchorOutput_UnlockableBy(t *testing.T) { &iotago.GovernorAddressUnlockCondition{Address: govCtrl}, }, }, - targetIdent: stateCtrl, + targetAddr: stateCtrl, commitmentInputTime: iotago.SlotIndex(0), minCommittableAge: iotago.SlotIndex(0), maxCommittableAge: iotago.SlotIndex(0), @@ -1196,12 +1196,12 @@ func TestAnchorOutput_UnlockableBy(t *testing.T) { &iotago.GovernorAddressUnlockCondition{Address: govCtrl}, }, }, - targetIdent: stateCtrl, - identCanUnlockInstead: govCtrl, - commitmentInputTime: iotago.SlotIndex(0), - minCommittableAge: iotago.SlotIndex(0), - maxCommittableAge: iotago.SlotIndex(0), - canUnlock: false, + targetAddr: stateCtrl, + addrCanUnlockInstead: govCtrl, + commitmentInputTime: iotago.SlotIndex(0), + minCommittableAge: iotago.SlotIndex(0), + maxCommittableAge: iotago.SlotIndex(0), + canUnlock: false, } }(), func() *test { @@ -1218,13 +1218,13 @@ func TestAnchorOutput_UnlockableBy(t *testing.T) { &iotago.GovernorAddressUnlockCondition{Address: govCtrl}, }, }, - next: nil, - targetIdent: stateCtrl, - identCanUnlockInstead: govCtrl, - commitmentInputTime: iotago.SlotIndex(0), - minCommittableAge: iotago.SlotIndex(0), - maxCommittableAge: iotago.SlotIndex(0), - canUnlock: false, + next: nil, + targetAddr: stateCtrl, + addrCanUnlockInstead: govCtrl, + commitmentInputTime: iotago.SlotIndex(0), + minCommittableAge: iotago.SlotIndex(0), + maxCommittableAge: iotago.SlotIndex(0), + canUnlock: false, } }(), } @@ -1232,17 +1232,17 @@ func TestAnchorOutput_UnlockableBy(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) { - canUnlock, err := tt.current.UnlockableBy(tt.targetIdent, tt.next, tt.commitmentInputTime+tt.maxCommittableAge, tt.commitmentInputTime+tt.minCommittableAge) + canUnlock, err := tt.current.UnlockableBy(tt.targetAddr, tt.next, tt.commitmentInputTime+tt.maxCommittableAge, tt.commitmentInputTime+tt.minCommittableAge) if tt.wantErr != nil { require.ErrorIs(t, err, tt.wantErr) return } require.Equal(t, tt.canUnlock, canUnlock) - if tt.identCanUnlockInstead == nil { + if tt.addrCanUnlockInstead == nil { return } - canUnlockInstead, err := tt.current.UnlockableBy(tt.identCanUnlockInstead, tt.next, tt.commitmentInputTime+tt.maxCommittableAge, tt.commitmentInputTime+tt.minCommittableAge) + canUnlockInstead, err := tt.current.UnlockableBy(tt.addrCanUnlockInstead, tt.next, tt.commitmentInputTime+tt.maxCommittableAge, tt.commitmentInputTime+tt.minCommittableAge) require.NoError(t, err) require.True(t, canUnlockInstead) }) diff --git a/signed_transaction.go b/signed_transaction.go index 5ef841780..75ef7d794 100644 --- a/signed_transaction.go +++ b/signed_transaction.go @@ -20,9 +20,9 @@ var ( ErrUnknownSignatureType = ierrors.New("unknown signature type") // ErrSignatureAndAddrIncompatible gets returned if an address of an input has a companion signature unlock with the wrong signature type. ErrSignatureAndAddrIncompatible = ierrors.New("address and signature type are not compatible") - // ErrSenderFeatureNotUnlocked gets returned when an output contains a SenderFeature with an ident which is not unlocked. + // ErrSenderFeatureNotUnlocked gets returned when an output contains a SenderFeature with an address which is not unlocked. ErrSenderFeatureNotUnlocked = ierrors.New("sender feature is not unlocked") - // ErrIssuerFeatureNotUnlocked gets returned when an output contains a IssuerFeature with an ident which is not unlocked. + // ErrIssuerFeatureNotUnlocked gets returned when an output contains a IssuerFeature with an address which is not unlocked. ErrIssuerFeatureNotUnlocked = ierrors.New("issuer feature is not unlocked") // ErrReturnAmountNotFulFilled gets returned when a return amount in a transaction is not fulfilled by the output side. ErrReturnAmountNotFulFilled = ierrors.New("return amount not fulfilled") diff --git a/tpkg/rand_ed25519.go b/tpkg/rand_ed25519.go index d7d3cc653..fa3b833a8 100644 --- a/tpkg/rand_ed25519.go +++ b/tpkg/rand_ed25519.go @@ -58,7 +58,7 @@ func RandEd25519Identity() (ed25519.PrivateKey, *iotago.Ed25519Address, iotago.A return edSk, edAddr, addrKeys } -// RandEd25519IdentitiesSortedByAddress returns random Ed25519 identities and keys lexically sorted by the address. +// RandEd25519IdentitiesSortedByAddress returns random Ed25519 addresses and keys lexically sorted by the address. func RandEd25519IdentitiesSortedByAddress(count int) ([]iotago.Address, []iotago.AddressKeys) { addresses := make([]iotago.Address, count) addressKeys := make([]iotago.AddressKeys, count) diff --git a/transaction_test.go b/transaction_test.go index 58c0ad340..7d997de79 100644 --- a/transaction_test.go +++ b/transaction_test.go @@ -30,7 +30,7 @@ func TestTransactionEssence_DeSerialize(t *testing.T) { } func TestChainConstrainedOutputUniqueness(t *testing.T) { - ident1 := tpkg.RandEd25519Address() + addr1 := tpkg.RandEd25519Address() inputIDs := tpkg.RandOutputIDs(1) @@ -62,7 +62,7 @@ func TestChainConstrainedOutputUniqueness(t *testing.T) { Amount: OneIOTA, AccountID: accountID, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -70,7 +70,7 @@ func TestChainConstrainedOutputUniqueness(t *testing.T) { Amount: OneIOTA, AccountID: accountID, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -98,8 +98,8 @@ func TestChainConstrainedOutputUniqueness(t *testing.T) { Amount: OneIOTA, AnchorID: anchorID, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident1}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -107,8 +107,8 @@ func TestChainConstrainedOutputUniqueness(t *testing.T) { Amount: OneIOTA, AnchorID: anchorID, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident1}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -134,7 +134,7 @@ func TestChainConstrainedOutputUniqueness(t *testing.T) { Amount: OneIOTA, NFTID: nftID, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -142,7 +142,7 @@ func TestChainConstrainedOutputUniqueness(t *testing.T) { Amount: OneIOTA, NFTID: nftID, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -168,7 +168,7 @@ func TestChainConstrainedOutputUniqueness(t *testing.T) { Amount: OneIOTA, AccountID: accountID, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -662,9 +662,9 @@ func (test *transactionSerializeTest) ToDeserializeTest() *frameworks.DeSerializ txBuilder.WithTransactionCapabilities( iotago.TransactionCapabilitiesBitMaskWithCapabilities(iotago.WithTransactionCanBurnNativeTokens(true)), ) - _, ident, addrKeys := tpkg.RandEd25519Identity() + _, addr, addrKeys := tpkg.RandEd25519Identity() txBuilder.AddInput(&builder.TxInput{ - UnlockTarget: ident, + UnlockTarget: addr, InputID: tpkg.RandUTXOInput().OutputID(), Input: tpkg.RandBasicOutput(), }) diff --git a/unlock_cond.go b/unlock_cond.go index 3ade6dff2..ad2e1b0b8 100644 --- a/unlock_cond.go +++ b/unlock_cond.go @@ -24,7 +24,7 @@ var ( // ErrExpirationCommitmentInputMissing gets returned when a TX containing an ExpirationUnlockCondition // does not have a commitment input. ErrExpirationCommitmentInputMissing = ierrors.New("transaction's containing an expiration condition require a commitment input") - // ErrExpirationNotUnlockable gets returned when a ExpirationUnlockCondition cannot be unlocked by return ident or the owner. + // ErrExpirationNotUnlockable gets returned when a ExpirationUnlockCondition cannot be unlocked by return address or the owner. ErrExpirationNotUnlockable = ierrors.New("expiration unlock condition cannot be unlocked") ) @@ -212,17 +212,17 @@ func (f UnlockConditionSet) HasExpirationCondition() bool { return f.Expiration() != nil } -// CheckExpirationCondition returns the expiration return ident in case an expiration condition was set and +// CheckExpirationCondition returns the expiration return address in case an expiration condition was set and // the future bound slot is greater than the expiration slot. // In case the past bound slot is smaller than the expiration slot, "nil" is returned to indicate that the original owner can unlock the output. // The range in between is not unlockable by anyone and an "ErrExpirationConditionUnlockFailed" error will be returned. func (f UnlockConditionSet) CheckExpirationCondition(futureBoundedSlotIndex, pastBoundedSlotIndex SlotIndex) (Address, error) { if f.HasExpirationCondition() { - if ok, returnIdent := f.ReturnIdentCanUnlock(futureBoundedSlotIndex); ok { - return returnIdent, nil + if ok, returnAddr := f.ReturnAddressCanUnlock(futureBoundedSlotIndex); ok { + return returnAddr, nil } - if !f.OwnerIdentCanUnlock(pastBoundedSlotIndex) { + if !f.OwnerAddressCanUnlock(pastBoundedSlotIndex) { return nil, ErrExpirationNotUnlockable } } @@ -263,30 +263,30 @@ func (f UnlockConditionSet) HasTimelockUntil(slot SlotIndex) bool { return timelock != nil && slot < timelock.Slot } -// tells whether the given ident can unlock an output containing this set of UnlockCondition(s) -// returns booleans indicating whether the given ident can unlock and whether the return identity can unlock. -func (f UnlockConditionSet) unlockableBy(ident Address, owner Address, pastBoundedSlot SlotIndex, futureBoundedSlot SlotIndex) bool { +// tells whether the given address can unlock an output containing this set of UnlockCondition(s) +// returns booleans indicating whether the given address can unlock and whether the return address can unlock. +func (f UnlockConditionSet) unlockableBy(addr Address, owner Address, pastBoundedSlot SlotIndex, futureBoundedSlot SlotIndex) bool { if err := f.TimelocksExpired(futureBoundedSlot); err != nil { return false } - // if the return ident can unlock, then ident must be the return ident - if returnIdentCanUnlock, returnIdent := f.ReturnIdentCanUnlock(futureBoundedSlot); returnIdentCanUnlock { - return ident.Equal(returnIdent) + // if the return addr can unlock, then addr must be the return address + if returnAddrCanUnlock, returnAddr := f.ReturnAddressCanUnlock(futureBoundedSlot); returnAddrCanUnlock { + return addr.Equal(returnAddr) } // if the past bounded index is less than the expiration slot index, then owner can unlock - if f.OwnerIdentCanUnlock(pastBoundedSlot) { - return ident.Equal(owner) + if f.OwnerAddressCanUnlock(pastBoundedSlot) { + return addr.Equal(owner) } return false } -// OwnerIdentCanUnlock tells whether the target address defined in an expiration unlock condition within this set is +// OwnerAddressCanUnlock tells whether the target address defined in an expiration unlock condition within this set is // allowed to unlock an Output containing this UnlockConditionSet given the past bounded slot index of the tx defined as // the slot index of the commitment input plus the max committable age. -func (f UnlockConditionSet) OwnerIdentCanUnlock(pastBoundedSlot SlotIndex) bool { +func (f UnlockConditionSet) OwnerAddressCanUnlock(pastBoundedSlot SlotIndex) bool { expUnlockCond := f.Expiration() // if there is not expiration unlock, then the owner can unlock. @@ -301,10 +301,10 @@ func (f UnlockConditionSet) OwnerIdentCanUnlock(pastBoundedSlot SlotIndex) bool return false } -// ReturnIdentCanUnlock tells whether a sender defined in an expiration unlock condition within this set is the actual -// identity which could unlock an Output containing this UnlockConditionSet given the future bounded slot index of the tx +// ReturnAddressCanUnlock tells whether a sender defined in an expiration unlock condition within this set is the actual +// address which could unlock an Output containing this UnlockConditionSet given the future bounded slot index of the tx // defined as the slot index of the commitment input plus the min committable age. -func (f UnlockConditionSet) ReturnIdentCanUnlock(futureBoundedSlotIndex SlotIndex) (bool, Address) { +func (f UnlockConditionSet) ReturnAddressCanUnlock(futureBoundedSlotIndex SlotIndex) (bool, Address) { expUnlockCond := f.Expiration() if expUnlockCond == nil { diff --git a/unlock_cond_address.go b/unlock_cond_address.go index 3fac46004..c0fcd9a6a 100644 --- a/unlock_cond_address.go +++ b/unlock_cond_address.go @@ -7,7 +7,7 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// AddressUnlockCondition is an UnlockCondition defining an identity which has to be unlocked. +// AddressUnlockCondition is an UnlockCondition defining an address which has to be unlocked. type AddressUnlockCondition struct { Address Address `serix:""` } diff --git a/unlock_cond_expiration.go b/unlock_cond_expiration.go index accdd7baa..1204b9c67 100644 --- a/unlock_cond_expiration.go +++ b/unlock_cond_expiration.go @@ -6,12 +6,12 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// ExpirationUnlockCondition is an unlock condition which puts a time constraint on whether the receiver or return identity +// ExpirationUnlockCondition is an unlock condition which puts a time constraint on whether the receiver or return address // can consume an output depending on the latest confirmed milestone's timestamp T: -// - only the receiver identity can consume the output, if T is before than the one defined in the condition. -// - only the return identity can consume the output, if T is at the same time or after the one defined in the condition. +// - only the receiver address can consume the output, if T is before than the one defined in the condition. +// - only the return address can consume the output, if T is at the same time or after the one defined in the condition. type ExpirationUnlockCondition struct { - // The identity who is allowed to use the output after the expiration has happened. + // The address who is allowed to use the output after the expiration has happened. ReturnAddress Address `serix:""` // The slot index at which the expiration happens. Slot SlotIndex `serix:""` diff --git a/unlock_cond_governor.go b/unlock_cond_governor.go index 7b724ba56..658f3f77d 100644 --- a/unlock_cond_governor.go +++ b/unlock_cond_governor.go @@ -7,7 +7,7 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// GovernorAddressUnlockCondition is an UnlockCondition defining the governor identity for an AccountOutput. +// GovernorAddressUnlockCondition is an UnlockCondition defining the governor address for an AccountOutput. type GovernorAddressUnlockCondition struct { Address Address `serix:""` } diff --git a/unlock_cond_state_ctrl.go b/unlock_cond_state_ctrl.go index e2d80ad5e..2a58f8292 100644 --- a/unlock_cond_state_ctrl.go +++ b/unlock_cond_state_ctrl.go @@ -7,7 +7,7 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// StateControllerAddressUnlockCondition is an UnlockCondition defining the state controller identity for an AccountOutput. +// StateControllerAddressUnlockCondition is an UnlockCondition defining the state controller address for an AccountOutput. type StateControllerAddressUnlockCondition struct { Address Address `serix:""` } diff --git a/unlock_cond_storage_return.go b/unlock_cond_storage_return.go index e1cac1ee6..f7e57b2df 100644 --- a/unlock_cond_storage_return.go +++ b/unlock_cond_storage_return.go @@ -7,9 +7,9 @@ import ( ) // StorageDepositReturnUnlockCondition is an unlock condition which defines -// the amount of tokens which must be sent back to the return identity, when the output in which it occurs in, is consumed. +// the amount of tokens which must be sent back to the return address, when the output in which it occurs in, is consumed. // If a transaction consumes multiple outputs which have a StorageDepositReturnUnlockCondition, then on the output side at least -// the sum of all occurring StorageDepositReturnUnlockCondition(s) on the input side must be deposited to the designated return identity. +// the sum of all occurring StorageDepositReturnUnlockCondition(s) on the input side must be deposited to the designated return address. type StorageDepositReturnUnlockCondition struct { ReturnAddress Address `serix:""` Amount BaseToken `serix:""` diff --git a/vm/nova/stvf_test.go b/vm/nova/stvf_test.go index 00bc798c8..a531f433a 100644 --- a/vm/nova/stvf_test.go +++ b/vm/nova/stvf_test.go @@ -95,7 +95,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -133,7 +133,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 900, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -173,7 +173,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 10001, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -213,7 +213,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 991, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -253,7 +253,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -294,7 +294,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -335,7 +335,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -375,7 +375,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -435,7 +435,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -488,7 +488,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -539,7 +539,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -585,7 +585,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -641,7 +641,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -701,7 +701,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -761,7 +761,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -823,7 +823,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -877,7 +877,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -937,7 +937,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -997,7 +997,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -1060,7 +1060,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -1111,7 +1111,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: currentSlot, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -1144,7 +1144,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -1182,7 +1182,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 1001, }, - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -1224,7 +1224,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 1001, }, - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -1262,7 +1262,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 1000, }, - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -1301,7 +1301,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 1001, }, - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ exampleAccountID: 0, }, @@ -1351,7 +1351,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 999, }, - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ exampleAccountID: 0, }, @@ -1401,7 +1401,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 1001, }, - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ exampleAccountID: 0, }, @@ -1451,7 +1451,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, Commitment: &iotago.Commitment{ @@ -1535,7 +1535,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 990, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ @@ -1588,7 +1588,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -1640,7 +1640,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 990, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ @@ -1698,7 +1698,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 990, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ @@ -1757,7 +1757,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 900, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ @@ -1815,7 +1815,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 900, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, @@ -1871,7 +1871,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 900, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ @@ -1930,7 +1930,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Commitment: &iotago.Commitment{ Slot: 0, }, - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleAddress.Key(): {UnlockedAt: 0}, }, InChains: map[iotago.ChainID]*vm.ChainOutputWithIDs{ @@ -2000,8 +2000,8 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, - InChains: vm.ChainInputSet{}, + UnlockedAddrs: vm.UnlockedAddresses{}, + InChains: vm.ChainInputSet{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -2084,7 +2084,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -2114,7 +2114,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -2162,7 +2162,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleGovCtrl.Key(): {UnlockedAt: 0}, }, Commitment: &iotago.Commitment{ @@ -2215,7 +2215,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleStateCtrl.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -2262,7 +2262,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleStateCtrl.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -2307,7 +2307,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleStateCtrl.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -2358,7 +2358,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ Capabilities: iotago.TransactionCapabilitiesBitMaskWithCapabilities(iotago.WithTransactionCanDoAnything()), @@ -2420,8 +2420,8 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, - InChains: vm.ChainInputSet{}, + UnlockedAddrs: vm.UnlockedAddresses{}, + InChains: vm.ChainInputSet{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -2469,7 +2469,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { } func TestFoundryOutput_ValidateStateTransition(t *testing.T) { - exampleAccountIdent := tpkg.RandAccountAddress() + exampleAccountAddr := tpkg.RandAccountAddress() startingSupply := new(big.Int).SetUint64(100) exampleFoundry := &iotago.FoundryOutput{ @@ -2481,7 +2481,7 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { MaximumSupply: new(big.Int).SetUint64(1000), }, UnlockConditions: iotago.FoundryOutputUnlockConditions{ - &iotago.ImmutableAccountUnlockCondition{Address: exampleAccountIdent}, + &iotago.ImmutableAccountUnlockCondition{Address: exampleAccountAddr}, }, } @@ -2494,7 +2494,7 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { MaximumSupply: new(big.Int).SetUint64(1000), }, UnlockConditions: iotago.FoundryOutputUnlockConditions{ - &iotago.ImmutableAccountUnlockCondition{Address: exampleAccountIdent}, + &iotago.ImmutableAccountUnlockCondition{Address: exampleAccountAddr}, }, } @@ -2516,7 +2516,7 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { transType: iotago.ChainTransitionTypeGenesis, svCtx: &vm.Params{ WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -2525,14 +2525,14 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { Outputs: iotago.TxEssenceOutputs{exampleFoundry}, }, InChains: vm.ChainInputSet{ - exampleAccountIdent.AccountID(): &vm.ChainOutputWithIDs{ - ChainID: exampleAccountIdent.AccountID(), + exampleAccountAddr.AccountID(): &vm.ChainOutputWithIDs{ + ChainID: exampleAccountAddr.AccountID(), OutputID: tpkg.RandOutputIDWithCreationSlot(0, 0), Output: &iotago.AccountOutput{FoundryCounter: 5}, }, }, OutChains: map[iotago.ChainID]iotago.ChainOutput{ - exampleAccountIdent.AccountID(): &iotago.AccountOutput{FoundryCounter: 6}, + exampleAccountAddr.AccountID(): &iotago.AccountOutput{FoundryCounter: 6}, }, OutNativeTokens: map[iotago.NativeTokenID]*big.Int{ exampleFoundry.MustNativeTokenID(): startingSupply, @@ -2548,7 +2548,7 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { transType: iotago.ChainTransitionTypeGenesis, svCtx: &vm.Params{ WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -2557,14 +2557,14 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { Outputs: iotago.TxEssenceOutputs{exampleFoundry}, }, InChains: vm.ChainInputSet{ - exampleAccountIdent.AccountID(): &vm.ChainOutputWithIDs{ - ChainID: exampleAccountIdent.AccountID(), + exampleAccountAddr.AccountID(): &vm.ChainOutputWithIDs{ + ChainID: exampleAccountAddr.AccountID(), OutputID: tpkg.RandOutputIDWithCreationSlot(0, 0), Output: &iotago.AccountOutput{FoundryCounter: 5}, }, }, OutChains: map[iotago.ChainID]iotago.ChainOutput{ - exampleAccountIdent.AccountID(): &iotago.AccountOutput{FoundryCounter: 6}, + exampleAccountAddr.AccountID(): &iotago.AccountOutput{FoundryCounter: 6}, }, OutNativeTokens: map[iotago.NativeTokenID]*big.Int{ // absent but should be there @@ -2580,7 +2580,7 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { transType: iotago.ChainTransitionTypeGenesis, svCtx: &vm.Params{ WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -2589,14 +2589,14 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { Outputs: iotago.TxEssenceOutputs{exampleFoundry}, }, InChains: vm.ChainInputSet{ - exampleAccountIdent.AccountID(): &vm.ChainOutputWithIDs{ - ChainID: exampleAccountIdent.AccountID(), + exampleAccountAddr.AccountID(): &vm.ChainOutputWithIDs{ + ChainID: exampleAccountAddr.AccountID(), OutputID: tpkg.RandOutputIDWithCreationSlot(0, 0), Output: &iotago.AccountOutput{FoundryCounter: 6}, }, }, OutChains: map[iotago.ChainID]iotago.ChainOutput{ - exampleAccountIdent.AccountID(): &iotago.AccountOutput{FoundryCounter: 7}, + exampleAccountAddr.AccountID(): &iotago.AccountOutput{FoundryCounter: 7}, }, OutNativeTokens: map[iotago.NativeTokenID]*big.Int{ exampleFoundry.MustNativeTokenID(): startingSupply, @@ -2612,7 +2612,7 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { transType: iotago.ChainTransitionTypeGenesis, svCtx: &vm.Params{ WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, TransactionEssence: &iotago.TransactionEssence{ @@ -2629,21 +2629,21 @@ func TestFoundryOutput_ValidateStateTransition(t *testing.T) { MaximumSupply: new(big.Int).SetUint64(1000), }, UnlockConditions: iotago.FoundryOutputUnlockConditions{ - &iotago.ImmutableAccountUnlockCondition{Address: exampleAccountIdent}, + &iotago.ImmutableAccountUnlockCondition{Address: exampleAccountAddr}, }, }, exampleFoundry, }, }, InChains: vm.ChainInputSet{ - exampleAccountIdent.AccountID(): &vm.ChainOutputWithIDs{ - ChainID: exampleAccountIdent.AccountID(), + exampleAccountAddr.AccountID(): &vm.ChainOutputWithIDs{ + ChainID: exampleAccountAddr.AccountID(), OutputID: tpkg.RandOutputIDWithCreationSlot(0, 0), Output: &iotago.AccountOutput{FoundryCounter: 5}, }, }, OutChains: map[iotago.ChainID]iotago.ChainOutput{ - exampleAccountIdent.AccountID(): &iotago.AccountOutput{FoundryCounter: 7}, + exampleAccountAddr.AccountID(): &iotago.AccountOutput{FoundryCounter: 7}, }, OutNativeTokens: map[iotago.NativeTokenID]*big.Int{ exampleFoundry.MustNativeTokenID(): startingSupply, @@ -3033,7 +3033,7 @@ func TestNFTOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, Tx: &iotago.Transaction{ @@ -3056,7 +3056,7 @@ func TestNFTOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ Capabilities: iotago.TransactionCapabilitiesBitMaskWithCapabilities(iotago.WithTransactionCanDoAnything()), @@ -3086,7 +3086,7 @@ func TestNFTOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ Capabilities: iotago.TransactionCapabilitiesBitMaskWithCapabilities(iotago.WithTransactionCanDoAnything()), @@ -3118,7 +3118,7 @@ func TestNFTOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ Capabilities: iotago.TransactionCapabilitiesBitMaskWithCapabilities(iotago.WithTransactionCanDoAnything()), @@ -3206,7 +3206,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3237,7 +3237,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3268,7 +3268,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3299,7 +3299,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3329,7 +3329,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3363,7 +3363,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3415,7 +3415,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3459,7 +3459,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3503,7 +3503,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochEndCommitmentIndex, }, @@ -3538,7 +3538,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3576,7 +3576,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3614,7 +3614,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Commitment: &iotago.Commitment{ Slot: epochStartCommitmentIndex, }, @@ -3644,7 +3644,7 @@ func TestDelegationOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{}, + UnlockedAddrs: vm.UnlockedAddresses{}, Rewards: map[iotago.ChainID]iotago.Mana{ exampleDelegationID: 0, }, @@ -3750,7 +3750,7 @@ func TestImplicitAccountOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, BIC: exampleBIC, @@ -3795,7 +3795,7 @@ func TestImplicitAccountOutput_ValidateStateTransition(t *testing.T) { svCtx: &vm.Params{ API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ - UnlockedIdents: vm.UnlockedIdentities{ + UnlockedAddrs: vm.UnlockedAddresses{ exampleIssuer.Key(): {UnlockedAt: 0}, }, BIC: exampleBIC, diff --git a/vm/nova/vm.go b/vm/nova/vm.go index 576e8ab0d..4b704404c 100644 --- a/vm/nova/vm.go +++ b/vm/nova/vm.go @@ -33,7 +33,7 @@ func NewVMParamsWorkingSet(api iotago.API, t *iotago.Transaction, resolvedInputs utxoInputsSet := constructInputSet(resolvedInputs.InputSet) workingSet := &vm.WorkingSet{} workingSet.Tx = t - workingSet.UnlockedIdents = make(vm.UnlockedIdentities) + workingSet.UnlockedAddrs = make(vm.UnlockedAddresses) workingSet.UTXOInputsSet = utxoInputsSet workingSet.InputIDToIndex = make(map[iotago.OutputID]uint16) for inputIndex, inputRef := range workingSet.Tx.TransactionEssence.Inputs { @@ -104,11 +104,11 @@ func constructInputSet(inputSet vm.InputSet) vm.InputSet { return utxoInputsSet } -func (novaVM *virtualMachine) ValidateUnlocks(signedTransaction *iotago.SignedTransaction, inputs vm.ResolvedInputs) (unlockedIdentities vm.UnlockedIdentities, err error) { +func (novaVM *virtualMachine) ValidateUnlocks(signedTransaction *iotago.SignedTransaction, inputs vm.ResolvedInputs) (unlockedAddrs vm.UnlockedAddresses, err error) { return vm.ValidateUnlocks(signedTransaction, inputs) } -func (novaVM *virtualMachine) Execute(transaction *iotago.Transaction, resolvedInputs vm.ResolvedInputs, unlockedIdentities vm.UnlockedIdentities, execFunctions ...vm.ExecFunc) (outputs []iotago.Output, err error) { +func (novaVM *virtualMachine) Execute(transaction *iotago.Transaction, resolvedInputs vm.ResolvedInputs, unlockedAddrs vm.UnlockedAddresses, execFunctions ...vm.ExecFunc) (outputs []iotago.Output, err error) { vmParams := &vm.Params{ API: transaction.API, } @@ -116,7 +116,7 @@ func (novaVM *virtualMachine) Execute(transaction *iotago.Transaction, resolvedI if vmParams.WorkingSet, err = NewVMParamsWorkingSet(vmParams.API, transaction, resolvedInputs); err != nil { return nil, ierrors.Wrap(err, "failed to create working set") } - vmParams.WorkingSet.UnlockedIdents = unlockedIdentities + vmParams.WorkingSet.UnlockedAddrs = unlockedAddrs if len(execFunctions) == 0 { execFunctions = novaVM.execList @@ -310,7 +310,7 @@ func accountGenesisValid(vmParams *vm.Params, next *iotago.AccountOutput, accoun } } - return vm.IsIssuerOnOutputUnlocked(next, vmParams.WorkingSet.UnlockedIdents) + return vm.IsIssuerOnOutputUnlocked(next, vmParams.WorkingSet.UnlockedAddrs) } func accountStateChangeValid(vmParams *vm.Params, input *vm.ChainOutputWithIDs, next *iotago.AccountOutput, isRemovingStakingFeature *bool) error { @@ -591,7 +591,7 @@ func accountFoundryCounterSTVF(vmParams *vm.Params, current *iotago.AccountOutpu } //nolint:forcetypeassert // we can safely assume that this is an AccountAddress - foundryAccountID := foundryOutput.Ident().(*iotago.AccountAddress).ChainID() + foundryAccountID := foundryOutput.Owner().(*iotago.AccountAddress).ChainID() if !foundryAccountID.Matches(next.AccountID) { continue } @@ -716,7 +716,7 @@ func anchorGenesisValid(vmParams *vm.Params, current *iotago.AnchorOutput, ancho return ierrors.Join(iotago.ErrAnchorInvalidStateTransition, iotago.ErrNewChainOutputHasNonZeroedID) } - return vm.IsIssuerOnOutputUnlocked(current, vmParams.WorkingSet.UnlockedIdents) + return vm.IsIssuerOnOutputUnlocked(current, vmParams.WorkingSet.UnlockedAddrs) } func anchorStateChangeValid(input *vm.ChainOutputWithIDs, next *iotago.AnchorOutput) error { @@ -825,7 +825,7 @@ func foundryGenesisValid(vmParams *vm.Params, current *iotago.FoundryOutput, thi // grab foundry counter from transitioning AccountOutput //nolint:forcetypeassert // we can safely assume that this is an AccountAddress - accountID := current.Ident().(*iotago.AccountAddress).AccountID() + accountID := current.Owner().(*iotago.AccountAddress).AccountID() inAccount, ok := vmParams.WorkingSet.InChains[accountID] if !ok { return ierrors.Join(iotago.ErrInvalidFoundryStateTransition, @@ -866,7 +866,7 @@ func foundrySerialNumberValid(vmParams *vm.Params, current *iotago.FoundryOutput continue } - if !otherFoundryOutput.Ident().Equal(current.Ident()) { + if !otherFoundryOutput.Owner().Equal(current.Owner()) { continue } @@ -958,7 +958,7 @@ func nftGenesisValid(vmParams *vm.Params, current *iotago.NFTOutput) error { return ierrors.Join(iotago.ErrInvalidNFTStateTransition, iotago.ErrNewChainOutputHasNonZeroedID) } - return vm.IsIssuerOnOutputUnlocked(current, vmParams.WorkingSet.UnlockedIdents) + return vm.IsIssuerOnOutputUnlocked(current, vmParams.WorkingSet.UnlockedAddrs) } func nftStateChangeValid(current *iotago.NFTOutput, next *iotago.NFTOutput) error { diff --git a/vm/nova/vm_test.go b/vm/nova/vm_test.go index 3164b1d17..ca5fedcd5 100644 --- a/vm/nova/vm_test.go +++ b/vm/nova/vm_test.go @@ -32,7 +32,7 @@ var ( ) func TestNFTTransition(t *testing.T) { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ @@ -40,7 +40,7 @@ func TestNFTTransition(t *testing.T) { Amount: OneIOTA, NFTID: iotago.NFTID{}, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -60,14 +60,14 @@ func TestNFTTransition(t *testing.T) { Amount: OneIOTA, NFTID: nftID, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) tx := &iotago.SignedTransaction{ @@ -82,23 +82,23 @@ func TestNFTTransition(t *testing.T) { } func TestCirculatingSupplyMelting(t *testing.T) { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - accountIdent1 := tpkg.RandAccountAddress() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + accountaddr1 := tpkg.RandAccountAddress() inputIDs := tpkg.RandOutputIDs(3) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: OneIOTA, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: &iotago.AccountOutput{ Amount: OneIOTA, - AccountID: accountIdent1.AccountID(), + AccountID: accountaddr1.AccountID(), FoundryCounter: 1, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -111,7 +111,7 @@ func TestCirculatingSupplyMelting(t *testing.T) { MaximumSupply: big.NewInt(50), }, UnlockConditions: iotago.FoundryOutputUnlockConditions{ - &iotago.ImmutableAccountUnlockCondition{Address: accountIdent1}, + &iotago.ImmutableAccountUnlockCondition{Address: accountaddr1}, }, Features: nil, }, @@ -133,10 +133,10 @@ func TestCirculatingSupplyMelting(t *testing.T) { Outputs: iotago.TxEssenceOutputs{ &iotago.AccountOutput{ Amount: OneIOTA, - AccountID: accountIdent1.AccountID(), + AccountID: accountaddr1.AccountID(), FoundryCounter: 1, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: nil, }, @@ -149,14 +149,14 @@ func TestCirculatingSupplyMelting(t *testing.T) { MaximumSupply: big.NewInt(50), }, UnlockConditions: iotago.FoundryOutputUnlockConditions{ - &iotago.ImmutableAccountUnlockCondition{Address: accountIdent1}, + &iotago.ImmutableAccountUnlockCondition{Address: accountaddr1}, }, Features: nil, }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) tx := &iotago.SignedTransaction{ @@ -184,11 +184,11 @@ func TestNovaTransactionExecution(t *testing.T) { // ok func() *test { var ( - _, ident1, ident1AddrKeys = tpkg.RandEd25519Identity() - _, ident2, ident2AddrKeys = tpkg.RandEd25519Identity() - _, ident3, ident3AddrKeys = tpkg.RandEd25519Identity() - _, ident4, ident4AddrKeys = tpkg.RandEd25519Identity() - _, ident5, _ = tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys = tpkg.RandEd25519Identity() + _, addr2, addr2AddrKeys = tpkg.RandEd25519Identity() + _, addr3, addr3AddrKeys = tpkg.RandEd25519Identity() + _, addr4, addr4AddrKeys = tpkg.RandEd25519Identity() + _, addr5, _ = tpkg.RandEd25519Identity() ) var ( @@ -224,151 +224,151 @@ func TestNovaTransactionExecution(t *testing.T) { nft1InputID := inputIDs[15] inputs := vm.InputSet{ - // basic output with no features [defaultAmount] (owned by ident1) - // => output 0: change ownership to ident5 + // basic output with no features [defaultAmount] (owned by addr1) + // => output 0: change ownership to addr5 inputIDs[0]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, - // basic output with native token feature - nativeTokenTransfer1 [defaultAmount] (owned by ident2) - // => output 1: change ownership to ident3 + // basic output with native token feature - nativeTokenTransfer1 [defaultAmount] (owned by addr2) + // => output 1: change ownership to addr3 inputIDs[1]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, Features: iotago.BasicOutputFeatures{ nativeTokenTransfer1, }, }, - // basic output with native token feature - nativeTokenTransfer2 [defaultAmount] (owned by ident2) - // => output 2: change ownership to ident4 + // basic output with native token feature - nativeTokenTransfer2 [defaultAmount] (owned by addr2) + // => output 2: change ownership to addr4 inputIDs[2]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, Features: iotago.BasicOutputFeatures{ nativeTokenTransfer2, }, }, - // basic output with expiration unlock condition - slot: 500, return: ident1 [defaultAmount] (originally owned by ident2 => creation slot 750 => owned by ident1) + // basic output with expiration unlock condition - slot: 500, return: addr1 [defaultAmount] (originally owned by addr2 => creation slot 750 => owned by addr1) // => output 3: remove expiration unlock condition inputIDs[3]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident1, + ReturnAddress: addr1, Slot: 500, }, }, }, - // basic output with timelock unlock condition - slot: 500 [defaultAmount] (owned by ident2 => creation slot 750 => can be unlocked) + // basic output with timelock unlock condition - slot: 500 [defaultAmount] (owned by addr2 => creation slot 750 => can be unlocked) // => output 4: remove timelock unlock condition inputIDs[4]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, &iotago.TimelockUnlockCondition{ Slot: 500, }, }, }, - // basic output [defaultAmount + storageDepositReturn] (owned by ident2 => creation slot 750 => can be unlocked, owned by ident2) - // storage deposit return unlock condition - return: ident1 + // basic output [defaultAmount + storageDepositReturn] (owned by addr2 => creation slot 750 => can be unlocked, owned by addr2) + // storage deposit return unlock condition - return: addr1 // timelock unlock condition - slot 500 - // expiration unlock condition - slot: 900, return: ident1 - // => output 5: storageDepositReturn to ident1 + // expiration unlock condition - slot: 900, return: addr1 + // => output 5: storageDepositReturn to addr1 // => output 14: defaultAmount inputIDs[5]: &iotago.BasicOutput{ Amount: defaultAmount + storageDepositReturn, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident1, + ReturnAddress: addr1, Amount: storageDepositReturn, }, &iotago.TimelockUnlockCondition{ Slot: 500, }, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident1, + ReturnAddress: addr1, Slot: 900, }, }, }, - // account output with no features - foundry counter 5 [defaultAmount] (owned by ident3) => going to be transitioned + // account output with no features - foundry counter 5 [defaultAmount] (owned by addr3) => going to be transitioned // => output 6: output transition (foundry counter 5 => 6, added metadata) account1InputID: &iotago.AccountOutput{ Amount: defaultAmount, AccountID: account1AccountID, FoundryCounter: 5, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident3}, + &iotago.AddressUnlockCondition{Address: addr3}, }, Features: nil, }, - // account output with no features [defaultAmount] (owned by ident3) => going to be destroyed + // account output with no features [defaultAmount] (owned by addr3) => going to be destroyed // => output 7: destroyed and new account output created inputIDs[7]: &iotago.AccountOutput{ Amount: defaultAmount, AccountID: iotago.AccountID{}, FoundryCounter: 0, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident3}, + &iotago.AddressUnlockCondition{Address: addr3}, }, Features: nil, }, - // anchor output with no features - state index 0 [defaultAmount] (owned by - state: ident3, gov: ident4) => going to be governance transitioned + // anchor output with no features - state index 0 [defaultAmount] (owned by - state: addr3, gov: addr4) => going to be governance transitioned // => output 8: governance transition (added metadata) anchor1InputID: &iotago.AnchorOutput{ Amount: defaultAmount, AnchorID: anchor1AnchorID, StateIndex: 0, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident3}, - &iotago.GovernorAddressUnlockCondition{Address: ident4}, + &iotago.StateControllerAddressUnlockCondition{Address: addr3}, + &iotago.GovernorAddressUnlockCondition{Address: addr4}, }, Features: iotago.AnchorOutputFeatures{ &iotago.StateMetadataFeature{Entries: iotago.StateMetadataFeatureEntries{"data": []byte("gov transitioning")}}, }, }, - // anchor output with no features - state index 5 [defaultAmount] (owned by - state: ident3, gov: ident4) => going to be state transitioned + // anchor output with no features - state index 5 [defaultAmount] (owned by - state: addr3, gov: addr4) => going to be state transitioned // => output 9: state transition (state index 5 => 6, changed state metadata) anchor2InputID: &iotago.AnchorOutput{ Amount: defaultAmount, AnchorID: anchor2AnchorID, StateIndex: 5, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident3}, - &iotago.GovernorAddressUnlockCondition{Address: ident4}, + &iotago.StateControllerAddressUnlockCondition{Address: addr3}, + &iotago.GovernorAddressUnlockCondition{Address: addr4}, }, Features: iotago.AnchorOutputFeatures{ &iotago.StateMetadataFeature{Entries: iotago.StateMetadataFeatureEntries{"data": []byte("state transitioning")}}, }, }, - // anchor output with no features - state index 0 [defaultAmount] (owned by - state: ident3, gov: ident3) => going to be destroyed + // anchor output with no features - state index 0 [defaultAmount] (owned by - state: addr3, gov: addr3) => going to be destroyed // => output 10: destroyed and new anchor output created inputIDs[10]: &iotago.AnchorOutput{ Amount: defaultAmount, AnchorID: iotago.AnchorID{}, StateIndex: 0, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident3}, - &iotago.GovernorAddressUnlockCondition{Address: ident3}, + &iotago.StateControllerAddressUnlockCondition{Address: addr3}, + &iotago.GovernorAddressUnlockCondition{Address: addr3}, }, Features: iotago.AnchorOutputFeatures{ &iotago.StateMetadataFeature{Entries: iotago.StateMetadataFeatureEntries{"data": []byte("going to be destroyed")}}, @@ -443,38 +443,38 @@ func TestNovaTransactionExecution(t *testing.T) { Features: nil, }, - // NFT output with issuer (ident3) and immutable metadata feature [defaultAmount] (owned by ident3) => going to be transferred to ident4 - // => output 16: transfer to ident4 + // NFT output with issuer (addr3) and immutable metadata feature [defaultAmount] (owned by addr3) => going to be transferred to addr4 + // => output 16: transfer to addr4 nft1InputID: &iotago.NFTOutput{ Amount: defaultAmount, NFTID: nft1ID, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident3}, + &iotago.AddressUnlockCondition{Address: addr3}, }, Features: iotago.NFTOutputFeatures{}, ImmutableFeatures: iotago.NFTOutputImmFeatures{ - &iotago.IssuerFeature{Address: ident3}, + &iotago.IssuerFeature{Address: addr3}, &iotago.MetadataFeature{Entries: iotago.MetadataFeatureEntries{"data": []byte("transfer to 4")}}, }, }, - // NFT output with immutable features [defaultAmount] (owned by ident4) => going to be destroyed + // NFT output with immutable features [defaultAmount] (owned by addr4) => going to be destroyed // => output 17: destroyed and new NFT output created inputIDs[16]: &iotago.NFTOutput{ Amount: defaultAmount, NFTID: nft2ID, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident4}, + &iotago.AddressUnlockCondition{Address: addr4}, }, Features: iotago.NFTOutputFeatures{}, ImmutableFeatures: iotago.NFTOutputImmFeatures{ - &iotago.IssuerFeature{Address: ident3}, + &iotago.IssuerFeature{Address: addr3}, &iotago.MetadataFeature{Entries: iotago.MetadataFeatureEntries{"data": []byte("going to be destroyed")}}, }, }, // basic output with no features [defaultAmount] (owned by nft1ID) - // => output 18: change ownership to ident5 + // => output 18: change ownership to addr5 inputIDs[17]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ @@ -483,17 +483,17 @@ func TestNovaTransactionExecution(t *testing.T) { }, } - foundry1Ident3NativeTokenID := inputs[foundry1InputID].(*iotago.FoundryOutput).MustNativeTokenID() - foundry2Ident3NativeTokenID := inputs[foundry2InputID].(*iotago.FoundryOutput).MustNativeTokenID() - foundry4Ident3NativeTokenID := inputs[foundry4InputID].(*iotago.FoundryOutput).MustNativeTokenID() + foundry1addr3NativeTokenID := inputs[foundry1InputID].(*iotago.FoundryOutput).MustNativeTokenID() + foundry2addr3NativeTokenID := inputs[foundry2InputID].(*iotago.FoundryOutput).MustNativeTokenID() + foundry4addr3NativeTokenID := inputs[foundry4InputID].(*iotago.FoundryOutput).MustNativeTokenID() inputs[foundry2InputID].(*iotago.FoundryOutput).Features.Upsert(&iotago.NativeTokenFeature{ - ID: foundry2Ident3NativeTokenID, + ID: foundry2addr3NativeTokenID, Amount: big.NewInt(100), }) inputs[foundry4InputID].(*iotago.FoundryOutput).Features.Upsert(&iotago.NativeTokenFeature{ - ID: foundry4Ident3NativeTokenID, + ID: foundry4addr3NativeTokenID, Amount: big.NewInt(50), }) @@ -527,103 +527,103 @@ func TestNovaTransactionExecution(t *testing.T) { Capabilities: iotago.TransactionCapabilitiesBitMaskWithCapabilities(iotago.WithTransactionCanDoAnything()), }, Outputs: iotago.TxEssenceOutputs{ - // basic output [defaultAmount] (owned by ident5) + // basic output [defaultAmount] (owned by addr5) // => input 0 &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident5}, + &iotago.AddressUnlockCondition{Address: addr5}, }, }, - // basic output with native token feature - nativeTokenTransfer1 [defaultAmount] (owned by ident3) + // basic output with native token feature - nativeTokenTransfer1 [defaultAmount] (owned by addr3) // => input 1 &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident3}, + &iotago.AddressUnlockCondition{Address: addr3}, }, Features: iotago.BasicOutputFeatures{ nativeTokenTransfer1, }, }, - // basic output with native token feature - nativeTokenTransfer2 [defaultAmount] (owned by ident4) + // basic output with native token feature - nativeTokenTransfer2 [defaultAmount] (owned by addr4) // => input 2 &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident4}, + &iotago.AddressUnlockCondition{Address: addr4}, }, Features: iotago.BasicOutputFeatures{ nativeTokenTransfer2, }, }, - // basic output [defaultAmount] (owned by ident2) + // basic output [defaultAmount] (owned by addr2) // => input 3 &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, }, - // basic output [defaultAmount] (owned by ident2) + // basic output [defaultAmount] (owned by addr2) // => input 4 &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, }, - // basic output [storageDepositReturn] (owned by ident1) + // basic output [storageDepositReturn] (owned by addr1) // => input 5 &iotago.BasicOutput{ Amount: storageDepositReturn, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, - // transitioned account output [defaultAmount] (owned by ident3) + // transitioned account output [defaultAmount] (owned by addr3) // => input 6 &iotago.AccountOutput{ Amount: defaultAmount, AccountID: account1AccountID, FoundryCounter: 6, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident3}, + &iotago.AddressUnlockCondition{Address: addr3}, }, Features: iotago.AccountOutputFeatures{ &iotago.MetadataFeature{Entries: iotago.MetadataFeatureEntries{"data": []byte("transitioned")}}, }, }, - // new account output [defaultAmount] (owned by ident3) + // new account output [defaultAmount] (owned by addr3) // => input 7 &iotago.AccountOutput{ Amount: defaultAmount, AccountID: iotago.AccountID{}, FoundryCounter: 0, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident3}, + &iotago.AddressUnlockCondition{Address: addr3}, }, Features: iotago.AccountOutputFeatures{ &iotago.MetadataFeature{Entries: iotago.MetadataFeatureEntries{"data": []byte("new")}}, }, }, - // governance transitioned anchor output [defaultAmount] (owned by - state: ident3, gov: ident4) + // governance transitioned anchor output [defaultAmount] (owned by - state: addr3, gov: addr4) // => input 8 &iotago.AnchorOutput{ Amount: defaultAmount, AnchorID: anchor1AnchorID, StateIndex: 0, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident3}, - &iotago.GovernorAddressUnlockCondition{Address: ident4}, + &iotago.StateControllerAddressUnlockCondition{Address: addr3}, + &iotago.GovernorAddressUnlockCondition{Address: addr4}, }, Features: iotago.AnchorOutputFeatures{ &iotago.StateMetadataFeature{Entries: iotago.StateMetadataFeatureEntries{"data": []byte("gov transitioning")}}, @@ -631,15 +631,15 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, - // state transitioned anchor output [defaultAmount] (owned by - state: ident3, gov: ident4) + // state transitioned anchor output [defaultAmount] (owned by - state: addr3, gov: addr4) // => input 9 &iotago.AnchorOutput{ Amount: defaultAmount, AnchorID: anchor2AnchorID, StateIndex: 6, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident3}, - &iotago.GovernorAddressUnlockCondition{Address: ident4}, + &iotago.StateControllerAddressUnlockCondition{Address: addr3}, + &iotago.GovernorAddressUnlockCondition{Address: addr4}, }, Features: iotago.AnchorOutputFeatures{ &iotago.StateMetadataFeature{Entries: iotago.StateMetadataFeatureEntries{ @@ -649,15 +649,15 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, - // new anchor output [defaultAmount] (owned by - state: ident3, gov: ident4) + // new anchor output [defaultAmount] (owned by - state: addr3, gov: addr4) // => input 10 &iotago.AnchorOutput{ Amount: defaultAmount, AnchorID: iotago.AnchorID{}, StateIndex: 0, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident3}, - &iotago.GovernorAddressUnlockCondition{Address: ident4}, + &iotago.StateControllerAddressUnlockCondition{Address: addr3}, + &iotago.GovernorAddressUnlockCondition{Address: addr4}, }, Features: iotago.AnchorOutputFeatures{ &iotago.StateMetadataFeature{Entries: iotago.StateMetadataFeatureEntries{"data": []byte("a new anchor output")}}, @@ -680,7 +680,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, Features: iotago.FoundryOutputFeatures{ &iotago.NativeTokenFeature{ - ID: foundry1Ident3NativeTokenID, + ID: foundry1addr3NativeTokenID, Amount: new(big.Int).SetUint64(100), // freshly minted }, }, @@ -702,7 +702,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, Features: iotago.FoundryOutputFeatures{ &iotago.NativeTokenFeature{ - ID: foundry2Ident3NativeTokenID, + ID: foundry2addr3NativeTokenID, Amount: new(big.Int).SetUint64(50), // melted to 50 }, }, @@ -731,37 +731,37 @@ func TestNovaTransactionExecution(t *testing.T) { // => input 5 newFoundryWithInitialSupply, - // basic output [defaultAmount] (owned by ident3) + // basic output [defaultAmount] (owned by addr3) // => input 14 (foundry 4 destruction remainder) &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident3}, + &iotago.AddressUnlockCondition{Address: addr3}, }, }, - // NFT output transitioned and changed ownership [defaultAmount] (owned by ident4) + // NFT output transitioned and changed ownership [defaultAmount] (owned by addr4) // => input 15 &iotago.NFTOutput{ Amount: defaultAmount, NFTID: nft1ID, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident4}, + &iotago.AddressUnlockCondition{Address: addr4}, }, Features: iotago.NFTOutputFeatures{}, ImmutableFeatures: iotago.NFTOutputImmFeatures{ - &iotago.IssuerFeature{Address: ident3}, + &iotago.IssuerFeature{Address: addr3}, &iotago.MetadataFeature{Entries: iotago.MetadataFeatureEntries{"data": []byte("transfer to 4")}}, }, }, - // new NFT output [defaultAmount] (owned by ident4) + // new NFT output [defaultAmount] (owned by addr4) // => input 16 &iotago.NFTOutput{ Amount: defaultAmount, NFTID: iotago.NFTID{}, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident4}, + &iotago.AddressUnlockCondition{Address: addr4}, }, Features: nil, ImmutableFeatures: iotago.NFTOutputImmFeatures{ @@ -769,18 +769,18 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, - // basic output [defaultAmount] (owned by ident5) + // basic output [defaultAmount] (owned by addr5) // => input 17 &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident5}, + &iotago.AddressUnlockCondition{Address: addr5}, }, }, }, } - sigs, err := transaction.Sign(ident1AddrKeys, ident2AddrKeys, ident3AddrKeys, ident4AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys, addr2AddrKeys, addr3AddrKeys, addr4AddrKeys) require.NoError(t, err) return &test{ @@ -797,27 +797,27 @@ func TestNovaTransactionExecution(t *testing.T) { Transaction: transaction, Unlocks: iotago.Unlocks{ // basic - &iotago.SignatureUnlock{Signature: sigs[0]}, // basic output (owned by ident1) => (ident1 == Reference 0) - &iotago.SignatureUnlock{Signature: sigs[1]}, // basic output (owned by ident2) => (ident2 == Reference 1) - &iotago.ReferenceUnlock{Reference: 1}, // basic output (owned by ident2) - &iotago.ReferenceUnlock{Reference: 0}, // basic output (owned by ident1) - &iotago.ReferenceUnlock{Reference: 1}, // basic output (owned by ident2) - &iotago.ReferenceUnlock{Reference: 1}, // basic output (owned by ident2) + &iotago.SignatureUnlock{Signature: sigs[0]}, // basic output (owned by addr1) => (addr1 == Reference 0) + &iotago.SignatureUnlock{Signature: sigs[1]}, // basic output (owned by addr2) => (addr2 == Reference 1) + &iotago.ReferenceUnlock{Reference: 1}, // basic output (owned by addr2) + &iotago.ReferenceUnlock{Reference: 0}, // basic output (owned by addr1) + &iotago.ReferenceUnlock{Reference: 1}, // basic output (owned by addr2) + &iotago.ReferenceUnlock{Reference: 1}, // basic output (owned by addr2) // account - &iotago.SignatureUnlock{Signature: sigs[2]}, // account output (owned by ident3) => (ident3 == Reference 6) - &iotago.ReferenceUnlock{Reference: 6}, // account output (owned by ident3) + &iotago.SignatureUnlock{Signature: sigs[2]}, // account output (owned by addr3) => (addr3 == Reference 6) + &iotago.ReferenceUnlock{Reference: 6}, // account output (owned by addr3) // anchor - &iotago.SignatureUnlock{Signature: sigs[3]}, // anchor output (owned by state: ident3, gov: ident4) => governance transitioned => (ident4 == Reference 8) - &iotago.ReferenceUnlock{Reference: 6}, // anchor output (owned by state: ident3, gov: ident4) => state transitioned - &iotago.ReferenceUnlock{Reference: 6}, // anchor output (owned by state: ident3, gov: ident3) => governance transitioned + &iotago.SignatureUnlock{Signature: sigs[3]}, // anchor output (owned by state: addr3, gov: addr4) => governance transitioned => (addr4 == Reference 8) + &iotago.ReferenceUnlock{Reference: 6}, // anchor output (owned by state: addr3, gov: addr4) => state transitioned + &iotago.ReferenceUnlock{Reference: 6}, // anchor output (owned by state: addr3, gov: addr3) => governance transitioned // foundries &iotago.AccountUnlock{Reference: 6}, // foundry output (owned by account1AccountAddress) &iotago.AccountUnlock{Reference: 6}, // foundry output (owned by account1AccountAddress) &iotago.AccountUnlock{Reference: 6}, // foundry output (owned by account1AccountAddress) &iotago.AccountUnlock{Reference: 6}, // foundry output (owned by account1AccountAddress) // nfts - &iotago.ReferenceUnlock{Reference: 6}, // NFT output (owned by ident3) - &iotago.ReferenceUnlock{Reference: 8}, // NFT output (owned by ident4) + &iotago.ReferenceUnlock{Reference: 6}, // NFT output (owned by addr3) + &iotago.ReferenceUnlock{Reference: 8}, // NFT output (owned by addr4) &iotago.NFTUnlock{Reference: 15}, // basic output (owned by nft1ID) }, }, @@ -829,7 +829,7 @@ func TestNovaTransactionExecution(t *testing.T) { func() *test { accountAddr1 := tpkg.RandAccountAddress() - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) inFoundry := &iotago.FoundryOutput{ @@ -855,7 +855,7 @@ func TestNovaTransactionExecution(t *testing.T) { Amount: 100, AccountID: accountAddr1.AccountID(), UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: inFoundry, @@ -872,14 +872,14 @@ func TestNovaTransactionExecution(t *testing.T) { Amount: 100, AccountID: accountAddr1.AccountID(), UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, outFoundry, }, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -908,7 +908,7 @@ func TestNovaTransactionExecution(t *testing.T) { func() *test { accountAddr1 := tpkg.RandAccountAddress() - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) @@ -923,7 +923,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -951,7 +951,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, }, @@ -965,7 +965,7 @@ func TestNovaTransactionExecution(t *testing.T) { Slot: 110, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -989,7 +989,7 @@ func TestNovaTransactionExecution(t *testing.T) { func() *test { accountAddr1 := tpkg.RandAccountAddress() - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) @@ -1004,7 +1004,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -1032,7 +1032,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, }, @@ -1046,7 +1046,7 @@ func TestNovaTransactionExecution(t *testing.T) { Slot: 110, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -1068,7 +1068,7 @@ func TestNovaTransactionExecution(t *testing.T) { // ok - remove expired block issuer feature from new account func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() creationSlot := iotago.SlotIndex(110) inputIDs := tpkg.RandOutputIDs(1) @@ -1085,7 +1085,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -1108,7 +1108,7 @@ func TestNovaTransactionExecution(t *testing.T) { AccountID: accountID, Features: iotago.AccountOutputFeatures{}, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, }, @@ -1122,7 +1122,7 @@ func TestNovaTransactionExecution(t *testing.T) { Slot: creationSlot, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -1150,7 +1150,7 @@ func TestNovaTransactionExecution(t *testing.T) { func() *test { accountAddr1 := tpkg.RandAccountAddress() - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) @@ -1165,7 +1165,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -1186,7 +1186,7 @@ func TestNovaTransactionExecution(t *testing.T) { &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, }, @@ -1200,7 +1200,7 @@ func TestNovaTransactionExecution(t *testing.T) { Slot: 110, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -1223,7 +1223,7 @@ func TestNovaTransactionExecution(t *testing.T) { // ok - destroy block issuer account func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) // Simulate the scenario where the input account's ID is unset. @@ -1240,7 +1240,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -1261,7 +1261,7 @@ func TestNovaTransactionExecution(t *testing.T) { &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, }, @@ -1275,7 +1275,7 @@ func TestNovaTransactionExecution(t *testing.T) { Slot: 110, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -1299,7 +1299,7 @@ func TestNovaTransactionExecution(t *testing.T) { func() *test { accountAddr1 := tpkg.RandAccountAddress() - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) @@ -1314,7 +1314,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -1330,7 +1330,7 @@ func TestNovaTransactionExecution(t *testing.T) { &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, }, @@ -1340,7 +1340,7 @@ func TestNovaTransactionExecution(t *testing.T) { Slot: 110, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -1364,7 +1364,7 @@ func TestNovaTransactionExecution(t *testing.T) { func() *test { accountAddr1 := tpkg.RandAccountAddress() - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) @@ -1379,7 +1379,7 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -1402,13 +1402,13 @@ func TestNovaTransactionExecution(t *testing.T) { }, }, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, }, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -3690,84 +3690,84 @@ func TestTxSemanticInputUnlocks(t *testing.T) { tests := []*test{ // ok func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - _, ident2, ident2AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + _, addr2, addr2AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(12) accountInputID := inputIDs[3] - accountIdent1 := iotago.AccountAddressFromOutputID(accountInputID) + accountaddr1 := iotago.AccountAddressFromOutputID(accountInputID) anchorInputID := inputIDs[8] - anchorIdent1 := iotago.AnchorAddressFromOutputID(anchorInputID) + anchoraddr1 := iotago.AnchorAddressFromOutputID(anchorInputID) - nftIdent1 := tpkg.RandNFTAddress() - nftIdent2 := tpkg.RandNFTAddress() + nftaddr1 := tpkg.RandNFTAddress() + nftaddr2 := tpkg.RandNFTAddress() defaultAmount := OneIOTA inputs := vm.InputSet{ - // basic output to create a signature unlock (owned by ident1) + // basic output to create a signature unlock (owned by addr1) inputIDs[0]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, - // basic output unlockable by sender as expired (owned by ident2) + // basic output unlockable by sender as expired (owned by addr2) inputIDs[1]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Slot: 5, }, }, }, - // basic output not unlockable by sender as not expired (owned by ident1) + // basic output not unlockable by sender as not expired (owned by addr1) inputIDs[2]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Slot: 30, }, }, }, - // account output that ownes the following outputs (owned by ident1) + // account output that ownes the following outputs (owned by addr1) accountInputID: &iotago.AccountOutput{ Amount: defaultAmount, AccountID: iotago.AccountID{}, // empty on purpose as validation should resolve UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, - // basic output (owned by accountIdent1) + // basic output (owned by accountaddr1) inputIDs[4]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: accountIdent1}, + &iotago.AddressUnlockCondition{Address: accountaddr1}, }, }, - // NFT output (owned by accountIdent1) + // NFT output (owned by accountaddr1) inputIDs[5]: &iotago.NFTOutput{ Amount: defaultAmount, - NFTID: nftIdent1.NFTID(), + NFTID: nftaddr1.NFTID(), UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: accountIdent1}, + &iotago.AddressUnlockCondition{Address: accountaddr1}, }, }, - // basic output (owned by nftIdent1) + // basic output (owned by nftaddr1) inputIDs[6]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: nftIdent1}, + &iotago.AddressUnlockCondition{Address: nftaddr1}, }, }, - // foundry output (owned by accountIdent1) + // foundry output (owned by accountaddr1) inputIDs[7]: &iotago.FoundryOutput{ Amount: defaultAmount, SerialNumber: 0, @@ -3777,39 +3777,39 @@ func TestTxSemanticInputUnlocks(t *testing.T) { MaximumSupply: new(big.Int).SetInt64(1000), }, UnlockConditions: iotago.FoundryOutputUnlockConditions{ - &iotago.ImmutableAccountUnlockCondition{Address: accountIdent1}, + &iotago.ImmutableAccountUnlockCondition{Address: accountaddr1}, }, }, - // anchor output that ownes the following outputs (owned by ident1) + // anchor output that ownes the following outputs (owned by addr1) inputIDs[8]: &iotago.AnchorOutput{ Amount: defaultAmount, AnchorID: iotago.AnchorID{}, // empty on purpose as validation should resolve UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident1}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr1}, }, }, - // basic output (owned by anchorIdent1) + // basic output (owned by anchoraddr1) inputIDs[9]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: anchorIdent1}, + &iotago.AddressUnlockCondition{Address: anchoraddr1}, }, }, - // NFT output (owned by anchorIdent1) + // NFT output (owned by anchoraddr1) inputIDs[10]: &iotago.NFTOutput{ Amount: defaultAmount, - NFTID: nftIdent2.NFTID(), + NFTID: nftaddr2.NFTID(), UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: anchorIdent1}, + &iotago.AddressUnlockCondition{Address: anchoraddr1}, }, }, - // basic output (owned by nftIdent2) + // basic output (owned by nftaddr2) inputIDs[11]: &iotago.BasicOutput{ Amount: defaultAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: nftIdent2}, + &iotago.AddressUnlockCondition{Address: nftaddr2}, }, }, } @@ -3825,24 +3825,24 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Outputs: iotago.TxEssenceOutputs{ &iotago.AccountOutput{ Amount: defaultAmount / 2, - AccountID: accountIdent1.AccountID(), + AccountID: accountaddr1.AccountID(), UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, &iotago.AnchorOutput{ Amount: defaultAmount / 2, - AnchorID: anchorIdent1.AnchorID(), + AnchorID: anchoraddr1.AnchorID(), StateIndex: 1, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident1}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr1}, }, }, }, } - sigs, err := transaction.Sign(ident1AddrKeys, ident2AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys, addr2AddrKeys) require.NoError(t, err) return &test{ @@ -3860,18 +3860,18 @@ func TestTxSemanticInputUnlocks(t *testing.T) { API: testAPI, Transaction: transaction, Unlocks: iotago.Unlocks{ - &iotago.SignatureUnlock{Signature: sigs[0]}, // basic output (owned by ident1) - &iotago.SignatureUnlock{Signature: sigs[1]}, // basic output (owned by ident2) - &iotago.ReferenceUnlock{Reference: 0}, // basic output (owned by ident1) - &iotago.ReferenceUnlock{Reference: 0}, // account output (owned by ident1) - &iotago.AccountUnlock{Reference: 3}, // basic output (owned by accountIdent1) - &iotago.AccountUnlock{Reference: 3}, // NFT output (owned by accountIdent1) - &iotago.NFTUnlock{Reference: 5}, // basic output (owned by nftIdent1) - &iotago.AccountUnlock{Reference: 3}, // foundry output (owned by accountIdent1) - &iotago.ReferenceUnlock{Reference: 0}, // anchor output (owned by ident1) - &iotago.AnchorUnlock{Reference: 8}, // basic output (owned by anchorIdent1) - &iotago.AnchorUnlock{Reference: 8}, // NFT output (owned by anchorIdent1) - &iotago.NFTUnlock{Reference: 10}, // basic output (owned by nftIdent2 + &iotago.SignatureUnlock{Signature: sigs[0]}, // basic output (owned by addr1) + &iotago.SignatureUnlock{Signature: sigs[1]}, // basic output (owned by addr2) + &iotago.ReferenceUnlock{Reference: 0}, // basic output (owned by addr1) + &iotago.ReferenceUnlock{Reference: 0}, // account output (owned by addr1) + &iotago.AccountUnlock{Reference: 3}, // basic output (owned by accountaddr1) + &iotago.AccountUnlock{Reference: 3}, // NFT output (owned by accountaddr1) + &iotago.NFTUnlock{Reference: 5}, // basic output (owned by nftaddr1) + &iotago.AccountUnlock{Reference: 3}, // foundry output (owned by accountaddr1) + &iotago.ReferenceUnlock{Reference: 0}, // anchor output (owned by addr1) + &iotago.AnchorUnlock{Reference: 8}, // basic output (owned by anchoraddr1) + &iotago.AnchorUnlock{Reference: 8}, // NFT output (owned by anchoraddr1) + &iotago.NFTUnlock{Reference: 10}, // basic output (owned by nftaddr2 }, }, wantErr: nil, @@ -3880,15 +3880,15 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - invalid signature func() *test { - ident1Sk, ident1, _ := tpkg.RandEd25519Identity() - _, _, ident2AddrKeys := tpkg.RandEd25519Identity() + addr1Sk, addr1, _ := tpkg.RandEd25519Identity() + _, _, addr2AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -3898,10 +3898,10 @@ func TestTxSemanticInputUnlocks(t *testing.T) { TransactionEssence: &iotago.TransactionEssence{Inputs: inputIDs.UTXOInputs()}, } - sigs, err := transaction.Sign(ident2AddrKeys) + sigs, err := transaction.Sign(addr2AddrKeys) require.NoError(t, err) - copy(sigs[0].(*iotago.Ed25519Signature).PublicKey[:], ident1Sk.Public().(ed25519.PublicKey)) + copy(sigs[0].(*iotago.Ed25519Signature).PublicKey[:], addr1Sk.Public().(ed25519.PublicKey)) return &test{ name: "fail - invalid signature", @@ -3922,20 +3922,20 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - should contain reference unlock func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -3944,7 +3944,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Inputs: inputIDs.UTXOInputs(), }} - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -3967,22 +3967,22 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - should contain account unlock func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) - accountIdent1 := iotago.AccountAddressFromOutputID(inputIDs[0]) + accountaddr1 := iotago.AccountAddressFromOutputID(inputIDs[0]) inputs := vm.InputSet{ inputIDs[0]: &iotago.AccountOutput{ Amount: 100, AccountID: iotago.AccountID{}, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: accountIdent1}, + &iotago.AddressUnlockCondition{Address: accountaddr1}, }, }, } @@ -3991,7 +3991,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Inputs: inputIDs.UTXOInputs(), }} - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4014,23 +4014,23 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - should contain anchor unlock func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) - anchorIdent1 := iotago.AnchorAddressFromOutputID(inputIDs[0]) + anchoraddr1 := iotago.AnchorAddressFromOutputID(inputIDs[0]) inputs := vm.InputSet{ inputIDs[0]: &iotago.AnchorOutput{ Amount: 100, AnchorID: iotago.AnchorID{}, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident1}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: anchorIdent1}, + &iotago.AddressUnlockCondition{Address: anchoraddr1}, }, }, } @@ -4039,7 +4039,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Inputs: inputIDs.UTXOInputs(), }} - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4062,22 +4062,22 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - should contain NFT unlock func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) - nftIdent1 := iotago.NFTAddressFromOutputID(inputIDs[0]) + nftaddr1 := iotago.NFTAddressFromOutputID(inputIDs[0]) inputs := vm.InputSet{ inputIDs[0]: &iotago.NFTOutput{ Amount: 100, NFTID: iotago.NFTID{}, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: nftIdent1}, + &iotago.AddressUnlockCondition{Address: nftaddr1}, }, }, } @@ -4086,7 +4086,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Inputs: inputIDs.UTXOInputs(), }} - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4111,22 +4111,22 @@ func TestTxSemanticInputUnlocks(t *testing.T) { func() *test { inputIDs := tpkg.RandOutputIDs(2) - nftIdent1 := iotago.NFTAddressFromOutputID(inputIDs[0]) - nftIdent2 := iotago.NFTAddressFromOutputID(inputIDs[1]) + nftaddr1 := iotago.NFTAddressFromOutputID(inputIDs[0]) + nftaddr2 := iotago.NFTAddressFromOutputID(inputIDs[1]) inputs := vm.InputSet{ inputIDs[0]: &iotago.NFTOutput{ Amount: 100, - NFTID: nftIdent1.NFTID(), + NFTID: nftaddr1.NFTID(), UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: nftIdent2}, + &iotago.AddressUnlockCondition{Address: nftaddr2}, }, }, inputIDs[1]: &iotago.NFTOutput{ Amount: 100, - NFTID: nftIdent2.NFTID(), + NFTID: nftaddr2.NFTID(), UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: nftIdent2}, + &iotago.AddressUnlockCondition{Address: nftaddr2}, }, }, } @@ -4156,7 +4156,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - should contain sig unlock func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) inputs := vm.InputSet{ @@ -4164,7 +4164,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Amount: 100, AccountID: iotago.AccountID{}, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -4173,7 +4173,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Inputs: inputIDs.UTXOInputs(), }} - _, err := transaction.Sign(ident1AddressKeys) + _, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4195,7 +4195,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - reference unlock pointee invalid func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ @@ -4203,7 +4203,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Amount: 100, AccountID: iotago.AccountID{}, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -4212,7 +4212,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Inputs: inputIDs.UTXOInputs(), }} - _, err := transaction.Sign(ident1AddressKeys) + _, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4234,17 +4234,17 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - sender can not unlock yet func() *test { - _, ident1, _ := tpkg.RandEd25519Identity() - _, ident2, ident2AddressKeys := tpkg.RandEd25519Identity() + _, addr1, _ := tpkg.RandEd25519Identity() + _, addr2, addr2AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Slot: 20, }, }, @@ -4254,7 +4254,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { creationSlot := iotago.SlotIndex(5) transaction := &iotago.Transaction{API: testAPI, TransactionEssence: &iotago.TransactionEssence{Inputs: inputIDs.UTXOInputs(), CreationSlot: creationSlot}} - sigs, err := transaction.Sign(ident2AddressKeys) + sigs, err := transaction.Sign(addr2AddressKeys) require.NoError(t, err) return &test{ @@ -4281,17 +4281,17 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - receiver can not unlock anymore func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() - _, ident2, _ := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() + _, addr2, _ := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Slot: 10, }, }, @@ -4301,7 +4301,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { creationSlot := iotago.SlotIndex(10) transaction := &iotago.Transaction{API: testAPI, TransactionEssence: &iotago.TransactionEssence{Inputs: inputIDs.UTXOInputs(), CreationSlot: creationSlot}} - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4328,7 +4328,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - referencing other account unlocked by source account func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(3) var ( @@ -4338,12 +4338,12 @@ func TestTxSemanticInputUnlocks(t *testing.T) { ) inputs := vm.InputSet{ - // owned by ident1 + // owned by addr1 inputIDs[0]: &iotago.AccountOutput{ Amount: 100, AccountID: accountAddr1.AccountID(), UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, // owned by account1 @@ -4368,7 +4368,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Inputs: inputIDs.UTXOInputs(), }} - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4393,7 +4393,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - referencing other anchor unlocked by source anchor func() *test { - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(3) var ( @@ -4403,13 +4403,13 @@ func TestTxSemanticInputUnlocks(t *testing.T) { ) inputs := vm.InputSet{ - // owned by ident1 + // owned by addr1 inputIDs[0]: &iotago.AnchorOutput{ Amount: 100, AnchorID: anchorAddr1.AnchorID(), UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident1}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr1}, }, }, // owned by anchor1 @@ -4436,7 +4436,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Inputs: inputIDs.UTXOInputs(), }} - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4461,8 +4461,8 @@ func TestTxSemanticInputUnlocks(t *testing.T) { // fail - anchor output not state transitioning func() *test { - _, ident1, _ := tpkg.RandEd25519Identity() - _, ident2, ident2AddressKeys := tpkg.RandEd25519Identity() + _, addr1, _ := tpkg.RandEd25519Identity() + _, addr2, addr2AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) anchorAddr1 := tpkg.RandAnchorAddress() @@ -4472,8 +4472,8 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Amount: 100, AnchorID: anchorAddr1.AnchorID(), UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident2}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr2}, }, }, inputIDs[1]: &iotago.BasicOutput{ @@ -4494,14 +4494,14 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Amount: 100, AnchorID: anchorAddr1.AnchorID(), UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident2}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr2}, }, }, }, } - sigs, err := transaction.Sign(ident2AddressKeys) + sigs, err := transaction.Sign(addr2AddressKeys) require.NoError(t, err) return &test{ @@ -4526,7 +4526,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { func() *test { accountAddr1 := tpkg.RandAccountAddress() - _, ident1, ident1AddressKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddressKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) foundryOutput := &iotago.FoundryOutput{ @@ -4547,7 +4547,7 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Amount: 100, AccountID: accountAddr1.AccountID(), UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: foundryOutput, @@ -4563,14 +4563,14 @@ func TestTxSemanticInputUnlocks(t *testing.T) { Amount: 100, AccountID: accountAddr1.AccountID(), UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, foundryOutput, }, } - sigs, err := transaction.Sign(ident1AddressKeys) + sigs, err := transaction.Sign(addr1AddressKeys) require.NoError(t, err) return &test{ @@ -4616,43 +4616,43 @@ func TestTxSemanticDeposit(t *testing.T) { tests := []*test{ // ok func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - _, ident2, ident2AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + _, addr2, addr2AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(3) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, - // unlocked by ident1 as it is not expired + // unlocked by addr1 as it is not expired inputIDs[1]: &iotago.BasicOutput{ Amount: 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Amount: 420, }, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Slot: 30, }, }, }, - // unlocked by ident2 as it is expired + // unlocked by addr2 as it is expired inputIDs[2]: &iotago.BasicOutput{ Amount: 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Amount: 420, }, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Slot: 2, }, }, @@ -4674,15 +4674,15 @@ func TestTxSemanticDeposit(t *testing.T) { }, }, &iotago.BasicOutput{ - // return via ident1 + reclaim + // return via addr1 + reclaim Amount: 420 + 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, }, }, } - sigs, err := transaction.Sign(ident1AddrKeys, ident2AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys, addr2AddrKeys) require.NoError(t, err) return &test{ @@ -4711,17 +4711,17 @@ func TestTxSemanticDeposit(t *testing.T) { // ok - more storage deposit returned via more outputs func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - _, ident2, _ := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + _, addr2, _ := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 1000, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Amount: 420, }, }, @@ -4735,17 +4735,17 @@ func TestTxSemanticDeposit(t *testing.T) { }, Outputs: iotago.TxEssenceOutputs{ &iotago.BasicOutput{ - // returns 200 to ident2 + // returns 200 to addr2 Amount: 200, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, }, &iotago.BasicOutput{ - // returns 221 to ident2 + // returns 221 to addr2 Amount: 221, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, }, &iotago.BasicOutput{ @@ -4757,7 +4757,7 @@ func TestTxSemanticDeposit(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -4779,14 +4779,14 @@ func TestTxSemanticDeposit(t *testing.T) { // fail - unbalanced, more on output than input func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 50, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -4806,7 +4806,7 @@ func TestTxSemanticDeposit(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -4828,14 +4828,14 @@ func TestTxSemanticDeposit(t *testing.T) { // fail - unbalanced, more on input than output func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -4855,7 +4855,7 @@ func TestTxSemanticDeposit(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -4877,22 +4877,22 @@ func TestTxSemanticDeposit(t *testing.T) { // fail - return not fulfilled func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - _, ident2, _ := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + _, addr2, _ := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Amount: 420, }, - // not yet expired, so ident1 needs to unlock + // not yet expired, so addr1 needs to unlock &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Slot: 30, }, }, @@ -4910,12 +4910,12 @@ func TestTxSemanticDeposit(t *testing.T) { &iotago.BasicOutput{ Amount: 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -4942,17 +4942,17 @@ func TestTxSemanticDeposit(t *testing.T) { // fail - storage deposit return not basic output func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - _, ident2, _ := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + _, addr2, _ := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Amount: 420, }, }, @@ -4968,18 +4968,18 @@ func TestTxSemanticDeposit(t *testing.T) { &iotago.BasicOutput{ Amount: 80, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, &iotago.NFTOutput{ Amount: 420, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -5001,17 +5001,17 @@ func TestTxSemanticDeposit(t *testing.T) { // fail - storage deposit return has additional unlocks func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - _, ident2, _ := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + _, addr2, _ := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Amount: 420, }, }, @@ -5027,22 +5027,22 @@ func TestTxSemanticDeposit(t *testing.T) { &iotago.BasicOutput{ Amount: 80, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, &iotago.BasicOutput{ Amount: 420, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, &iotago.ExpirationUnlockCondition{ - ReturnAddress: ident1, + ReturnAddress: addr1, Slot: 10, }, }, }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -5064,17 +5064,17 @@ func TestTxSemanticDeposit(t *testing.T) { // fail - storage deposit return has feature func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - _, ident2, _ := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + _, addr2, _ := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Amount: 420, }, }, @@ -5090,13 +5090,13 @@ func TestTxSemanticDeposit(t *testing.T) { &iotago.BasicOutput{ Amount: 80, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, &iotago.BasicOutput{ Amount: 420, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, Features: iotago.BasicOutputFeatures{ &iotago.MetadataFeature{Entries: iotago.MetadataFeatureEntries{"data": []byte("foo")}}, @@ -5104,7 +5104,7 @@ func TestTxSemanticDeposit(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -5126,8 +5126,8 @@ func TestTxSemanticDeposit(t *testing.T) { // fail - storage deposit return has native tokens func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() - _, ident2, _ := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() + _, addr2, _ := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) ntID := tpkg.Rand38ByteArray() @@ -5135,9 +5135,9 @@ func TestTxSemanticDeposit(t *testing.T) { inputIDs[0]: &iotago.BasicOutput{ Amount: 500, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident2, + ReturnAddress: addr2, Amount: 420, }, }, @@ -5159,13 +5159,13 @@ func TestTxSemanticDeposit(t *testing.T) { &iotago.BasicOutput{ Amount: 80, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, &iotago.BasicOutput{ Amount: 420, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident2}, + &iotago.AddressUnlockCondition{Address: addr2}, }, Features: iotago.BasicOutputFeatures{ &iotago.NativeTokenFeature{ @@ -5176,7 +5176,7 @@ func TestTxSemanticDeposit(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -5210,7 +5210,7 @@ func TestTxSemanticDeposit(t *testing.T) { } func TestTxSemanticNativeTokens(t *testing.T) { - foundryAccountIdent := tpkg.RandAccountAddress() + foundryAccountAddr := tpkg.RandAccountAddress() foundryMaxSupply := new(big.Int).SetInt64(1000) foundryMintedSupply := new(big.Int).SetInt64(500) @@ -5223,7 +5223,7 @@ func TestTxSemanticNativeTokens(t *testing.T) { MaximumSupply: foundryMaxSupply, }, UnlockConditions: iotago.FoundryOutputUnlockConditions{ - &iotago.ImmutableAccountUnlockCondition{Address: foundryAccountIdent}, + &iotago.ImmutableAccountUnlockCondition{Address: foundryAccountAddr}, }, } @@ -5236,7 +5236,7 @@ func TestTxSemanticNativeTokens(t *testing.T) { MaximumSupply: foundryMaxSupply, }, UnlockConditions: iotago.FoundryOutputUnlockConditions{ - &iotago.ImmutableAccountUnlockCondition{Address: foundryAccountIdent}, + &iotago.ImmutableAccountUnlockCondition{Address: foundryAccountAddr}, }, } @@ -5567,7 +5567,7 @@ func TestTxSemanticNativeTokens(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - _, err := novaVM.Execute(tt.tx.Transaction, tt.resolvedInputs, make(vm.UnlockedIdentities), vm.ExecFuncBalancedNativeTokens()) + _, err := novaVM.Execute(tt.tx.Transaction, tt.resolvedInputs, make(vm.UnlockedAddresses), vm.ExecFuncBalancedNativeTokens()) if tt.wantErr != nil { require.ErrorIs(t, err, tt.wantErr) return @@ -5589,7 +5589,7 @@ func TestTxSemanticOutputsSender(t *testing.T) { tests := []*test{ // ok func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(4) accountAddr := tpkg.RandAccountAddress() anchorAddr := tpkg.RandAnchorAddress() @@ -5599,14 +5599,14 @@ func TestTxSemanticOutputsSender(t *testing.T) { inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: &iotago.AccountOutput{ Amount: 100, AccountID: accountAddr.AccountID(), UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[2]: &iotago.AnchorOutput{ @@ -5614,15 +5614,15 @@ func TestTxSemanticOutputsSender(t *testing.T) { AnchorID: anchorAddr.AnchorID(), StateIndex: 1, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident1}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr1}, }, }, inputIDs[3]: &iotago.NFTOutput{ Amount: 100, NFTID: nftAddr.NFTID(), UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -5641,12 +5641,12 @@ func TestTxSemanticOutputsSender(t *testing.T) { AnchorID: anchorAddr.AnchorID(), StateIndex: 2, UnlockConditions: iotago.AnchorOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: ident1}, - &iotago.GovernorAddressUnlockCondition{Address: ident1}, + &iotago.StateControllerAddressUnlockCondition{Address: addr1}, + &iotago.GovernorAddressUnlockCondition{Address: addr1}, }, }) - for _, sender := range []iotago.Address{ident1, accountAddr, anchorAddr, nftAddr} { + for _, sender := range []iotago.Address{addr1, accountAddr, anchorAddr, nftAddr} { outputs = append(outputs, &iotago.BasicOutput{ Amount: 1337, UnlockConditions: iotago.BasicOutputUnlockConditions{ @@ -5660,7 +5660,7 @@ func TestTxSemanticOutputsSender(t *testing.T) { outputs = append(outputs, &iotago.AccountOutput{ Amount: 1337, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, Features: iotago.AccountOutputFeatures{ &iotago.SenderFeature{Address: sender}, @@ -5680,7 +5680,7 @@ func TestTxSemanticOutputsSender(t *testing.T) { return outputs }(), } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -5705,14 +5705,14 @@ func TestTxSemanticOutputsSender(t *testing.T) { // fail - sender not unlocked func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -5734,7 +5734,7 @@ func TestTxSemanticOutputsSender(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -5957,17 +5957,17 @@ func TestTxSemanticOutputsSender(t *testing.T) { // ok - multi address in sender feature func() *test { - _, ident1, ident1Keys := tpkg.RandEd25519Identity() - _, ident2, ident2Keys := tpkg.RandEd25519Identity() + _, addr1, addr1Keys := tpkg.RandEd25519Identity() + _, addr2, addr2Keys := tpkg.RandEd25519Identity() multiAddr := iotago.MultiAddress{ Addresses: iotago.AddressesWithWeight{ { - Address: ident1, + Address: addr1, Weight: 5, }, { - Address: ident2, + Address: addr2, Weight: 10, }, { @@ -6007,7 +6007,7 @@ func TestTxSemanticOutputsSender(t *testing.T) { }, } - sigs, err := transaction.Sign(ident1Keys, ident2Keys) + sigs, err := transaction.Sign(addr1Keys, addr2Keys) require.NoError(t, err) return &test{ @@ -6035,17 +6035,17 @@ func TestTxSemanticOutputsSender(t *testing.T) { // ok - restricted multi address in sender and issuer feature func() *test { - _, ident1, ident1Keys := tpkg.RandEd25519Identity() - _, ident2, ident2Keys := tpkg.RandEd25519Identity() + _, addr1, addr1Keys := tpkg.RandEd25519Identity() + _, addr2, addr2Keys := tpkg.RandEd25519Identity() multiAddr := iotago.MultiAddress{ Addresses: iotago.AddressesWithWeight{ { - Address: ident1, + Address: addr1, Weight: 5, }, { - Address: ident2, + Address: addr2, Weight: 10, }, { @@ -6095,7 +6095,7 @@ func TestTxSemanticOutputsSender(t *testing.T) { }, } - sigs, err := transaction.Sign(ident1Keys, ident2Keys) + sigs, err := transaction.Sign(addr1Keys, addr2Keys) require.NoError(t, err) return &test{ @@ -6145,7 +6145,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { tests := []*test{ // fail - issuer not unlocked due to governance transition func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() _, stateController, _ := tpkg.RandEd25519Identity() _, governor, governorAddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) @@ -6164,7 +6164,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { inputIDs[1]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6186,7 +6186,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { &iotago.NFTOutput{ Amount: 100, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, ImmutableFeatures: iotago.NFTOutputImmFeatures{ &iotago.IssuerFeature{Address: anchorAddr}, @@ -6194,7 +6194,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { }, }, } - sigs, err := transaction.Sign(governorAddrKeys, ident1AddrKeys) + sigs, err := transaction.Sign(governorAddrKeys, addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6217,7 +6217,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { // ok - issuer unlocked with state transition func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() _, stateController, stateControllerAddrKeys := tpkg.RandEd25519Identity() _, governor, _ := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) @@ -6228,7 +6228,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { nftAddr := tpkg.RandNFTAddress() inputs := vm.InputSet{ - // possible issuers: anchorAddr, stateController, nftAddr, ident1 + // possible issuers: anchorAddr, stateController, nftAddr, addr1 inputIDs[0]: &iotago.AnchorOutput{ Amount: 100, AnchorID: anchorID, @@ -6242,7 +6242,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { Amount: 900, NFTID: nftAddr.NFTID(), UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6267,14 +6267,14 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { Amount: 100, NFTID: nftAddr.NFTID(), UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, // issuer is anchorAddr &iotago.NFTOutput{ Amount: 100, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, ImmutableFeatures: iotago.NFTOutputImmFeatures{ &iotago.IssuerFeature{Address: anchorAddr}, @@ -6294,7 +6294,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { &iotago.NFTOutput{ Amount: 100, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, ImmutableFeatures: iotago.NFTOutputImmFeatures{ &iotago.IssuerFeature{Address: stateController}, @@ -6314,7 +6314,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { &iotago.NFTOutput{ Amount: 100, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, ImmutableFeatures: iotago.NFTOutputImmFeatures{ &iotago.IssuerFeature{Address: nftAddr}, @@ -6330,14 +6330,14 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { &iotago.IssuerFeature{Address: nftAddr}, }, }, - // issuer is ident1 + // issuer is addr1 &iotago.NFTOutput{ Amount: 100, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, ImmutableFeatures: iotago.NFTOutputImmFeatures{ - &iotago.IssuerFeature{Address: ident1}, + &iotago.IssuerFeature{Address: addr1}, }, }, &iotago.AnchorOutput{ @@ -6347,12 +6347,12 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { &iotago.GovernorAddressUnlockCondition{Address: governor}, }, ImmutableFeatures: iotago.AnchorOutputImmFeatures{ - &iotago.IssuerFeature{Address: ident1}, + &iotago.IssuerFeature{Address: addr1}, }, }, }, } - sigs, err := transaction.Sign(stateControllerAddrKeys, ident1AddrKeys) + sigs, err := transaction.Sign(stateControllerAddrKeys, addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6375,7 +6375,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { // ok - issuer is the governor func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() _, stateController, _ := tpkg.RandEd25519Identity() _, governor, governorAddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(2) @@ -6394,7 +6394,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { inputIDs[1]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6416,7 +6416,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { &iotago.NFTOutput{ Amount: 100, UnlockConditions: iotago.NFTOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, ImmutableFeatures: iotago.NFTOutputImmFeatures{ &iotago.IssuerFeature{Address: governor}, @@ -6424,7 +6424,7 @@ func TestTxSemanticOutputsIssuer(t *testing.T) { }, }, } - sigs, err := transaction.Sign(governorAddrKeys, ident1AddrKeys) + sigs, err := transaction.Sign(governorAddrKeys, addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6469,13 +6469,13 @@ func TestTxSemanticTimelocks(t *testing.T) { tests := []*test{ // ok func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.TimelockUnlockCondition{ Slot: 5, }, @@ -6485,7 +6485,7 @@ func TestTxSemanticTimelocks(t *testing.T) { creationSlot := iotago.SlotIndex(10) transaction := &iotago.Transaction{API: testAPI, TransactionEssence: &iotago.TransactionEssence{Inputs: inputIDs.UTXOInputs(), CreationSlot: creationSlot}} - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6512,14 +6512,14 @@ func TestTxSemanticTimelocks(t *testing.T) { // fail - timelock not expired func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.TimelockUnlockCondition{ Slot: 25, }, @@ -6529,7 +6529,7 @@ func TestTxSemanticTimelocks(t *testing.T) { creationSlot := iotago.SlotIndex(10) transaction := &iotago.Transaction{API: testAPI, TransactionEssence: &iotago.TransactionEssence{Inputs: inputIDs.UTXOInputs(), CreationSlot: creationSlot}} - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6556,14 +6556,14 @@ func TestTxSemanticTimelocks(t *testing.T) { // fail - no commitment input for timelock func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDs(1) inputs := vm.InputSet{ inputIDs[0]: &iotago.BasicOutput{ Amount: 100, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, &iotago.TimelockUnlockCondition{ Slot: 1000, }, @@ -6573,7 +6573,7 @@ func TestTxSemanticTimelocks(t *testing.T) { creationSlot := iotago.SlotIndex(1005) transaction := &iotago.Transaction{API: testAPI, TransactionEssence: &iotago.TransactionEssence{Inputs: inputIDs.UTXOInputs(), CreationSlot: creationSlot}} - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6597,7 +6597,7 @@ func TestTxSemanticTimelocks(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - _, err := novaVM.Execute(tt.tx.Transaction, tt.resolvedInputs, make(vm.UnlockedIdentities), vm.ExecFuncTimelocks()) + _, err := novaVM.Execute(tt.tx.Transaction, tt.resolvedInputs, make(vm.UnlockedAddresses), vm.ExecFuncTimelocks()) if tt.wantErr != nil { require.ErrorIs(t, err, tt.wantErr) return @@ -6620,7 +6620,7 @@ func TestTxSemanticMana(t *testing.T) { tests := []*test{ // ok - stored Mana only without allotment" func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDsWithCreationSlot(10, 1) inputs := vm.InputSet{ @@ -6628,7 +6628,7 @@ func TestTxSemanticMana(t *testing.T) { Amount: OneIOTA, Mana: iotago.MaxMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6662,7 +6662,7 @@ func TestTxSemanticMana(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6684,7 +6684,7 @@ func TestTxSemanticMana(t *testing.T) { // ok - stored and allotted func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDsWithCreationSlot(10, 1) inputs := vm.InputSet{ @@ -6692,7 +6692,7 @@ func TestTxSemanticMana(t *testing.T) { Amount: OneIOTA, Mana: iotago.MaxMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6730,7 +6730,7 @@ func TestTxSemanticMana(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6752,7 +6752,7 @@ func TestTxSemanticMana(t *testing.T) { // fail - input created after tx func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDsWithCreationSlot(20, 1) inputs := vm.InputSet{ @@ -6760,7 +6760,7 @@ func TestTxSemanticMana(t *testing.T) { Amount: 5, Mana: 10, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6781,7 +6781,7 @@ func TestTxSemanticMana(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6803,7 +6803,7 @@ func TestTxSemanticMana(t *testing.T) { // ok - input created in same slot as tx func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDsWithCreationSlot(15, 1) inputs := vm.InputSet{ @@ -6811,7 +6811,7 @@ func TestTxSemanticMana(t *testing.T) { Amount: 5, Mana: 10, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6832,7 +6832,7 @@ func TestTxSemanticMana(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6854,7 +6854,7 @@ func TestTxSemanticMana(t *testing.T) { // fail - mana overflow on the input side sum func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDsWithCreationSlot(15, 2) inputs := vm.InputSet{ @@ -6862,14 +6862,14 @@ func TestTxSemanticMana(t *testing.T) { Amount: 5, Mana: iotago.MaxMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, inputIDs[1]: &iotago.BasicOutput{ Amount: 5, Mana: 10, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6890,7 +6890,7 @@ func TestTxSemanticMana(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6913,7 +6913,7 @@ func TestTxSemanticMana(t *testing.T) { // fail - mana overflow on the output side sum func() *test { - _, ident1, ident1AddrKeys := tpkg.RandEd25519Identity() + _, addr1, addr1AddrKeys := tpkg.RandEd25519Identity() inputIDs := tpkg.RandOutputIDsWithCreationSlot(15, 1) inputs := vm.InputSet{ @@ -6921,7 +6921,7 @@ func TestTxSemanticMana(t *testing.T) { Amount: 5, Mana: 10, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident1}, + &iotago.AddressUnlockCondition{Address: addr1}, }, }, } @@ -6949,7 +6949,7 @@ func TestTxSemanticMana(t *testing.T) { }, }, } - sigs, err := transaction.Sign(ident1AddrKeys) + sigs, err := transaction.Sign(addr1AddrKeys) require.NoError(t, err) return &test{ @@ -6983,9 +6983,9 @@ func TestTxSemanticMana(t *testing.T) { } func TestManaRewardsClaimingStaking(t *testing.T) { - _, ident, identAddrKeys := tpkg.RandEd25519Identity() - accountIdent := tpkg.RandAccountAddress() - accountID := accountIdent.AccountID() + _, addr, addrAddrKeys := tpkg.RandEd25519Identity() + accountAddr := tpkg.RandAccountAddress() + accountID := accountAddr.AccountID() var manaRewardAmount iotago.Mana = 200 currentEpoch := iotago.EpochIndex(20) @@ -7007,7 +7007,7 @@ func TestManaRewardsClaimingStaking(t *testing.T) { Mana: 0, FoundryCounter: 0, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident}, + &iotago.AddressUnlockCondition{Address: addr}, }, Features: iotago.AccountOutputFeatures{ blockIssuerFeature, @@ -7036,7 +7036,7 @@ func TestManaRewardsClaimingStaking(t *testing.T) { AccountID: accountID, FoundryCounter: 0, UnlockConditions: iotago.AccountOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident}, + &iotago.AddressUnlockCondition{Address: addr}, }, Features: iotago.AccountOutputFeatures{ blockIssuerFeature, @@ -7046,14 +7046,14 @@ func TestManaRewardsClaimingStaking(t *testing.T) { Amount: OneIOTA * 5, Mana: manaRewardAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: accountIdent}, + &iotago.AddressUnlockCondition{Address: accountAddr}, }, Features: nil, }, }, } - sigs, err := transaction.Sign(identAddrKeys) + sigs, err := transaction.Sign(addrAddrKeys) require.NoError(t, err) tx := &iotago.SignedTransaction{ @@ -7080,7 +7080,7 @@ func TestManaRewardsClaimingStaking(t *testing.T) { } func TestManaRewardsClaimingDelegation(t *testing.T) { - _, ident, identAddrKeys := tpkg.RandEd25519Identity() + _, addr, addrAddrKeys := tpkg.RandEd25519Identity() const manaRewardAmount iotago.Mana = 200 currentSlot := 20 * testProtoParams.ParamEpochDurationInSlots() @@ -7096,7 +7096,7 @@ func TestManaRewardsClaimingDelegation(t *testing.T) { StartEpoch: currentEpoch, EndEpoch: currentEpoch + 5, UnlockConditions: iotago.DelegationOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident}, + &iotago.AddressUnlockCondition{Address: addr}, }, }, } @@ -7114,14 +7114,14 @@ func TestManaRewardsClaimingDelegation(t *testing.T) { Amount: OneIOTA * 10, Mana: manaRewardAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident}, + &iotago.AddressUnlockCondition{Address: addr}, }, Features: nil, }, }, } - sigs, err := transaction.Sign(identAddrKeys) + sigs, err := transaction.Sign(addrAddrKeys) require.NoError(t, err) tx := &iotago.SignedTransaction{ @@ -7152,8 +7152,8 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { createTestParameters []func() testParameters } - _, ident, identAddrKeys := tpkg.RandEd25519Identity() - addr := tpkg.RandEd25519Address() + _, addr, addrAddrKeys := tpkg.RandEd25519Identity() + randAddr := tpkg.RandEd25519Address() tests := []*test{ { @@ -7171,14 +7171,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Native Token Address in Output with Native Tokens", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveNativeTokens(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveNativeTokens(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Native Token Address in Output with Native Tokens", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveNativeTokens, } }, @@ -7197,14 +7197,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Mana Address in Output with Mana", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveMana(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveMana(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Mana Address in Output with Mana", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveMana, } }, @@ -7225,14 +7225,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Timelock Unlock Condition Address in Output with Timelock Unlock Condition", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveOutputsWithTimelockUnlockCondition(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveOutputsWithTimelockUnlockCondition(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Timelock Unlock Condition Address in Output with Timelock Unlock Condition", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveTimelockUnlockCondition, } }, @@ -7245,7 +7245,7 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { &iotago.AddressUnlockCondition{Address: address}, &iotago.ExpirationUnlockCondition{ Slot: 500, - ReturnAddress: ident, + ReturnAddress: addr, }, }, } @@ -7254,14 +7254,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Expiration Unlock Condition Address in Output with Expiration Unlock Condition", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveOutputsWithExpirationUnlockCondition(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveOutputsWithExpirationUnlockCondition(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Expiration Unlock Condition Address in Output with Expiration Unlock Condition", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveExpirationUnlockCondition, } }, @@ -7273,7 +7273,7 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { UnlockConditions: iotago.BasicOutputUnlockConditions{ &iotago.AddressUnlockCondition{Address: address}, &iotago.StorageDepositReturnUnlockCondition{ - ReturnAddress: ident, + ReturnAddress: addr, }, }, } @@ -7282,14 +7282,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Storage Deposit Return Unlock Condition Address in Output with Storage Deposit Return Unlock Condition", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveOutputsWithStorageDepositReturnUnlockCondition(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveOutputsWithStorageDepositReturnUnlockCondition(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Storage Deposit Return Unlock Condition Address in Output with Storage Deposit Return Unlock Condition", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveStorageDepositReturnUnlockCondition, } }, @@ -7307,14 +7307,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Account Output Address in Account Output", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveAccountOutputs(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveAccountOutputs(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Account Output Address in Account Output", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveAccountOutput, } }, @@ -7332,14 +7332,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Anchor Output Address in State Controller UC in Anchor Output", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveAnchorOutputs(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveAnchorOutputs(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Anchor Output Address in State Controller UC in Anchor Output", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveAnchorOutput, } }, @@ -7357,14 +7357,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Anchor Output Address in Governor UC in Anchor Output", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveAnchorOutputs(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveAnchorOutputs(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Anchor Output Address in Governor UC in Anchor Output", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveAnchorOutput, } }, @@ -7382,14 +7382,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - NFT Output Address in NFT Output", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveNFTOutputs(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveNFTOutputs(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non NFT Output Address in NFT Output", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveNFTOutput, } }, @@ -7408,14 +7408,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Delegation Output Address in Delegation Output", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveDelegationOutputs(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveDelegationOutputs(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Delegation Output Address in Delegation Output", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveDelegationOutput, } }, @@ -7438,14 +7438,14 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { func() testParameters { return testParameters{ name: "ok - Mana Return Address in Output with Mana", - address: iotago.RestrictedAddressWithCapabilities(addr, iotago.WithAddressCanReceiveMana(true), iotago.WithAddressCanReceiveOutputsWithExpirationUnlockCondition(true)), + address: iotago.RestrictedAddressWithCapabilities(randAddr, iotago.WithAddressCanReceiveMana(true), iotago.WithAddressCanReceiveOutputsWithExpirationUnlockCondition(true)), wantErr: nil, } }, func() testParameters { return testParameters{ name: "fail - Non Mana Return Address in Output with Mana", - address: iotago.RestrictedAddressWithCapabilities(addr), + address: iotago.RestrictedAddressWithCapabilities(randAddr), wantErr: iotago.ErrAddressCannotReceiveMana, } }, @@ -7460,7 +7460,7 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { inputIDs[0]: &iotago.BasicOutput{ Amount: iotago.BaseToken(1_000_000), UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: ident}, + &iotago.AddressUnlockCondition{Address: addr}, }, }, } @@ -7476,7 +7476,7 @@ func TestTxSyntacticAddressRestrictions(t *testing.T) { output, }, } - sigs, err := transaction.Sign(identAddrKeys) + sigs, err := transaction.Sign(addrAddrKeys) require.NoError(t, err) return inputs, sigs[0], transaction @@ -7532,8 +7532,8 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { wantErr error } - _, edIdent, edIdentAddrKeys := tpkg.RandEd25519Identity() - _, implicitAccountIdent, implicitAccountIdentAddrKeys := tpkg.RandImplicitAccountIdentity() + _, edAddr, edAddrAddrKeys := tpkg.RandEd25519Identity() + _, implicitAccountAddr, implicitAccountAddrAddrKeys := tpkg.RandImplicitAccountIdentity() exampleAmount := iotago.BaseToken(1_000_000) exampleMana := iotago.Mana(10_000_000) exampleNativeTokenFeature := tpkg.RandNativeTokenFeature() @@ -7547,7 +7547,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { dummyImplicitAccount := &iotago.BasicOutput{ Amount: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, } exampleMetadataFeature := &iotago.MetadataFeature{Entries: iotago.MetadataFeatureEntries{"data": tpkg.RandBytes(40)}} @@ -7562,13 +7562,13 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { input: &iotago.BasicOutput{ Amount: exampleAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: edIdent}, + &iotago.AddressUnlockCondition{Address: edAddr}, }, Features: iotago.BasicOutputFeatures{ exampleNativeTokenFeature, }, }, - unlockTarget: edIdent, + unlockTarget: edAddr, }, } @@ -7581,11 +7581,11 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, }, - keys: []iotago.AddressKeys{edIdentAddrKeys}, + keys: []iotago.AddressKeys{edAddrAddrKeys}, wantErr: nil, }, { @@ -7595,12 +7595,12 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { &iotago.BasicOutput{ Amount: exampleAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, &iotago.TimelockUnlockCondition{Slot: 500}, }, }, }, - keys: []iotago.AddressKeys{edIdentAddrKeys}, + keys: []iotago.AddressKeys{edAddrAddrKeys}, wantErr: iotago.ErrAddressCannotReceiveTimelockUnlockCondition, }, { @@ -7610,7 +7610,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { &iotago.BasicOutput{ Amount: exampleAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, &iotago.ExpirationUnlockCondition{ // The implicit account creation address should disallow this expiration UC. ReturnAddress: tpkg.RandEd25519Address(), @@ -7619,7 +7619,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{edIdentAddrKeys}, + keys: []iotago.AddressKeys{edAddrAddrKeys}, wantErr: iotago.ErrAddressCannotReceiveExpirationUnlockCondition, }, { @@ -7629,7 +7629,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { &iotago.BasicOutput{ Amount: exampleAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, &iotago.StorageDepositReturnUnlockCondition{ // The implicit account creation address should disallow this SDRUC. ReturnAddress: tpkg.RandEd25519Address(), @@ -7638,7 +7638,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{edIdentAddrKeys}, + keys: []iotago.AddressKeys{edAddrAddrKeys}, wantErr: iotago.ErrAddressCannotReceiveStorageDepositReturnUnlockCondition, }, { @@ -7648,11 +7648,11 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { &iotago.BasicOutput{ Amount: exampleAmount, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, Features: iotago.BasicOutputFeatures{ &iotago.SenderFeature{ - Address: edIdentAddrKeys.Address, + Address: edAddrAddrKeys.Address, }, &iotago.MetadataFeature{Entries: iotago.MetadataFeatureEntries{"data": tpkg.RandBytes(40)}}, &iotago.TagFeature{ @@ -7665,7 +7665,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{edIdentAddrKeys}, + keys: []iotago.AddressKeys{edAddrAddrKeys}, wantErr: nil, }, { @@ -7677,10 +7677,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: exampleMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -7696,7 +7696,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID1, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{ @@ -7711,7 +7711,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys}, wantErr: nil, }, { @@ -7723,13 +7723,13 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: exampleMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, Features: iotago.BasicOutputFeatures{ exampleNativeTokenFeature, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -7744,7 +7744,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: 21200, Mana: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: edIdent}, + &iotago.AddressUnlockCondition{Address: edAddr}, }, Features: iotago.BasicOutputFeatures{ exampleNativeTokenFeature, @@ -7756,7 +7756,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID1, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{ @@ -7771,7 +7771,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys}, wantErr: nil, }, { @@ -7783,10 +7783,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: exampleMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -7802,13 +7802,13 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID1, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{}, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys}, wantErr: iotago.ErrBlockIssuerNotExpired, }, { @@ -7820,10 +7820,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: exampleMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -7837,11 +7837,11 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: exampleMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: edIdent}, + &iotago.AddressUnlockCondition{Address: edAddr}, }, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys}, wantErr: iotago.ErrImplicitAccountDestructionDisallowed, }, { @@ -7853,10 +7853,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: minAmountImplicitAccount, Mana: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -7872,7 +7872,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID1, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{ @@ -7885,7 +7885,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys}, wantErr: nil, }, { @@ -7897,13 +7897,13 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: minAmountImplicitAccount + exampleMetadataFeatureStorageDeposit, Mana: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, Features: iotago.BasicOutputFeatures{ exampleMetadataFeature, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -7919,7 +7919,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID1, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{ @@ -7933,7 +7933,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys}, wantErr: nil, }, { @@ -7945,10 +7945,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: minAmountImplicitAccount, Mana: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, { inputID: tpkg.RandOutputID(1), @@ -7956,10 +7956,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: edIdent}, + &iotago.AddressUnlockCondition{Address: edAddr}, }, }, - unlockTarget: edIdent, + unlockTarget: edAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -7976,7 +7976,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID1, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{ @@ -7989,7 +7989,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys, edIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys, edAddrAddrKeys}, wantErr: nil, }, { @@ -8001,10 +8001,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: minAmountImplicitAccount, Mana: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, { inputID: outputID2, @@ -8012,10 +8012,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -8032,7 +8032,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID1, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{ @@ -8050,7 +8050,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID2, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{ @@ -8063,7 +8063,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { }, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys, edIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys, edAddrAddrKeys}, wantErr: iotago.ErrMultipleImplicitAccountCreationAddresses, }, { @@ -8075,10 +8075,10 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Amount: exampleAmount, Mana: exampleMana, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, }, - unlockTarget: implicitAccountIdent, + unlockTarget: implicitAccountAddr, }, }, resolvedBICInputSet: vm.BlockIssuanceCreditInputSet{ @@ -8094,7 +8094,7 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { AccountID: accountID1, UnlockConditions: iotago.AccountOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, Features: iotago.AccountOutputFeatures{ @@ -8111,12 +8111,12 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { Mana: exampleMana / 2, UnlockConditions: iotago.BasicOutputUnlockConditions{ &iotago.AddressUnlockCondition{ - Address: edIdent, + Address: edAddr, }, }, }, }, - keys: []iotago.AddressKeys{implicitAccountIdentAddrKeys}, + keys: []iotago.AddressKeys{implicitAccountAddrAddrKeys}, wantErr: iotago.ErrManaMovedOffBlockIssuerAccount, }, } @@ -8171,12 +8171,12 @@ func TestTxSemanticImplicitAccountCreationAndTransition(t *testing.T) { // Ensure that the storage score offset for implicit accounts is the // minimum required for a full block issuer account. func TestTxSyntacticImplicitAccountMinDeposit(t *testing.T) { - _, implicitAccountIdent, _ := tpkg.RandImplicitAccountIdentity() + _, implicitAccountAddr, _ := tpkg.RandImplicitAccountIdentity() implicitAccount := &iotago.BasicOutput{ Amount: 0, UnlockConditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: implicitAccountIdent}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddr}, }, } storageScore := implicitAccount.StorageScore(testAPI.StorageScoreStructure(), nil) @@ -8205,10 +8205,10 @@ func TestTxSyntacticImplicitAccountMinDeposit(t *testing.T) { } func validateAndExecuteSignedTransaction(tx *iotago.SignedTransaction, resolvedInputs vm.ResolvedInputs, execFunctions ...vm.ExecFunc) (err error) { - unlockedIdentities, err := novaVM.ValidateUnlocks(tx, resolvedInputs) + unlockedAddrs, err := novaVM.ValidateUnlocks(tx, resolvedInputs) if err != nil { return err } - return lo.Return2(novaVM.Execute(tx.Transaction, resolvedInputs, unlockedIdentities, execFunctions...)) + return lo.Return2(novaVM.Execute(tx.Transaction, resolvedInputs, unlockedAddrs, execFunctions...)) } diff --git a/vm/vm.go b/vm/vm.go index 8e0d171e7..ca5ef24bd 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -12,10 +12,10 @@ import ( // VirtualMachine executes and validates transactions. type VirtualMachine interface { - // ValidateUnlocks validates the unlocks of the given SignedTransaction and returns the unlocked identities. - ValidateUnlocks(signedTransaction *iotago.SignedTransaction, inputs ResolvedInputs) (unlockedIdentities UnlockedIdentities, err error) + // ValidateUnlocks validates the unlocks of the given SignedTransaction and returns the unlocked addresses. + ValidateUnlocks(signedTransaction *iotago.SignedTransaction, inputs ResolvedInputs) (unlockedAddrs UnlockedAddresses, err error) // Execute executes the given tx in the VM. It is possible to optionally override the default execution functions. - Execute(transaction *iotago.Transaction, inputs ResolvedInputs, unlockedIdentities UnlockedIdentities, execFunctions ...ExecFunc) (outputs []iotago.Output, err error) + Execute(transaction *iotago.Transaction, inputs ResolvedInputs, unlockedAddrs UnlockedAddresses, execFunctions ...ExecFunc) (outputs []iotago.Output, err error) // ChainSTVF executes the chain state transition validation function. ChainSTVF(vmParams *Params, transType iotago.ChainTransitionType, input *ChainOutputWithIDs, next iotago.ChainOutput) error } @@ -31,8 +31,8 @@ type Params struct { // WorkingSet contains fields which get automatically populated // by the library during execution of a SignedTransaction. type WorkingSet struct { - // The identities which are successfully unlocked from the input side. - UnlockedIdents UnlockedIdentities + // The addresses which are successfully unlocked from the input side. + UnlockedAddrs UnlockedAddresses // The UTXO inputs to the transaction. UTXOInputs iotago.Outputs[iotago.Output] // The mapping of OutputID to the actual inputs. @@ -155,14 +155,14 @@ func RunVMFuncs(vm VirtualMachine, vmParams *Params, execFuncs ...ExecFunc) erro return nil } -// UnlockedIdentities defines a set of identities which are unlocked from the input side of a SignedTransaction. -// The value represent the index of the unlock which unlocked the identity. -type UnlockedIdentities map[string]*UnlockedIdentity +// UnlockedAddresses defines a set of addresses which are unlocked from the input side of a SignedTransaction. +// The value represent the index of the unlock which unlocked the address. +type UnlockedAddresses map[string]*unlockedAddress -// SigUnlock performs a signature unlock check and adds the given ident to the set of unlocked identities if +// SigUnlock performs a signature unlock check and adds the given address to the set of unlocked addresses if // the signature is valid, otherwise returns an error. -func (unlockedIdents UnlockedIdentities) SigUnlock(ident iotago.DirectUnlockableAddress, essence []byte, sig iotago.Signature, inputIndex uint16, checkUnlockOnly bool) error { - if err := ident.Unlock(essence, sig); err != nil { +func (unlockedAddrs UnlockedAddresses) SigUnlock(addr iotago.DirectUnlockableAddress, essence []byte, sig iotago.Signature, inputIndex uint16, checkUnlockOnly bool) error { + if err := addr.Unlock(essence, sig); err != nil { return ierrors.Wrapf(err, "input %d's address is not unlocked through its signature unlock", inputIndex) } @@ -170,8 +170,8 @@ func (unlockedIdents UnlockedIdentities) SigUnlock(ident iotago.DirectUnlockable return nil } - unlockedIdents[ident.Key()] = &UnlockedIdentity{ - Ident: ident, + unlockedAddrs[addr.Key()] = &unlockedAddress{ + Address: addr, UnlockedAt: inputIndex, ReferencedBy: map[uint16]struct{}{}, } @@ -179,11 +179,11 @@ func (unlockedIdents UnlockedIdentities) SigUnlock(ident iotago.DirectUnlockable return nil } -// RefUnlock performs a check whether the given ident is unlocked at ref and if so, -// adds the index of the input to the set of unlocked inputs by this identity. -func (unlockedIdents UnlockedIdentities) RefUnlock(identKey string, ref uint16, inputIndex uint16, checkUnlockOnly bool) error { - ident, has := unlockedIdents[identKey] - if !has || ident.UnlockedAt != ref { +// RefUnlock performs a check whether the given address is unlocked at ref and if so, +// adds the index of the input to the set of unlocked inputs by this address. +func (unlockedAddrs UnlockedAddresses) RefUnlock(addrKey string, ref uint16, inputIndex uint16, checkUnlockOnly bool) error { + addr, has := unlockedAddrs[addrKey] + if !has || addr.UnlockedAt != ref { return ierrors.Errorf("input %d is not unlocked through input %d's unlock", inputIndex, ref) } @@ -191,16 +191,16 @@ func (unlockedIdents UnlockedIdentities) RefUnlock(identKey string, ref uint16, return nil } - ident.ReferencedBy[inputIndex] = struct{}{} + addr.ReferencedBy[inputIndex] = struct{}{} return nil } // MultiUnlock performs a check whether all given unlocks are valid and if so, -// adds the index of the input to the set of unlocked inputs by this identity. -func (unlockedIdents UnlockedIdentities) MultiUnlock(ident *iotago.MultiAddress, multiUnlock *iotago.MultiUnlock, inputIndex uint16, unlockedIdentities UnlockedIdentities, essenceMsgToSign []byte) error { - if len(ident.Addresses) != len(multiUnlock.Unlocks) { - return ierrors.Wrapf(iotago.ErrMultiAddressLengthUnlockLengthMismatch, "input %d has a multi address (%T) but the amount of addresses does not match the unlocks %d != %d", inputIndex, ident, len(ident.Addresses), len(multiUnlock.Unlocks)) +// adds the index of the input to the set of unlocked inputs by this address. +func (unlockedAddrs UnlockedAddresses) MultiUnlock(addr *iotago.MultiAddress, multiUnlock *iotago.MultiUnlock, inputIndex uint16, essenceMsgToSign []byte) error { + if len(addr.Addresses) != len(multiUnlock.Unlocks) { + return ierrors.Wrapf(iotago.ErrMultiAddressLengthUnlockLengthMismatch, "input %d has a multi address (%T) but the amount of addresses does not match the unlocks %d != %d", inputIndex, addr, len(addr.Addresses), len(multiUnlock.Unlocks)) } var cumulativeUnlockedWeight uint16 @@ -216,21 +216,21 @@ func (unlockedIdents UnlockedIdentities) MultiUnlock(ident *iotago.MultiAddress, default: // ATTENTION: we perform the checks only, but we do not unlock the input yet. - if err := unlockIdent(ident.Addresses[subIndex].Address, unlock, inputIndex, unlockedIdentities, essenceMsgToSign, true); err != nil { + if err := unlockAddress(addr.Addresses[subIndex].Address, unlock, inputIndex, unlockedAddrs, essenceMsgToSign, true); err != nil { return err } // the unlock was successful, add the weight of the address - cumulativeUnlockedWeight += uint16(ident.Addresses[subIndex].Weight) + cumulativeUnlockedWeight += uint16(addr.Addresses[subIndex].Weight) } } // check if the threshold for a successful unlock was reached - if cumulativeUnlockedWeight < ident.Threshold { - return ierrors.Wrapf(iotago.ErrMultiAddressUnlockThresholdNotReached, "input %d has a multi address (%T) but the threshold of valid unlocks was not reached %d < %d", inputIndex, ident, cumulativeUnlockedWeight, ident.Threshold) + if cumulativeUnlockedWeight < addr.Threshold { + return ierrors.Wrapf(iotago.ErrMultiAddressUnlockThresholdNotReached, "input %d has a multi address (%T) but the threshold of valid unlocks was not reached %d < %d", inputIndex, addr, cumulativeUnlockedWeight, addr.Threshold) } - unlockedIdents[ident.Key()] = &UnlockedIdentity{ - Ident: ident, + unlockedAddrs[addr.Key()] = &unlockedAddress{ + Address: addr, UnlockedAt: inputIndex, ReferencedBy: map[uint16]struct{}{}, } @@ -238,26 +238,26 @@ func (unlockedIdents UnlockedIdentities) MultiUnlock(ident *iotago.MultiAddress, return nil } -// AddUnlockedChain allocates an UnlockedIdentity for the given chain. -func (unlockedIdents UnlockedIdentities) AddUnlockedChain(chainAddr iotago.ChainAddress, inputIndex uint16) { - unlockedIdents[chainAddr.Key()] = &UnlockedIdentity{ - Ident: chainAddr, +// AddUnlockedChain allocates an unlockedAddress for the given chain. +func (unlockedAddrs UnlockedAddresses) AddUnlockedChain(chainAddr iotago.ChainAddress, inputIndex uint16) { + unlockedAddrs[chainAddr.Key()] = &unlockedAddress{ + Address: chainAddr, UnlockedAt: inputIndex, ReferencedBy: map[uint16]struct{}{}, } } -func (unlockedIdents UnlockedIdentities) String() string { +func (unlockedAddrs UnlockedAddresses) String() string { var b strings.Builder - idents := make([]*UnlockedIdentity, 0, len(unlockedIdents)) - for _, ident := range unlockedIdents { - idents = append(idents, ident) + addrs := make([]*unlockedAddress, 0, len(unlockedAddrs)) + for _, addr := range unlockedAddrs { + addrs = append(addrs, addr) } - sort.Slice(idents, func(i, j int) bool { - x, y := idents[i].UnlockedAt, idents[j].UnlockedAt + sort.Slice(addrs, func(i, j int) bool { + x, y := addrs[i].UnlockedAt, addrs[j].UnlockedAt // prefer to show direct unlockable addresses first in string if x == y { - if _, is := idents[i].Ident.(iotago.ChainAddress); is { + if _, is := addrs[i].Address.(iotago.ChainAddress); is { return false } @@ -266,54 +266,54 @@ func (unlockedIdents UnlockedIdentities) String() string { return x < y }) - for _, ident := range idents { - b.WriteString(ident.String() + "\n") + for _, addr := range addrs { + b.WriteString(addr.String() + "\n") } return b.String() } // UnlockedBy checks whether the given input was unlocked either directly by a signature or indirectly -// through a ReferentialUnlock by the given identity. -func (unlockedIdents UnlockedIdentities) UnlockedBy(inputIndex uint16, identKey string) bool { - unlockedIdent, has := unlockedIdents[identKey] +// through a ReferentialUnlock by the given address. +func (unlockedAddrs UnlockedAddresses) UnlockedBy(inputIndex uint16, addrKey string) bool { + unlockedAddr, has := unlockedAddrs[addrKey] if !has { return false } - if unlockedIdent.UnlockedAt == inputIndex { + if unlockedAddr.UnlockedAt == inputIndex { return true } - _, refUnlocked := unlockedIdent.ReferencedBy[inputIndex] + _, refUnlocked := unlockedAddr.ReferencedBy[inputIndex] return refUnlocked } -// UnlockedIdentity represents an unlocked identity. -type UnlockedIdentity struct { - // The source ident which got unlocked. - Ident iotago.Address - // The index at which this identity has been unlocked. +// unlockedAddress represents an unlocked address. +type unlockedAddress struct { + // The source address which got unlocked. + Address iotago.Address + // The index at which this address has been unlocked. UnlockedAt uint16 - // A set of input/unlock-block indices which referenced this unlocked identity. + // A set of input/unlock-block indices which referenced this unlocked address. ReferencedBy map[uint16]struct{} } -func (unlockedIdent *UnlockedIdentity) String() string { - refs := make([]int, 0, len(unlockedIdent.ReferencedBy)) - for ref := range unlockedIdent.ReferencedBy { +func (unlockedAddr *unlockedAddress) String() string { + refs := make([]int, 0, len(unlockedAddr.ReferencedBy)) + for ref := range unlockedAddr.ReferencedBy { refs = append(refs, int(ref)) } sort.Ints(refs) - return fmt.Sprintf("ident %s (%s), unlocked at %d, ref unlocks at %v", unlockedIdent.Ident, unlockedIdent.Ident.Type(), - unlockedIdent.UnlockedAt, refs) + return fmt.Sprintf("address %s (%s), unlocked at %d, ref unlocks at %v", unlockedAddr.Address, unlockedAddr.Address.Type(), + unlockedAddr.UnlockedAt, refs) } // IsIssuerOnOutputUnlocked checks whether the issuer in an IssuerFeature of this new ChainOutput has been unlocked. // This function is a no-op if the chain output does not contain an IssuerFeature. -func IsIssuerOnOutputUnlocked(output iotago.ChainOutputImmutable, unlockedIdents UnlockedIdentities) error { +func IsIssuerOnOutputUnlocked(output iotago.ChainOutputImmutable, unlockedAddrs UnlockedAddresses) error { immFeats := output.ImmutableFeatureSet() if len(immFeats) == 0 { return nil @@ -324,8 +324,8 @@ func IsIssuerOnOutputUnlocked(output iotago.ChainOutputImmutable, unlockedIdents return nil } - issuer := resolveUnderlyingIdent(issuerFeat.Address) - if _, isUnlocked := unlockedIdents[issuer.Key()]; !isUnlocked { + issuer := resolveUnderlyingAddress(issuerFeat.Address) + if _, isUnlocked := unlockedAddrs[issuer.Key()]; !isUnlocked { return iotago.ErrIssuerFeatureNotUnlocked } @@ -339,9 +339,9 @@ func IsIssuerOnOutputUnlocked(output iotago.ChainOutputImmutable, unlockedIdents //nolint:revive type ExecFunc func(vm VirtualMachine, svCtx *Params) error -// ValidateUnlocks produces the UnlockedIdentities which will be set into the given Params and verifies that inputs are +// ValidateUnlocks produces the UnlockedAddresses which will be set into the given Params and verifies that inputs are // correctly unlocked and that the inputs commitment matches. -func ValidateUnlocks(signedTransaction *iotago.SignedTransaction, resolvedInputs ResolvedInputs) (unlockedIdentities UnlockedIdentities, err error) { +func ValidateUnlocks(signedTransaction *iotago.SignedTransaction, resolvedInputs ResolvedInputs) (unlockedAddrs UnlockedAddresses, err error) { utxoInputs, err := signedTransaction.Transaction.Inputs() if err != nil { return nil, ierrors.Wrap(err, "failed to get inputs from transaction") @@ -362,16 +362,16 @@ func ValidateUnlocks(signedTransaction *iotago.SignedTransaction, resolvedInputs return nil, ierrors.Wrapf(err, "failed to compute signing message") } - unlockedIdentities = make(UnlockedIdentities) + unlockedAddrs = make(UnlockedAddresses) outChains := signedTransaction.Transaction.Outputs.ChainOutputSet(txID) for inputIndex, input := range inputs { - if err = unlockOutput(signedTransaction.Transaction, resolvedInputs.CommitmentInput, input, signedTransaction.Unlocks[inputIndex], uint16(inputIndex), unlockedIdentities, outChains, essenceMsgToSign); err != nil { + if err = unlockOutput(signedTransaction.Transaction, resolvedInputs.CommitmentInput, input, signedTransaction.Unlocks[inputIndex], uint16(inputIndex), unlockedAddrs, outChains, essenceMsgToSign); err != nil { return nil, err } // since this input is now unlocked, and it is a ChainOutput, the chain's address becomes automatically unlocked if chainConstrOutput, is := input.(iotago.ChainOutput); is && chainConstrOutput.ChainID().Addressable() { - // mark this ChainOutput's identity as unlocked by this input + // mark this ChainOutput's address as unlocked by this input chainID := chainConstrOutput.ChainID() if chainID.Empty() { //nolint:forcetypeassert // we can safely assume that this is an UTXOIDChainID @@ -392,25 +392,25 @@ func ValidateUnlocks(signedTransaction *iotago.SignedTransaction, resolvedInputs } } - unlockedIdentities.AddUnlockedChain(chainID.ToAddress(), uint16(inputIndex)) + unlockedAddrs.AddUnlockedChain(chainID.ToAddress(), uint16(inputIndex)) } } - return unlockedIdentities, err + return unlockedAddrs, err } -func identToUnlock(transaction *iotago.Transaction, input iotago.Output, inputIndex uint16, outChains iotago.ChainOutputSet) (iotago.Address, error) { +func addressToUnlock(transaction *iotago.Transaction, input iotago.Output, inputIndex uint16, outChains iotago.ChainOutputSet) (iotago.Address, error) { switch in := input.(type) { - case iotago.TransIndepIdentOutput: - return in.Ident(), nil + case iotago.OwnerTransitionIndependentOutput: + return in.Owner(), nil - case iotago.TransDepIdentOutput: + case iotago.OwnerTransitionDependentOutput: chainID := in.ChainID() if chainID.Empty() { utxoChainID, is := chainID.(iotago.UTXOIDChainID) if !is { - return nil, iotago.ErrTransDepIdentOutputNonUTXOChainID + return nil, iotago.ErrOwnerTransitionDependentOutputNonUTXOChainID } //nolint:forcetypeassert // we can safely assume that this is an UTXOInput chainID = utxoChainID.FromOutputID(transaction.TransactionEssence.Inputs[inputIndex].(*iotago.UTXOInput).OutputID()) @@ -418,18 +418,18 @@ func identToUnlock(transaction *iotago.Transaction, input iotago.Output, inputIn next := outChains[chainID] if next == nil { - return in.Ident(nil) + return in.Owner(nil) } - nextTransDepIdentOutput, ok := next.(iotago.TransDepIdentOutput) + nextOwnerTransitionDependentOutput, ok := next.(iotago.OwnerTransitionDependentOutput) if !ok { - return nil, iotago.ErrTransDepIdentOutputNextInvalid + return nil, iotago.ErrOwnerTransitionDependentOutputNextInvalid } - return in.Ident(nextTransDepIdentOutput) + return in.Owner(nextOwnerTransitionDependentOutput) default: - panic(fmt.Sprintf("unknown ident output type in semantic unlocks: %T", in)) + panic(fmt.Sprintf("unknown address output type in semantic unlocks: %T", in)) } } @@ -448,46 +448,46 @@ func checkExpiration(output iotago.Output, commitmentInput VMCommitmentInput, pr return nil, nil } -func unlockIdent(ownerIdent iotago.Address, unlock iotago.Unlock, inputIndex uint16, unlockedIdentities UnlockedIdentities, essenceMsgToSign []byte, checkUnlockOnly bool) error { - switch owner := ownerIdent.(type) { +func unlockAddress(ownerAddr iotago.Address, unlock iotago.Unlock, inputIndex uint16, unlockedAddrs UnlockedAddresses, essenceMsgToSign []byte, checkUnlockOnly bool) error { + switch owner := ownerAddr.(type) { case iotago.ChainAddress: refUnlock, isReferentialUnlock := unlock.(iotago.ReferentialUnlock) - if !isReferentialUnlock || !refUnlock.Chainable() || !refUnlock.SourceAllowed(ownerIdent) { + if !isReferentialUnlock || !refUnlock.Chainable() || !refUnlock.SourceAllowed(ownerAddr) { return ierrors.WithMessagef( iotago.ErrChainAddressUnlockInvalid, "input %d has a chain address of type %s but its corresponding unlock is of type %s", inputIndex, owner.Type(), unlock.Type(), ) } - if err := unlockedIdentities.RefUnlock(owner.Key(), refUnlock.Ref(), inputIndex, checkUnlockOnly); err != nil { + if err := unlockedAddrs.RefUnlock(owner.Key(), refUnlock.Ref(), inputIndex, checkUnlockOnly); err != nil { return ierrors.Errorf("%w %s (%s): %w", iotago.ErrChainAddressUnlockInvalid, owner, owner.Type(), err) } case iotago.DirectUnlockableAddress: switch uBlock := unlock.(type) { case iotago.ReferentialUnlock: - // ReferentialUnlock for DirectUnlockableAddress are only allowed if the unlock is not chainable, and the owner ident is not a ChainAddress. - if uBlock.Chainable() || !uBlock.SourceAllowed(ownerIdent) { + // ReferentialUnlock for DirectUnlockableAddress are only allowed if the unlock is not chainable, and the owner address is not a ChainAddress. + if uBlock.Chainable() || !uBlock.SourceAllowed(ownerAddr) { return ierrors.WithMessagef( iotago.ErrDirectUnlockableAddressUnlockInvalid, "input %d has a non-chain address of type %s but its corresponding unlock of type %s is chainable or not allowed", inputIndex, owner.Type(), unlock.Type(), ) } - if err := unlockedIdentities.RefUnlock(owner.Key(), uBlock.Ref(), inputIndex, checkUnlockOnly); err != nil { + if err := unlockedAddrs.RefUnlock(owner.Key(), uBlock.Ref(), inputIndex, checkUnlockOnly); err != nil { return ierrors.Errorf("%w %s (%s): %w", iotago.ErrDirectUnlockableAddressUnlockInvalid, owner, owner.Type(), err) } case *iotago.SignatureUnlock: // owner must not be unlocked already - if unlockedIdent, wasAlreadyUnlocked := unlockedIdentities[owner.Key()]; wasAlreadyUnlocked { + if unlockedAddr, wasAlreadyUnlocked := unlockedAddrs[owner.Key()]; wasAlreadyUnlocked { return ierrors.WithMessagef( iotago.ErrDirectUnlockableAddressUnlockInvalid, - "input %d's address is already unlocked through input %d's unlock but the input uses a non referential unlock of type %s", inputIndex, unlockedIdent.UnlockedAt, unlock.Type(), + "input %d's address is already unlocked through input %d's unlock but the input uses a non referential unlock of type %s", inputIndex, unlockedAddr.UnlockedAt, unlock.Type(), ) } - if err := unlockedIdentities.SigUnlock(owner, essenceMsgToSign, uBlock.Signature, inputIndex, checkUnlockOnly); err != nil { + if err := unlockedAddrs.SigUnlock(owner, essenceMsgToSign, uBlock.Signature, inputIndex, checkUnlockOnly); err != nil { return ierrors.Join(iotago.ErrDirectUnlockableAddressUnlockInvalid, iotago.ErrUnlockSignatureInvalid, err) } @@ -498,24 +498,24 @@ func unlockIdent(ownerIdent iotago.Address, unlock iotago.Unlock, inputIndex uin case *iotago.MultiAddress: switch uBlock := unlock.(type) { case iotago.ReferentialUnlock: - if uBlock.Chainable() || !uBlock.SourceAllowed(ownerIdent) { + if uBlock.Chainable() || !uBlock.SourceAllowed(ownerAddr) { return ierrors.WithMessagef(iotago.ErrMultiAddressUnlockInvalid, "input %d has a non-chain address of %s but its corresponding unlock of type %s is chainable or not allowed", inputIndex, owner.Type(), unlock.Type(), ) } - if err := unlockedIdentities.RefUnlock(owner.Key(), uBlock.Ref(), inputIndex, checkUnlockOnly); err != nil { + if err := unlockedAddrs.RefUnlock(owner.Key(), uBlock.Ref(), inputIndex, checkUnlockOnly); err != nil { return ierrors.Errorf("%w %s (%s): %w", iotago.ErrMultiAddressUnlockInvalid, owner, owner.Type(), err) } case *iotago.MultiUnlock: // owner must not be unlocked already - if unlockedIdent, wasAlreadyUnlocked := unlockedIdentities[owner.Key()]; wasAlreadyUnlocked { - return ierrors.WithMessagef(iotago.ErrMultiAddressUnlockInvalid, "input %d's address is already unlocked through input %d's unlock but the input uses a non referential unlock", inputIndex, unlockedIdent.UnlockedAt) + if unlockedAddr, wasAlreadyUnlocked := unlockedAddrs[owner.Key()]; wasAlreadyUnlocked { + return ierrors.WithMessagef(iotago.ErrMultiAddressUnlockInvalid, "input %d's address is already unlocked through input %d's unlock but the input uses a non referential unlock", inputIndex, unlockedAddr.UnlockedAt) } - if err := unlockedIdentities.MultiUnlock(owner, uBlock, inputIndex, unlockedIdentities, essenceMsgToSign); err != nil { + if err := unlockedAddrs.MultiUnlock(owner, uBlock, inputIndex, essenceMsgToSign); err != nil { return ierrors.Join(iotago.ErrMultiAddressUnlockInvalid, err) } @@ -530,10 +530,10 @@ func unlockIdent(ownerIdent iotago.Address, unlock iotago.Unlock, inputIndex uin return nil } -// resolveUnderlyingIdent returns the underlying address in case of a restricted address. +// resolveUnderlyingAddress returns the underlying address in case of a restricted address. // this way we handle restricted addresses like normal addresses in the unlock logic. -func resolveUnderlyingIdent(ident iotago.Address) iotago.Address { - switch addr := ident.(type) { +func resolveUnderlyingAddress(addr iotago.Address) iotago.Address { + switch addr := addr.(type) { case *iotago.RestrictedAddress: return addr.Address default: @@ -541,23 +541,23 @@ func resolveUnderlyingIdent(ident iotago.Address) iotago.Address { } } -func unlockOutput(transaction *iotago.Transaction, commitmentInput VMCommitmentInput, input iotago.Output, unlock iotago.Unlock, inputIndex uint16, unlockedIdentities UnlockedIdentities, outChains iotago.ChainOutputSet, essenceMsgToSign []byte) error { - ownerIdent, err := identToUnlock(transaction, input, inputIndex, outChains) +func unlockOutput(transaction *iotago.Transaction, commitmentInput VMCommitmentInput, input iotago.Output, unlock iotago.Unlock, inputIndex uint16, unlockedAddrs UnlockedAddresses, outChains iotago.ChainOutputSet, essenceMsgToSign []byte) error { + ownerAddr, err := addressToUnlock(transaction, input, inputIndex, outChains) if err != nil { - return ierrors.Errorf("unable to retrieve ident to unlock of input %d: %w", inputIndex, err) + return ierrors.Errorf("unable to retrieve address to unlock of input %d: %w", inputIndex, err) } - if actualIdentToUnlock, err := checkExpiration(input, commitmentInput, transaction.API.ProtocolParameters()); err != nil { + if actualAddrToUnlock, err := checkExpiration(input, commitmentInput, transaction.API.ProtocolParameters()); err != nil { return err - } else if actualIdentToUnlock != nil { - ownerIdent = actualIdentToUnlock + } else if actualAddrToUnlock != nil { + ownerAddr = actualAddrToUnlock } - return unlockIdent(resolveUnderlyingIdent(ownerIdent), unlock, inputIndex, unlockedIdentities, essenceMsgToSign, false) + return unlockAddress(resolveUnderlyingAddress(ownerAddr), unlock, inputIndex, unlockedAddrs, essenceMsgToSign, false) } // ExecFuncSenderUnlocked validates that for SenderFeature occurring on the output side, -// the given identity is unlocked on the input side. +// the given address is unlocked on the input side. func ExecFuncSenderUnlocked() ExecFunc { return func(_ VirtualMachine, vmParams *Params) error { for outputIndex, output := range vmParams.WorkingSet.Tx.Outputs { @@ -567,8 +567,8 @@ func ExecFuncSenderUnlocked() ExecFunc { } // check unlocked - sender := resolveUnderlyingIdent(senderFeat.Address) - if _, isUnlocked := vmParams.WorkingSet.UnlockedIdents[sender.Key()]; !isUnlocked { + sender := resolveUnderlyingAddress(senderFeat.Address) + if _, isUnlocked := vmParams.WorkingSet.UnlockedAddrs[sender.Key()]; !isUnlocked { return ierrors.Wrapf(iotago.ErrSenderFeatureNotUnlocked, "output %d", outputIndex) } } @@ -604,14 +604,14 @@ func ExecFuncBalancedMana() ExecFunc { } // ExecFuncBalancedBaseTokens validates that the base tokens are balanced from the input/output side. -// It additionally also incorporates the check whether return amounts via StorageDepositReturnUnlockCondition(s) for specified identities +// It additionally also incorporates the check whether return amounts via StorageDepositReturnUnlockCondition(s) for specified addresses // are fulfilled from the output side. func ExecFuncBalancedBaseTokens() ExecFunc { return func(_ VirtualMachine, vmParams *Params) error { // note that due to syntactic validation of outputs, input and output base token amount sums // are always within bounds of the total token supply var in, out iotago.BaseToken - inputSumReturnAmountPerIdent := make(map[string]iotago.BaseToken) + inputSumReturnAmountPerAddress := make(map[string]iotago.BaseToken) for inputID, input := range vmParams.WorkingSet.UTXOInputsSet { in += input.BaseTokenAmount() @@ -620,25 +620,25 @@ func ExecFuncBalancedBaseTokens() ExecFunc { continue } - returnIdent := returnUnlockCond.ReturnAddress.Key() + returnAddr := returnUnlockCond.ReturnAddress.Key() - // if the return ident unlocked this input, then the return amount does + // if the return address unlocked this input, then the return amount does // not have to be fulfilled (this can happen implicit through an expiration condition) - if vmParams.WorkingSet.UnlockedIdents.UnlockedBy(vmParams.WorkingSet.InputIDToIndex[inputID], returnIdent) { + if vmParams.WorkingSet.UnlockedAddrs.UnlockedBy(vmParams.WorkingSet.InputIDToIndex[inputID], returnAddr) { continue } - inputSumReturnAmountPerIdent[returnIdent] += returnUnlockCond.Amount + inputSumReturnAmountPerAddress[returnAddr] += returnUnlockCond.Amount } - outputSimpleTransfersPerIdent := make(map[string]iotago.BaseToken) + outputSimpleTransfersPerAddr := make(map[string]iotago.BaseToken) for _, output := range vmParams.WorkingSet.Tx.Outputs { outAmount := output.BaseTokenAmount() out += outAmount // accumulate simple transfers for StorageDepositReturnUnlockCondition checks if basicOutput, is := output.(*iotago.BasicOutput); is && basicOutput.IsSimpleTransfer() { - outputSimpleTransfersPerIdent[basicOutput.Ident().Key()] += outAmount + outputSimpleTransfersPerAddr[basicOutput.Owner().Key()] += outAmount } } @@ -646,13 +646,13 @@ func ExecFuncBalancedBaseTokens() ExecFunc { return ierrors.Wrapf(iotago.ErrInputOutputBaseTokenMismatch, "in %d, out %d", in, out) } - for ident, returnSum := range inputSumReturnAmountPerIdent { - outSum, has := outputSimpleTransfersPerIdent[ident] + for addr, returnSum := range inputSumReturnAmountPerAddress { + outSum, has := outputSimpleTransfersPerAddr[addr] if !has { - return ierrors.Wrapf(iotago.ErrReturnAmountNotFulFilled, "return amount of %d not fulfilled as there is no output for %s", returnSum, ident) + return ierrors.Wrapf(iotago.ErrReturnAmountNotFulFilled, "return amount of %d not fulfilled as there is no output for %s", returnSum, addr) } if outSum < returnSum { - return ierrors.Wrapf(iotago.ErrReturnAmountNotFulFilled, "return amount of %d not fulfilled as output is only %d for %s", returnSum, outSum, ident) + return ierrors.Wrapf(iotago.ErrReturnAmountNotFulFilled, "return amount of %d not fulfilled as output is only %d for %s", returnSum, outSum, addr) } } From 46f95037dc674a1da33708786083507654ed0f0a Mon Sep 17 00:00:00 2001 From: muXxer Date: Mon, 26 Feb 2024 18:33:59 +0100 Subject: [PATCH 2/2] Rename Ref to Reference/Referential unlocks --- gen/unlock_ref.tmpl | 6 ++-- input.go | 9 ++--- input_test.go | 2 +- signed_transaction.go | 2 +- unlock.go | 62 ++++++++++++++++---------------- unlock_account.gen.go | 6 ++-- unlock_anchor.gen.go | 6 ++-- unlock_nft.gen.go | 6 ++-- unlock_reference.gen.go | 6 ++-- unlock_test.go | 18 +++++----- vm/nova/stvf_test.go | 76 +++++++++++++++++++-------------------- vm/nova/vm.go | 10 +++--- vm/vm.go | 78 ++++++++++++++++++++--------------------- workscore.go | 2 +- 14 files changed, 145 insertions(+), 144 deletions(-) diff --git a/gen/unlock_ref.tmpl b/gen/unlock_ref.tmpl index 7d5cc5fb4..e0962e9fb 100644 --- a/gen/unlock_ref.tmpl +++ b/gen/unlock_ref.tmpl @@ -4,9 +4,9 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// {{.Name}} is an Unlock which references a previous unlock. +// {{.Name}} is an Unlock which references a previous input/unlock. type {{.Name}} struct { - // The other unlock this {{.Name}} references to. + // The other input/unlock this {{.Name}} references to. Reference uint16 `serix:""` } @@ -26,7 +26,7 @@ func ({{.Receiver}} *{{.Name}}) Chainable() bool { {{if index .Features "chainable"}} return true {{else}} return false {{end}} } -func ({{.Receiver}} *{{.Name}}) Ref() uint16 { +func ({{.Receiver}} *{{.Name}}) ReferencedInputIndex() uint16 { return {{.Receiver}}.Reference } diff --git a/input.go b/input.go index 6c0032eb9..1cefc66d1 100644 --- a/input.go +++ b/input.go @@ -80,17 +80,17 @@ type Input interface { Type() InputType } -// InputsSyntacticalUnique returns an ElementValidationFunc which checks that every input has a unique UTXO ref. +// InputsSyntacticalUnique returns an ElementValidationFunc which checks that every input has a unique reference UTXO index. func InputsSyntacticalUnique() ElementValidationFunc[Input] { utxoSet := map[string]int{} return func(index int, input Input) error { switch castInput := input.(type) { case *UTXOInput: - utxoRef := castInput.OutputID() - k := string(utxoRef[:]) + referencedOutputID := castInput.OutputID() + k := string(referencedOutputID[:]) if j, has := utxoSet[k]; has { - return ierrors.Wrapf(ErrInputUTXORefsNotUnique, "input %d and %d share the same UTXO ref", j, index) + return ierrors.Wrapf(ErrInputUTXORefsNotUnique, "input %d and %d share the same referenced UTXO index", j, index) } utxoSet[k] = index default: @@ -106,6 +106,7 @@ func InputsSyntacticalIndicesWithinBounds() ElementValidationFunc[Input] { return func(index int, input Input) error { switch castInput := input.(type) { case *UTXOInput: + // TODO: do we really want to check the max value on the input side? if castInput.Index() < RefUTXOIndexMin || castInput.Index() > RefUTXOIndexMax { return ierrors.Wrapf(ErrRefUTXOIndexInvalid, "input %d", index) } diff --git a/input_test.go b/input_test.go index 45e29ac43..c9548ad1d 100644 --- a/input_test.go +++ b/input_test.go @@ -131,7 +131,7 @@ func TestInputsSyntacticalIndicesWithinBounds(t *testing.T) { wantErr: nil, }, { - name: "fail - invalid UTXO ref index", + name: "fail - invalid reference UTXO index", inputs: iotago.Inputs[iotago.Input]{ &iotago.UTXOInput{ TransactionID: [36]byte{}, diff --git a/signed_transaction.go b/signed_transaction.go index 75ef7d794..c93efa97f 100644 --- a/signed_transaction.go +++ b/signed_transaction.go @@ -106,7 +106,7 @@ func (t *SignedTransaction) syntacticallyValidate() error { } if err := ValidateUnlocks(t.Unlocks, - UnlocksSigUniqueAndRefValidator(t.API), + SignatureUniqueAndReferenceUnlocksValidator(t.API), ); err != nil { return ierrors.Errorf("invalid unlocks: %w", err) } diff --git a/unlock.go b/unlock.go index d3f4946ba..a90b41e5a 100644 --- a/unlock.go +++ b/unlock.go @@ -50,8 +50,8 @@ var ( ) var ( - // ErrSigUnlockNotUnique gets returned if sig unlocks making part of a transaction aren't unique. - ErrSigUnlockNotUnique = ierrors.New("signature unlock must be unique") + // ErrSignatureUnlockNotUnique gets returned if sig unlocks making part of a transaction aren't unique. + ErrSignatureUnlockNotUnique = ierrors.New("signature unlock must be unique") // ErrUnlockSignatureInvalid gets returned when a signature in an unlock is invalid. ErrUnlockSignatureInvalid = ierrors.New("signature in unlock is invalid") // ErrMultiUnlockNotUnique gets returned if multi unlocks making part of a transaction aren't unique. @@ -62,8 +62,8 @@ var ( ErrMultiAddressLengthUnlockLengthMismatch = ierrors.New("multi address length and multi unlock length do not match") // ErrReferentialUnlockInvalid gets returned when a ReferentialUnlock is invalid. ErrReferentialUnlockInvalid = ierrors.New("invalid referential unlock") - // ErrSigUnlockHasNilSig gets returned if a signature unlock contains a nil signature. - ErrSigUnlockHasNilSig = ierrors.New("signature is nil") + // ErrSignatureUnlockHasNilSignature gets returned if a signature unlock contains a nil signature. + ErrSignatureUnlockHasNilSignature = ierrors.New("signature is nil") // ErrUnknownUnlockType gets returned for unknown unlock. ErrUnknownUnlockType = ierrors.New("unknown unlock type") // ErrNestedMultiUnlock gets returned when a MultiUnlock is nested inside a MultiUnlock. @@ -124,8 +124,8 @@ type Unlock interface { type ReferentialUnlock interface { Unlock - // Ref returns the index of the Unlock this ReferentialUnlock references. - Ref() uint16 + // ReferencedInputIndex returns the index of the Input/Unlock this ReferentialUnlock references. + ReferencedInputIndex() uint16 // Chainable indicates whether this ReferentialUnlock can reference another ReferentialUnlock. Chainable() bool // SourceAllowed tells whether the given Address is allowed to be the source of this ReferentialUnlock. @@ -145,7 +145,7 @@ func publicKeyBytesFromSignatureBlock(signature Signature) ([]byte, error) { // UnlockValidatorFunc which given the index and the Unlock itself, runs validations and returns an error if any should fail. type UnlockValidatorFunc func(index int, unlock Unlock) error -// UnlocksSigUniqueAndRefValidator returns a validator which checks that: +// SignatureUniqueAndReferenceUnlocksValidator returns a validator which checks that: // 1. SignatureUnlock(s) are unique (compared by public key) // - SignatureUnlock(s) inside different MultiUnlock(s) don't need to be unique, // as long as there is no equal SignatureUnlock(s) outside of a MultiUnlock(s). @@ -155,11 +155,11 @@ type UnlockValidatorFunc func(index int, unlock Unlock) error // 5. MultiUnlock(s) are not nested // 6. MultiUnlock(s) are unique // 7. ReferenceUnlock(s) to MultiUnlock(s) are not nested in MultiUnlock(s) -func UnlocksSigUniqueAndRefValidator(api API) UnlockValidatorFunc { - seenSigUnlocks := map[uint16]struct{}{} +func SignatureUniqueAndReferenceUnlocksValidator(api API) UnlockValidatorFunc { + seenSignatureUnlocks := map[uint16]struct{}{} seenSigBlockPubkeyBytes := map[string]int{} seenSigBlockPubkeyBytesInMultiUnlocks := map[string]int{} - seenRefUnlocks := map[uint16]ReferentialUnlock{} + seenReferentialUnlocks := map[uint16]ReferentialUnlock{} seenMultiUnlocks := map[uint16]struct{}{} seenMultiUnlockBytes := map[string]int{} @@ -167,7 +167,7 @@ func UnlocksSigUniqueAndRefValidator(api API) UnlockValidatorFunc { switch unlock := u.(type) { case *SignatureUnlock: if unlock.Signature == nil { - return ierrors.Wrapf(ErrSigUnlockHasNilSig, "at index %d is nil", index) + return ierrors.Wrapf(ErrSignatureUnlockHasNilSignature, "at index %d is nil", index) } sigBlockPubKeyBytes, err := publicKeyBytesFromSignatureBlock(unlock.Signature) @@ -177,34 +177,34 @@ func UnlocksSigUniqueAndRefValidator(api API) UnlockValidatorFunc { // we check for duplicated pubkeys in SignatureUnlock(s) if existingIndex, exists := seenSigBlockPubkeyBytes[string(sigBlockPubKeyBytes)]; exists { - return ierrors.Wrapf(ErrSigUnlockNotUnique, "signature unlock block at index %d is the same as %d", index, existingIndex) + return ierrors.Wrapf(ErrSignatureUnlockNotUnique, "signature unlock block at index %d is the same as %d", index, existingIndex) } // we also need to check for duplicated pubkeys in MultiUnlock(s) if existingIndex, exists := seenSigBlockPubkeyBytesInMultiUnlocks[string(sigBlockPubKeyBytes)]; exists { - return ierrors.Wrapf(ErrSigUnlockNotUnique, "signature unlock block at index %d is the same as in multi unlock at index %d", index, existingIndex) + return ierrors.Wrapf(ErrSignatureUnlockNotUnique, "signature unlock block at index %d is the same as in multi unlock at index %d", index, existingIndex) } - seenSigUnlocks[uint16(index)] = struct{}{} + seenSignatureUnlocks[uint16(index)] = struct{}{} seenSigBlockPubkeyBytes[string(sigBlockPubKeyBytes)] = index case ReferentialUnlock: - if prevRef := seenRefUnlocks[unlock.Ref()]; prevRef != nil { + if prevReferentialUnlock := seenReferentialUnlocks[unlock.ReferencedInputIndex()]; prevReferentialUnlock != nil { if !unlock.Chainable() { - return ierrors.Wrapf(ErrReferentialUnlockInvalid, "%d references existing referential unlock %d but it does not support chaining", index, unlock.Ref()) + return ierrors.Wrapf(ErrReferentialUnlockInvalid, "%d references existing referential unlock %d but it does not support chaining", index, unlock.ReferencedInputIndex()) } - seenRefUnlocks[uint16(index)] = unlock + seenReferentialUnlocks[uint16(index)] = unlock break } // must reference a sig or multi unlock here - _, hasSigUnlock := seenSigUnlocks[unlock.Ref()] - _, hasMultiUnlock := seenMultiUnlocks[unlock.Ref()] - if !hasSigUnlock && !hasMultiUnlock { - return ierrors.Wrapf(ErrReferentialUnlockInvalid, "%d references non existent unlock %d", index, unlock.Ref()) + _, hasSignatureUnlock := seenSignatureUnlocks[unlock.ReferencedInputIndex()] + _, hasMultiUnlock := seenMultiUnlocks[unlock.ReferencedInputIndex()] + if !hasSignatureUnlock && !hasMultiUnlock { + return ierrors.Wrapf(ErrReferentialUnlockInvalid, "%d references non existent unlock %d", index, unlock.ReferencedInputIndex()) } - seenRefUnlocks[uint16(index)] = unlock + seenReferentialUnlocks[uint16(index)] = unlock case *MultiUnlock: multiUnlockBytes, err := api.Encode(unlock) @@ -220,7 +220,7 @@ func UnlocksSigUniqueAndRefValidator(api API) UnlockValidatorFunc { switch subUnlock := subU.(type) { case *SignatureUnlock: if subUnlock.Signature == nil { - return ierrors.Wrapf(ErrSigUnlockHasNilSig, "at index %d.%d is nil", index, subIndex) + return ierrors.Wrapf(ErrSignatureUnlockHasNilSignature, "at index %d.%d is nil", index, subIndex) } sigBlockPubKeyBytes, err := publicKeyBytesFromSignatureBlock(subUnlock.Signature) @@ -230,29 +230,29 @@ func UnlocksSigUniqueAndRefValidator(api API) UnlockValidatorFunc { // we check for duplicated pubkeys in SignatureUnlock(s) if existingIndex, exists := seenSigBlockPubkeyBytes[string(sigBlockPubKeyBytes)]; exists { - return ierrors.Wrapf(ErrSigUnlockNotUnique, "signature unlock block at index %d.%d is the same as %d", index, subIndex, existingIndex) + return ierrors.Wrapf(ErrSignatureUnlockNotUnique, "signature unlock block at index %d.%d is the same as %d", index, subIndex, existingIndex) } - // we don't set the index here in "seenSigUnlocks" because there is no concept of reference unlocks inside of multi unlocks + // we don't set the index here in "seenSignatureUnlocks" because there is no concept of reference unlocks inside of multi unlocks // add the pubkey to "seenSigBlockPubkeyBytesInMultiUnlocks", so we can check that pubkeys from a multi unlock are not reused in a normal SignatureUnlock seenSigBlockPubkeyBytesInMultiUnlocks[string(sigBlockPubKeyBytes)] = index case ReferentialUnlock: - if prevRef := seenRefUnlocks[subUnlock.Ref()]; prevRef != nil { + if prevRef := seenReferentialUnlocks[subUnlock.ReferencedInputIndex()]; prevRef != nil { if !subUnlock.Chainable() { - return ierrors.Wrapf(ErrReferentialUnlockInvalid, "%d.%d references existing referential unlock %d but it does not support chaining", index, subIndex, subUnlock.Ref()) + return ierrors.Wrapf(ErrReferentialUnlockInvalid, "%d.%d references existing referential unlock %d but it does not support chaining", index, subIndex, subUnlock.ReferencedInputIndex()) } - // we don't set the index here in "seenRefUnlocks" because it's not allowed to reference an unlock within a multi unlock + // we don't set the index here in "seenReferentialUnlocks" because it's not allowed to reference an unlock within a multi unlock continue } // must reference a sig unlock here // we don't check for "seenMultiUnlocks" here because we don't want to nest "reference unlocks to multi unlocks" in multi unlocks - if _, has := seenSigUnlocks[subUnlock.Ref()]; !has { - return ierrors.Wrapf(ErrReferentialUnlockInvalid, "%d.%d references non existent unlock %d", index, subIndex, subUnlock.Ref()) + if _, has := seenSignatureUnlocks[subUnlock.ReferencedInputIndex()]; !has { + return ierrors.Wrapf(ErrReferentialUnlockInvalid, "%d.%d references non existent unlock %d", index, subIndex, subUnlock.ReferencedInputIndex()) } - // we don't set the index here in "seenRefUnlocks" because it's not allowed to reference an unlock within a multi unlock + // we don't set the index here in "seenReferentialUnlocks" because it's not allowed to reference an unlock within a multi unlock case *MultiUnlock: return ierrors.Wrapf(ErrNestedMultiUnlock, "unlock at index %d.%d is invalid", index, subIndex) diff --git a/unlock_account.gen.go b/unlock_account.gen.go index 4b96e2faf..070d2045b 100644 --- a/unlock_account.gen.go +++ b/unlock_account.gen.go @@ -4,9 +4,9 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// AccountUnlock is an Unlock which references a previous unlock. +// AccountUnlock is an Unlock which references a previous input/unlock. type AccountUnlock struct { - // The other unlock this AccountUnlock references to. + // The other input/unlock this AccountUnlock references to. Reference uint16 `serix:""` } @@ -26,7 +26,7 @@ func (r *AccountUnlock) Chainable() bool { return true } -func (r *AccountUnlock) Ref() uint16 { +func (r *AccountUnlock) ReferencedInputIndex() uint16 { return r.Reference } diff --git a/unlock_anchor.gen.go b/unlock_anchor.gen.go index 02f799c3a..9017b0946 100644 --- a/unlock_anchor.gen.go +++ b/unlock_anchor.gen.go @@ -4,9 +4,9 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// AnchorUnlock is an Unlock which references a previous unlock. +// AnchorUnlock is an Unlock which references a previous input/unlock. type AnchorUnlock struct { - // The other unlock this AnchorUnlock references to. + // The other input/unlock this AnchorUnlock references to. Reference uint16 `serix:""` } @@ -26,7 +26,7 @@ func (r *AnchorUnlock) Chainable() bool { return true } -func (r *AnchorUnlock) Ref() uint16 { +func (r *AnchorUnlock) ReferencedInputIndex() uint16 { return r.Reference } diff --git a/unlock_nft.gen.go b/unlock_nft.gen.go index 4b3e6a1a0..38f979727 100644 --- a/unlock_nft.gen.go +++ b/unlock_nft.gen.go @@ -4,9 +4,9 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// NFTUnlock is an Unlock which references a previous unlock. +// NFTUnlock is an Unlock which references a previous input/unlock. type NFTUnlock struct { - // The other unlock this NFTUnlock references to. + // The other input/unlock this NFTUnlock references to. Reference uint16 `serix:""` } @@ -26,7 +26,7 @@ func (r *NFTUnlock) Chainable() bool { return true } -func (r *NFTUnlock) Ref() uint16 { +func (r *NFTUnlock) ReferencedInputIndex() uint16 { return r.Reference } diff --git a/unlock_reference.gen.go b/unlock_reference.gen.go index 250c74642..fe57122a0 100644 --- a/unlock_reference.gen.go +++ b/unlock_reference.gen.go @@ -4,9 +4,9 @@ import ( "github.com/iotaledger/hive.go/serializer/v2" ) -// ReferenceUnlock is an Unlock which references a previous unlock. +// ReferenceUnlock is an Unlock which references a previous input/unlock. type ReferenceUnlock struct { - // The other unlock this ReferenceUnlock references to. + // The other input/unlock this ReferenceUnlock references to. Reference uint16 `serix:""` } @@ -26,7 +26,7 @@ func (r *ReferenceUnlock) Chainable() bool { return false } -func (r *ReferenceUnlock) Ref() uint16 { +func (r *ReferenceUnlock) ReferencedInputIndex() uint16 { return r.Reference } diff --git a/unlock_test.go b/unlock_test.go index 4aa18aaac..83637f143 100644 --- a/unlock_test.go +++ b/unlock_test.go @@ -50,7 +50,7 @@ func TestUnlock_DeSerialize(t *testing.T) { } } -func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { +func TestSignatureUniqueAndReferenceUnlocksValidator(t *testing.T) { tests := []struct { name string unlocks iotago.Unlocks @@ -119,7 +119,7 @@ func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { Signature: [64]byte{}, }}, }, - wantErr: iotago.ErrSigUnlockNotUnique, + wantErr: iotago.ErrSignatureUnlockNotUnique, }, { name: "fail - signature reuse outside and inside the multi unlocks - 1", @@ -137,7 +137,7 @@ func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { }, }, }, - wantErr: iotago.ErrSigUnlockNotUnique, + wantErr: iotago.ErrSignatureUnlockNotUnique, }, { name: "fail - signature reuse outside and inside the multi unlocks - 2", @@ -159,7 +159,7 @@ func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { Signature: [64]byte{}, }}, }, - wantErr: iotago.ErrSigUnlockNotUnique, + wantErr: iotago.ErrSignatureUnlockNotUnique, }, { name: "ok - duplicate ed25519 sig block in different multi unlocks", @@ -210,7 +210,7 @@ func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { wantErr: iotago.ErrMultiUnlockNotUnique, }, { - name: "fail - reference unlock invalid ref", + name: "fail - reference unlock invalid reference", unlocks: iotago.Unlocks{ tpkg.RandEd25519SignatureUnlock(), tpkg.RandEd25519SignatureUnlock(), @@ -219,7 +219,7 @@ func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { wantErr: iotago.ErrReferentialUnlockInvalid, }, { - name: "fail - reference unlock invalid ref in multi unlock", + name: "fail - reference unlock invalid reference in multi unlock", unlocks: iotago.Unlocks{ tpkg.RandEd25519SignatureUnlock(), tpkg.RandEd25519SignatureUnlock(), @@ -232,7 +232,7 @@ func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { wantErr: iotago.ErrReferentialUnlockInvalid, }, { - name: "fail - reference unlock refs non sig unlock", + name: "fail - reference unlock references non sig unlock", unlocks: iotago.Unlocks{ tpkg.RandEd25519SignatureUnlock(), &iotago.ReferenceUnlock{Reference: 0}, @@ -241,7 +241,7 @@ func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { wantErr: iotago.ErrReferentialUnlockInvalid, }, { - name: "fail - reference unlock refs non sig unlock in multi unlock", + name: "fail - reference unlock references non sig unlock in multi unlock", unlocks: iotago.Unlocks{ tpkg.RandEd25519SignatureUnlock(), &iotago.ReferenceUnlock{Reference: 0}, @@ -318,7 +318,7 @@ func TestUnlocksSigUniqueAndRefValidator(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - valFunc := iotago.UnlocksSigUniqueAndRefValidator(tpkg.ZeroCostTestAPI) + valFunc := iotago.SignatureUniqueAndReferenceUnlocksValidator(tpkg.ZeroCostTestAPI) var runErr error for index, unlock := range tt.unlocks { if err := valFunc(index, unlock); err != nil { diff --git a/vm/nova/stvf_test.go b/vm/nova/stvf_test.go index a531f433a..f16b4ac34 100644 --- a/vm/nova/stvf_test.go +++ b/vm/nova/stvf_test.go @@ -96,7 +96,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ @@ -134,7 +134,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 900, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -174,7 +174,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 10001, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -214,7 +214,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 991, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -254,7 +254,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -295,7 +295,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -336,7 +336,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -376,7 +376,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -436,7 +436,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -489,7 +489,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ @@ -540,7 +540,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ @@ -586,7 +586,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -642,7 +642,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -702,7 +702,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -762,7 +762,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -824,7 +824,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -878,7 +878,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -938,7 +938,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -998,7 +998,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -1061,7 +1061,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -1112,7 +1112,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: currentSlot, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -1452,7 +1452,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, Commitment: &iotago.Commitment{ Slot: 990, @@ -1536,7 +1536,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 990, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ exampleAccountID: 10, @@ -1589,7 +1589,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ @@ -1641,7 +1641,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 990, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ exampleAccountID: 10, @@ -1699,7 +1699,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 990, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ exampleAccountID: 10, @@ -1758,7 +1758,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 900, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ exampleAccountID: -1, @@ -1816,7 +1816,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 900, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ @@ -1872,7 +1872,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 900, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, BIC: map[iotago.AccountID]iotago.BlockIssuanceCredits{ exampleAccountID: 10, @@ -1931,7 +1931,7 @@ func TestAccountOutput_ValidateStateTransition(t *testing.T) { Slot: 0, }, UnlockedAddrs: vm.UnlockedAddresses{ - exampleAddress.Key(): {UnlockedAt: 0}, + exampleAddress.Key(): {UnlockedAtInputIndex: 0}, }, InChains: map[iotago.ChainID]*vm.ChainOutputWithIDs{ // serial number 5 @@ -2085,7 +2085,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ @@ -2163,7 +2163,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleGovCtrl.Key(): {UnlockedAt: 0}, + exampleGovCtrl.Key(): {UnlockedAtInputIndex: 0}, }, Commitment: &iotago.Commitment{ Slot: 990, @@ -2216,7 +2216,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleStateCtrl.Key(): {UnlockedAt: 0}, + exampleStateCtrl.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ API: tpkg.ZeroCostTestAPI, @@ -2263,7 +2263,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleStateCtrl.Key(): {UnlockedAt: 0}, + exampleStateCtrl.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ @@ -2308,7 +2308,7 @@ func TestAnchorOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleStateCtrl.Key(): {UnlockedAt: 0}, + exampleStateCtrl.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ @@ -3034,7 +3034,7 @@ func TestNFTOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, Tx: &iotago.Transaction{ TransactionEssence: &iotago.TransactionEssence{ @@ -3751,7 +3751,7 @@ func TestImplicitAccountOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, BIC: exampleBIC, Commitment: &iotago.Commitment{ @@ -3796,7 +3796,7 @@ func TestImplicitAccountOutput_ValidateStateTransition(t *testing.T) { API: tpkg.ZeroCostTestAPI, WorkingSet: &vm.WorkingSet{ UnlockedAddrs: vm.UnlockedAddresses{ - exampleIssuer.Key(): {UnlockedAt: 0}, + exampleIssuer.Key(): {UnlockedAtInputIndex: 0}, }, BIC: exampleBIC, Commitment: &iotago.Commitment{ diff --git a/vm/nova/vm.go b/vm/nova/vm.go index 4b704404c..7177e344f 100644 --- a/vm/nova/vm.go +++ b/vm/nova/vm.go @@ -35,12 +35,12 @@ func NewVMParamsWorkingSet(api iotago.API, t *iotago.Transaction, resolvedInputs workingSet.Tx = t workingSet.UnlockedAddrs = make(vm.UnlockedAddresses) workingSet.UTXOInputsSet = utxoInputsSet - workingSet.InputIDToIndex = make(map[iotago.OutputID]uint16) - for inputIndex, inputRef := range workingSet.Tx.TransactionEssence.Inputs { + workingSet.InputIDToInputIndex = make(map[iotago.OutputID]uint16) + for inputIndex, txInput := range workingSet.Tx.TransactionEssence.Inputs { //nolint:forcetypeassert // we can safely assume that this is an UTXOInput - ref := inputRef.(*iotago.UTXOInput).OutputID() - workingSet.InputIDToIndex[ref] = uint16(inputIndex) - input, ok := workingSet.UTXOInputsSet[ref] + txInputID := txInput.(*iotago.UTXOInput).OutputID() + workingSet.InputIDToInputIndex[txInputID] = uint16(inputIndex) + input, ok := workingSet.UTXOInputsSet[txInputID] if !ok { return nil, ierrors.Wrapf(iotago.ErrMissingUTXO, "utxo for input %d not supplied", inputIndex) } diff --git a/vm/vm.go b/vm/vm.go index ca5ef24bd..b57152d1a 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -38,7 +38,7 @@ type WorkingSet struct { // The mapping of OutputID to the actual inputs. UTXOInputsSet InputSet // The mapping of inputs' OutputID to the index. - InputIDToIndex map[iotago.OutputID]uint16 + InputIDToInputIndex map[iotago.OutputID]uint16 // The transaction for which this semantic validation happens. Tx *iotago.Transaction // The message which signatures are signing. @@ -159,9 +159,9 @@ func RunVMFuncs(vm VirtualMachine, vmParams *Params, execFuncs ...ExecFunc) erro // The value represent the index of the unlock which unlocked the address. type UnlockedAddresses map[string]*unlockedAddress -// SigUnlock performs a signature unlock check and adds the given address to the set of unlocked addresses if +// SignatureUnlock performs a signature unlock check and adds the given address to the set of unlocked addresses if // the signature is valid, otherwise returns an error. -func (unlockedAddrs UnlockedAddresses) SigUnlock(addr iotago.DirectUnlockableAddress, essence []byte, sig iotago.Signature, inputIndex uint16, checkUnlockOnly bool) error { +func (unlockedAddrs UnlockedAddresses) SignatureUnlock(addr iotago.DirectUnlockableAddress, essence []byte, sig iotago.Signature, inputIndex uint16, checkUnlockOnly bool) error { if err := addr.Unlock(essence, sig); err != nil { return ierrors.Wrapf(err, "input %d's address is not unlocked through its signature unlock", inputIndex) } @@ -171,27 +171,27 @@ func (unlockedAddrs UnlockedAddresses) SigUnlock(addr iotago.DirectUnlockableAdd } unlockedAddrs[addr.Key()] = &unlockedAddress{ - Address: addr, - UnlockedAt: inputIndex, - ReferencedBy: map[uint16]struct{}{}, + Address: addr, + UnlockedAtInputIndex: inputIndex, + ReferencedByInputIndex: map[uint16]struct{}{}, } return nil } -// RefUnlock performs a check whether the given address is unlocked at ref and if so, +// ReferentialUnlock performs a check whether the given address is unlocked at referenceInputIndex and if so, // adds the index of the input to the set of unlocked inputs by this address. -func (unlockedAddrs UnlockedAddresses) RefUnlock(addrKey string, ref uint16, inputIndex uint16, checkUnlockOnly bool) error { +func (unlockedAddrs UnlockedAddresses) ReferentialUnlock(addrKey string, referenceInputIndex uint16, inputIndex uint16, checkUnlockOnly bool) error { addr, has := unlockedAddrs[addrKey] - if !has || addr.UnlockedAt != ref { - return ierrors.Errorf("input %d is not unlocked through input %d's unlock", inputIndex, ref) + if !has || addr.UnlockedAtInputIndex != referenceInputIndex { + return ierrors.Errorf("input %d is not unlocked through input %d's unlock", inputIndex, referenceInputIndex) } if checkUnlockOnly { return nil } - addr.ReferencedBy[inputIndex] = struct{}{} + addr.ReferencedByInputIndex[inputIndex] = struct{}{} return nil } @@ -230,9 +230,9 @@ func (unlockedAddrs UnlockedAddresses) MultiUnlock(addr *iotago.MultiAddress, mu } unlockedAddrs[addr.Key()] = &unlockedAddress{ - Address: addr, - UnlockedAt: inputIndex, - ReferencedBy: map[uint16]struct{}{}, + Address: addr, + UnlockedAtInputIndex: inputIndex, + ReferencedByInputIndex: map[uint16]struct{}{}, } return nil @@ -241,9 +241,9 @@ func (unlockedAddrs UnlockedAddresses) MultiUnlock(addr *iotago.MultiAddress, mu // AddUnlockedChain allocates an unlockedAddress for the given chain. func (unlockedAddrs UnlockedAddresses) AddUnlockedChain(chainAddr iotago.ChainAddress, inputIndex uint16) { unlockedAddrs[chainAddr.Key()] = &unlockedAddress{ - Address: chainAddr, - UnlockedAt: inputIndex, - ReferencedBy: map[uint16]struct{}{}, + Address: chainAddr, + UnlockedAtInputIndex: inputIndex, + ReferencedByInputIndex: map[uint16]struct{}{}, } } @@ -254,7 +254,7 @@ func (unlockedAddrs UnlockedAddresses) String() string { addrs = append(addrs, addr) } sort.Slice(addrs, func(i, j int) bool { - x, y := addrs[i].UnlockedAt, addrs[j].UnlockedAt + x, y := addrs[i].UnlockedAtInputIndex, addrs[j].UnlockedAtInputIndex // prefer to show direct unlockable addresses first in string if x == y { if _, is := addrs[i].Address.(iotago.ChainAddress); is { @@ -281,11 +281,11 @@ func (unlockedAddrs UnlockedAddresses) UnlockedBy(inputIndex uint16, addrKey str return false } - if unlockedAddr.UnlockedAt == inputIndex { + if unlockedAddr.UnlockedAtInputIndex == inputIndex { return true } - _, refUnlocked := unlockedAddr.ReferencedBy[inputIndex] + _, refUnlocked := unlockedAddr.ReferencedByInputIndex[inputIndex] return refUnlocked } @@ -294,21 +294,21 @@ func (unlockedAddrs UnlockedAddresses) UnlockedBy(inputIndex uint16, addrKey str type unlockedAddress struct { // The source address which got unlocked. Address iotago.Address - // The index at which this address has been unlocked. - UnlockedAt uint16 - // A set of input/unlock-block indices which referenced this unlocked address. - ReferencedBy map[uint16]struct{} + // The index of the input/unlock by which this address has been unlocked. + UnlockedAtInputIndex uint16 + // A set of input/unlock indexes which referenced this address. + ReferencedByInputIndex map[uint16]struct{} } func (unlockedAddr *unlockedAddress) String() string { - refs := make([]int, 0, len(unlockedAddr.ReferencedBy)) - for ref := range unlockedAddr.ReferencedBy { - refs = append(refs, int(ref)) + inputIndexes := make([]int, 0, len(unlockedAddr.ReferencedByInputIndex)) + for inputIndex := range unlockedAddr.ReferencedByInputIndex { + inputIndexes = append(inputIndexes, int(inputIndex)) } - sort.Ints(refs) + sort.Ints(inputIndexes) - return fmt.Sprintf("address %s (%s), unlocked at %d, ref unlocks at %v", unlockedAddr.Address, unlockedAddr.Address.Type(), - unlockedAddr.UnlockedAt, refs) + return fmt.Sprintf("address %s (%s), unlocked at %d, referenced by unlocks at %v", unlockedAddr.Address, unlockedAddr.Address.Type(), + unlockedAddr.UnlockedAtInputIndex, inputIndexes) } // IsIssuerOnOutputUnlocked checks whether the issuer in an IssuerFeature of this new ChainOutput has been unlocked. @@ -451,15 +451,15 @@ func checkExpiration(output iotago.Output, commitmentInput VMCommitmentInput, pr func unlockAddress(ownerAddr iotago.Address, unlock iotago.Unlock, inputIndex uint16, unlockedAddrs UnlockedAddresses, essenceMsgToSign []byte, checkUnlockOnly bool) error { switch owner := ownerAddr.(type) { case iotago.ChainAddress: - refUnlock, isReferentialUnlock := unlock.(iotago.ReferentialUnlock) - if !isReferentialUnlock || !refUnlock.Chainable() || !refUnlock.SourceAllowed(ownerAddr) { + referentialUnlock, isReferentialUnlock := unlock.(iotago.ReferentialUnlock) + if !isReferentialUnlock || !referentialUnlock.Chainable() || !referentialUnlock.SourceAllowed(ownerAddr) { return ierrors.WithMessagef( iotago.ErrChainAddressUnlockInvalid, "input %d has a chain address of type %s but its corresponding unlock is of type %s", inputIndex, owner.Type(), unlock.Type(), ) } - if err := unlockedAddrs.RefUnlock(owner.Key(), refUnlock.Ref(), inputIndex, checkUnlockOnly); err != nil { + if err := unlockedAddrs.ReferentialUnlock(owner.Key(), referentialUnlock.ReferencedInputIndex(), inputIndex, checkUnlockOnly); err != nil { return ierrors.Errorf("%w %s (%s): %w", iotago.ErrChainAddressUnlockInvalid, owner, owner.Type(), err) } @@ -474,7 +474,7 @@ func unlockAddress(ownerAddr iotago.Address, unlock iotago.Unlock, inputIndex ui ) } - if err := unlockedAddrs.RefUnlock(owner.Key(), uBlock.Ref(), inputIndex, checkUnlockOnly); err != nil { + if err := unlockedAddrs.ReferentialUnlock(owner.Key(), uBlock.ReferencedInputIndex(), inputIndex, checkUnlockOnly); err != nil { return ierrors.Errorf("%w %s (%s): %w", iotago.ErrDirectUnlockableAddressUnlockInvalid, owner, owner.Type(), err) } @@ -483,11 +483,11 @@ func unlockAddress(ownerAddr iotago.Address, unlock iotago.Unlock, inputIndex ui if unlockedAddr, wasAlreadyUnlocked := unlockedAddrs[owner.Key()]; wasAlreadyUnlocked { return ierrors.WithMessagef( iotago.ErrDirectUnlockableAddressUnlockInvalid, - "input %d's address is already unlocked through input %d's unlock but the input uses a non referential unlock of type %s", inputIndex, unlockedAddr.UnlockedAt, unlock.Type(), + "input %d's address is already unlocked through input %d's unlock but the input uses a non referential unlock of type %s", inputIndex, unlockedAddr.UnlockedAtInputIndex, unlock.Type(), ) } - if err := unlockedAddrs.SigUnlock(owner, essenceMsgToSign, uBlock.Signature, inputIndex, checkUnlockOnly); err != nil { + if err := unlockedAddrs.SignatureUnlock(owner, essenceMsgToSign, uBlock.Signature, inputIndex, checkUnlockOnly); err != nil { return ierrors.Join(iotago.ErrDirectUnlockableAddressUnlockInvalid, iotago.ErrUnlockSignatureInvalid, err) } @@ -505,14 +505,14 @@ func unlockAddress(ownerAddr iotago.Address, unlock iotago.Unlock, inputIndex ui ) } - if err := unlockedAddrs.RefUnlock(owner.Key(), uBlock.Ref(), inputIndex, checkUnlockOnly); err != nil { + if err := unlockedAddrs.ReferentialUnlock(owner.Key(), uBlock.ReferencedInputIndex(), inputIndex, checkUnlockOnly); err != nil { return ierrors.Errorf("%w %s (%s): %w", iotago.ErrMultiAddressUnlockInvalid, owner, owner.Type(), err) } case *iotago.MultiUnlock: // owner must not be unlocked already if unlockedAddr, wasAlreadyUnlocked := unlockedAddrs[owner.Key()]; wasAlreadyUnlocked { - return ierrors.WithMessagef(iotago.ErrMultiAddressUnlockInvalid, "input %d's address is already unlocked through input %d's unlock but the input uses a non referential unlock", inputIndex, unlockedAddr.UnlockedAt) + return ierrors.WithMessagef(iotago.ErrMultiAddressUnlockInvalid, "input %d's address is already unlocked through input %d's unlock but the input uses a non referential unlock", inputIndex, unlockedAddr.UnlockedAtInputIndex) } if err := unlockedAddrs.MultiUnlock(owner, uBlock, inputIndex, essenceMsgToSign); err != nil { @@ -624,7 +624,7 @@ func ExecFuncBalancedBaseTokens() ExecFunc { // if the return address unlocked this input, then the return amount does // not have to be fulfilled (this can happen implicit through an expiration condition) - if vmParams.WorkingSet.UnlockedAddrs.UnlockedBy(vmParams.WorkingSet.InputIDToIndex[inputID], returnAddr) { + if vmParams.WorkingSet.UnlockedAddrs.UnlockedBy(vmParams.WorkingSet.InputIDToInputIndex[inputID], returnAddr) { continue } diff --git a/workscore.go b/workscore.go index 0682e3c46..e80072810 100644 --- a/workscore.go +++ b/workscore.go @@ -119,7 +119,7 @@ func (w WorkScoreParameters) MaxBlockWork() (WorkScore, error) { // allotments factor for max number of allotments addWorkScore(w.Allotment, MaxAllotmentCount) - // signature check for max number of inputs each unlocked by a maximum sized mutli unlock + // signature check for max number of inputs each unlocked by a maximum sized multi unlock addWorkScore(w.SignatureEd25519, MaxInputsCount*10) if innerErr != nil {