diff --git a/address.go b/address.go index 7f2f74150..23dbaa964 100644 --- a/address.go +++ b/address.go @@ -173,22 +173,22 @@ type UTXOIDChainID interface { FromOutputID(id OutputID) ChainID } -func newAddress(addressType AddressType) (address Address, err error) { +func newAddress(addressType AddressType) Address { switch addressType { case AddressEd25519: - return &Ed25519Address{}, nil + return &Ed25519Address{} case AddressAccount: - return &AccountAddress{}, nil + return &AccountAddress{} case AddressNFT: - return &NFTAddress{}, nil + return &NFTAddress{} case AddressAnchor: - return &AnchorAddress{}, nil + return &AnchorAddress{} case AddressImplicitAccountCreation: - return &ImplicitAccountCreationAddress{}, nil + return &ImplicitAccountCreationAddress{} case AddressMulti: - return &MultiAddress{}, nil + return &MultiAddress{} case AddressRestricted: - return &RestrictedAddress{}, nil + return &RestrictedAddress{} default: panic(fmt.Sprintf("unknown address type %d", addressType)) } @@ -252,10 +252,7 @@ func ParseBech32(s string) (NetworkPrefix, Address, error) { } } - addr, err := newAddress(addrType) - if err != nil { - return "", nil, err - } + addr := newAddress(addrType) serixAPI := CommonSerixAPI() n, err := serixAPI.Decode(context.TODO(), addrData, addr) diff --git a/signed_transaction.go b/signed_transaction.go index aa1949d7f..61d333d4a 100644 --- a/signed_transaction.go +++ b/signed_transaction.go @@ -100,10 +100,7 @@ func (t *SignedTransaction) String() string { // syntacticallyValidate syntactically validates the SignedTransaction. func (t *SignedTransaction) syntacticallyValidate() error { // limit unlock block count = input count - inputs, err := t.Transaction.Inputs() - if err != nil { - return err - } + inputs := t.Transaction.Inputs() if len(t.Unlocks) != len(inputs) { return ierrors.WithMessagef(ErrInputUnlockCountMismatch, "unlock count %d does not match inputs count %d", len(t.Unlocks), len(inputs)) diff --git a/signed_transaction_test.go b/signed_transaction_test.go index 9e9dab614..9eb26ba86 100644 --- a/signed_transaction_test.go +++ b/signed_transaction_test.go @@ -246,17 +246,14 @@ func TestTransaction_InputTypes(t *testing.T) { }), )) - utxoInputs, err := signedTransaction.Transaction.Inputs() - require.NoError(t, err) + utxoInputs := signedTransaction.Transaction.Inputs() commitmentInput := signedTransaction.Transaction.CommitmentInput() require.NotNil(t, commitmentInput) - bicInputs, err := signedTransaction.Transaction.BICInputs() - require.NoError(t, err) + bicInputs := signedTransaction.Transaction.BICInputs() - rewardInputs, err := signedTransaction.Transaction.RewardInputs() - require.NoError(t, err) + rewardInputs := signedTransaction.Transaction.RewardInputs() require.Equal(t, 2, len(utxoInputs)) require.Equal(t, 2, len(bicInputs)) diff --git a/testlog.txt b/testlog.txt new file mode 100644 index 000000000..e69de29bb diff --git a/transaction.go b/transaction.go index 170c905f2..2a311a654 100644 --- a/transaction.go +++ b/transaction.go @@ -133,7 +133,7 @@ func (t *Transaction) Clone() *Transaction { } } -func (t *Transaction) Inputs() ([]*UTXOInput, error) { +func (t *Transaction) Inputs() []*UTXOInput { references := make([]*UTXOInput, 0, len(t.TransactionEssence.Inputs)) for _, input := range t.TransactionEssence.Inputs { switch castInput := input.(type) { @@ -144,7 +144,7 @@ func (t *Transaction) Inputs() ([]*UTXOInput, error) { } } - return references, nil + return references } // OutputsSet returns an OutputSet from the Transaction's outputs, mapped by their OutputID. @@ -161,7 +161,7 @@ func (t *Transaction) OutputsSet() (OutputSet, error) { return set, nil } -func (t *Transaction) ContextInputs() (TransactionContextInputs, error) { +func (t *Transaction) ContextInputs() TransactionContextInputs { references := make(TransactionContextInputs, 0, len(t.TransactionEssence.ContextInputs)) for _, input := range t.TransactionEssence.ContextInputs { switch castInput := input.(type) { @@ -172,10 +172,10 @@ func (t *Transaction) ContextInputs() (TransactionContextInputs, error) { } } - return references, nil + return references } -func (t *Transaction) BICInputs() ([]*BlockIssuanceCreditInput, error) { +func (t *Transaction) BICInputs() []*BlockIssuanceCreditInput { references := make([]*BlockIssuanceCreditInput, 0, len(t.TransactionEssence.ContextInputs)) for _, input := range t.TransactionEssence.ContextInputs { switch castInput := input.(type) { @@ -188,10 +188,10 @@ func (t *Transaction) BICInputs() ([]*BlockIssuanceCreditInput, error) { } } - return references, nil + return references } -func (t *Transaction) RewardInputs() ([]*RewardInput, error) { +func (t *Transaction) RewardInputs() []*RewardInput { references := make([]*RewardInput, 0, len(t.TransactionEssence.ContextInputs)) for _, input := range t.TransactionEssence.ContextInputs { switch castInput := input.(type) { @@ -204,7 +204,7 @@ func (t *Transaction) RewardInputs() ([]*RewardInput, error) { } } - return references, nil + return references } // Returns the first commitment input in the transaction if it exists or nil. diff --git a/vm/vm.go b/vm/vm.go index 70c3a35f8..d4e17f800 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -424,10 +424,7 @@ type ExecFunc func(vm VirtualMachine, svCtx *Params) error // 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) (unlockedAddrs UnlockedAddresses, err error) { - utxoInputs, err := signedTransaction.Transaction.Inputs() - if err != nil { - return nil, ierrors.Wrap(err, "failed to get inputs from transaction") - } + utxoInputs := signedTransaction.Transaction.Inputs() var inputs iotago.Outputs[iotago.Output] for _, input := range utxoInputs {