Skip to content

Commit

Permalink
Merge pull request #46 from iotaledger/feat/update-iota.go
Browse files Browse the repository at this point in the history
Updated to latest iota.go
  • Loading branch information
piotrm50 authored Mar 8, 2024
2 parents 72c30db + 614a129 commit f3fa2ef
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 225 deletions.
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ toolchain go1.22.0

require (
github.com/iotaledger/hive.go/app v0.0.0-20240216135101-261e99d9d84a
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240216135101-261e99d9d84a
github.com/iotaledger/hive.go/crypto v0.0.0-20240216135101-261e99d9d84a
github.com/iotaledger/hive.go/ds v0.0.0-20240216135101-261e99d9d84a
github.com/iotaledger/hive.go/ierrors v0.0.0-20240216135101-261e99d9d84a
github.com/iotaledger/hive.go/lo v0.0.0-20240216135101-261e99d9d84a
github.com/iotaledger/hive.go/log v0.0.0-20240216135101-261e99d9d84a
github.com/iotaledger/hive.go/runtime v0.0.0-20240216135101-261e99d9d84a
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/crypto v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/ds v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/ierrors v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/lo v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/log v0.0.0-20240223134921-02b9a2022431
github.com/iotaledger/hive.go/runtime v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7
github.com/iotaledger/iota.go/v4 v4.0.0-20240216140514-c867d6524642
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38
github.com/mr-tron/base58 v1.2.0
go.uber.org/atomic v1.11.0
go.uber.org/dig v1.17.1
golang.org/x/crypto v0.19.0
golang.org/x/crypto v0.21.0
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.3 // indirect
github.com/ethereum/go-ethereum v1.13.12 // indirect
github.com/ethereum/go-ethereum v1.13.14 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand All @@ -37,9 +37,9 @@ require (
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20240216135101-261e99d9d84a // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240216135101-261e99d9d84a // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20240216135101-261e99d9d84a // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20240305162344-4b8be588e1cf // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240305162344-4b8be588e1cf // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20240305162344-4b8be588e1cf // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand All @@ -55,7 +55,7 @@ require (
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
56 changes: 28 additions & 28 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.13.12 h1:iDr9UM2JWkngBHGovRJEQn4Kor7mT4gt9rUZqB5M29Y=
github.com/ethereum/go-ethereum v1.13.12/go.mod h1:hKL2Qcj1OvStXNSEDbucexqnEt1Wh4Cz329XsjAalZY=
github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0HwTQtm6CQ=
github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
Expand Down Expand Up @@ -175,30 +175,30 @@ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJ
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/iotaledger/hive.go/app v0.0.0-20240216135101-261e99d9d84a h1:o5viyYlzi6kgClLNgUW5Pay0tXMylc0FPivYgSlAc4g=
github.com/iotaledger/hive.go/app v0.0.0-20240216135101-261e99d9d84a/go.mod h1:O9agBfrnt1ykrDOzF6GXZf4ivcw+SxM9c9C86YtbxLU=
github.com/iotaledger/hive.go/constraints v0.0.0-20240216135101-261e99d9d84a h1:9xeffzciYdw9L/ebAOPg/39Bqn3p5iyOROQhQHaAEUs=
github.com/iotaledger/hive.go/constraints v0.0.0-20240216135101-261e99d9d84a/go.mod h1:JF7jjkL6tSUOXm23SWadBzBrl7eJk1DQRLc/fNoVZ+o=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240216135101-261e99d9d84a h1:+l3NjL4v700Iv+ZF7KjPALkygFOxzkByoRIoSK9bOzc=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240216135101-261e99d9d84a/go.mod h1:9HM/YmzOfdlWXYHVEWVjYhKQHOlgxBVMsr5Vf5yn5IE=
github.com/iotaledger/hive.go/crypto v0.0.0-20240216135101-261e99d9d84a h1:ux81+J6mcxYw6usZpEPLZjE6J+TNs3RaRcTHa9+5ERM=
github.com/iotaledger/hive.go/crypto v0.0.0-20240216135101-261e99d9d84a/go.mod h1:7kZh98nwJInQsIybiPXSABc/on/IsDdXyeiPLfaH+2I=
github.com/iotaledger/hive.go/ds v0.0.0-20240216135101-261e99d9d84a h1:7M1+k0H53jahg2ZDN10SociepCB+jymIZoiYaSenpbQ=
github.com/iotaledger/hive.go/ds v0.0.0-20240216135101-261e99d9d84a/go.mod h1:sE/HabIH9FWTvgaHioLN6o4rrxFMf4BuqRQwloxcamo=
github.com/iotaledger/hive.go/ierrors v0.0.0-20240216135101-261e99d9d84a h1:ugcQ43xbMZo5XYTfanIHOxQGKNpxhcatcz9ZXcX6W1o=
github.com/iotaledger/hive.go/ierrors v0.0.0-20240216135101-261e99d9d84a/go.mod h1:GQY0/35sjgT9Poi1Vrs9kFVvAkuKzGXfVh4j6CBXsAA=
github.com/iotaledger/hive.go/lo v0.0.0-20240216135101-261e99d9d84a h1:eUAtyEIYRlAPeZ2qhlEA+7T8DVoYK2h9eotlst/84SU=
github.com/iotaledger/hive.go/lo v0.0.0-20240216135101-261e99d9d84a/go.mod h1:0ycE1W59kkNjQ87odL6H4x5Ik9bXhbNk88wmo+mIYt0=
github.com/iotaledger/hive.go/log v0.0.0-20240216135101-261e99d9d84a h1:XzIuUsWPtDP7h9UbQPFW5/bjeqVjodcSCMRuF7zP5jk=
github.com/iotaledger/hive.go/log v0.0.0-20240216135101-261e99d9d84a/go.mod h1:JCv/LVVTAMoCPLzou534RoIif7CAezcWZlGYabrHsck=
github.com/iotaledger/hive.go/runtime v0.0.0-20240216135101-261e99d9d84a h1:qmfoYLK2XyPOXfldG21qHyCrbIf0sl7iJoFirvTrnO0=
github.com/iotaledger/hive.go/runtime v0.0.0-20240216135101-261e99d9d84a/go.mod h1:lAR3vbqE9g65M9VwWHiaXab2q+d89dBOFjhKgnDfK7c=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240216135101-261e99d9d84a h1:ahUFo0X9Th+8/aE6KSWiy7Eap5p0YFL6CDapP1o8dLo=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240216135101-261e99d9d84a/go.mod h1:yXQNGZUz++dB1T9RAHhWSresuTLzTC856ntdins9ivo=
github.com/iotaledger/hive.go/stringify v0.0.0-20240216135101-261e99d9d84a h1:xLreq/rXeSPdb86RnZNEPH3PUIWt56BQxK1+11+hM4I=
github.com/iotaledger/hive.go/stringify v0.0.0-20240216135101-261e99d9d84a/go.mod h1:O4p7UmsfoeLqtAUwrKbq0lXMxjY/MLQSpZSavvvvGig=
github.com/iotaledger/hive.go/constraints v0.0.0-20240305162344-4b8be588e1cf h1:SHtB0Nf1MdOAk+adIQfQGWZ++EcvrfFE4kCTMbZ7Qys=
github.com/iotaledger/hive.go/constraints v0.0.0-20240305162344-4b8be588e1cf/go.mod h1:JF7jjkL6tSUOXm23SWadBzBrl7eJk1DQRLc/fNoVZ+o=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240305162344-4b8be588e1cf h1:CxqQWH3cHX+jUx94zDeeCIe93gmygem1Y5jMrcAWJA4=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240305162344-4b8be588e1cf/go.mod h1:73ODTHUJxAoGUN0InOtuQ29LVq85pDf7GckM9d0ziqo=
github.com/iotaledger/hive.go/crypto v0.0.0-20240305162344-4b8be588e1cf h1:msheCEl+Q1y8LQjfP9VOf6t38LeCOndhHkuw3AgMfK8=
github.com/iotaledger/hive.go/crypto v0.0.0-20240305162344-4b8be588e1cf/go.mod h1:aREIB19gIhSYdY0Hl/37sg1JRH7+j3ajeJxBIQf6mig=
github.com/iotaledger/hive.go/ds v0.0.0-20240305162344-4b8be588e1cf h1:TyGz03gRMdFECQVc0gExs9W1k4lB10MPeRQohNilnmk=
github.com/iotaledger/hive.go/ds v0.0.0-20240305162344-4b8be588e1cf/go.mod h1:wfjeJj9B+MM/3yeUHfvT8Gj8bRsdl9utyh2dZg+1+B0=
github.com/iotaledger/hive.go/ierrors v0.0.0-20240305162344-4b8be588e1cf h1:aBMpx2sHnG7Esai4S7b47aUERBTV+JgoSjJKT1U4LxE=
github.com/iotaledger/hive.go/ierrors v0.0.0-20240305162344-4b8be588e1cf/go.mod h1:GQY0/35sjgT9Poi1Vrs9kFVvAkuKzGXfVh4j6CBXsAA=
github.com/iotaledger/hive.go/lo v0.0.0-20240305162344-4b8be588e1cf h1:ADrQgsSpsoMSfIlSsMHo66ush8y0z8AaFn0Nae5dztY=
github.com/iotaledger/hive.go/lo v0.0.0-20240305162344-4b8be588e1cf/go.mod h1:67oLzWYiBLGt5PN7IBVHdbt9P6oBYCx9UvMEL8ExDAc=
github.com/iotaledger/hive.go/log v0.0.0-20240223134921-02b9a2022431 h1:CxoorcruX5zlz+I3iwPxdfs1D3DJt/NQ60Kb0+YvEKs=
github.com/iotaledger/hive.go/log v0.0.0-20240223134921-02b9a2022431/go.mod h1:H5tmswUbT3o5+QiM6UPtBv7VnPf+lJtlantgpp2lzUI=
github.com/iotaledger/hive.go/runtime v0.0.0-20240305162344-4b8be588e1cf h1:gELL3pOfJADq6kLC6HkbEtFwAiVOm1cPuVy92noqjPk=
github.com/iotaledger/hive.go/runtime v0.0.0-20240305162344-4b8be588e1cf/go.mod h1:pueoYXud+HmTY2x9j/S6+ZX3M5ZyENFKPDrx3EtcwWs=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240305162344-4b8be588e1cf h1:PAwjwceOCwCclmvCzbSJb0A7EolaDJsjWqw0ixRys0M=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240305162344-4b8be588e1cf/go.mod h1:NK05G4PxwZF1m4jGANJWLhAQ2hP1Nt0L8mgCTFLsSCw=
github.com/iotaledger/hive.go/stringify v0.0.0-20240305162344-4b8be588e1cf h1:gLQTQtZZTwZBFZdx0tuM7WHpWtF1liC3c6FflZiNGXc=
github.com/iotaledger/hive.go/stringify v0.0.0-20240305162344-4b8be588e1cf/go.mod h1:O4p7UmsfoeLqtAUwrKbq0lXMxjY/MLQSpZSavvvvGig=
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 h1:t6k4MqiUov0FrBb2o2JhKlOVSdlPbIQWM8ivYHL0G0g=
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7/go.mod h1:do+N3LpeDEi9qselEC4XcjqGoRc7cWGiqBtIeBOKEMs=
github.com/iotaledger/iota.go/v4 v4.0.0-20240216140514-c867d6524642 h1:s3nISWsyLwNA4+fh19yp1CQip3pHpIgsbYIRITpl8aA=
github.com/iotaledger/iota.go/v4 v4.0.0-20240216140514-c867d6524642/go.mod h1:IZNS0qmVdoRjIbFe4VTPG7k3bzSJQBvAHL2eC/2kFT0=
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38 h1:NizJ3CALLCcJowtAtkNuDlpE4gd4qjaWZkp/kTZfeYk=
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
Expand Down Expand Up @@ -348,8 +348,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
Expand Down Expand Up @@ -425,8 +425,8 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
38 changes: 18 additions & 20 deletions pkg/evilwallet/evilwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ func (e *EvilWallet) PrepareAndPostBlockWithPayload(ctx context.Context, clt mod
return blockID, nil
}

func (e *EvilWallet) PrepareAndPostBlockWithTxBuildData(ctx context.Context, clt models.Client, txBuilder *builder.TransactionBuilder, signingKeys []iotago.AddressKeys, issuer wallet.Account) (iotago.BlockID, *iotago.Transaction, error) {
func (e *EvilWallet) PrepareAndPostBlockWithTxBuildData(ctx context.Context, clt models.Client, txBuilder *builder.TransactionBuilder, issuer wallet.Account) (iotago.BlockID, *iotago.Transaction, error) {
congestionResp, issuerResp, version, err := e.accManager.RequestBlockIssuanceData(ctx, clt, issuer)
if err != nil {
return iotago.EmptyBlockID, nil, ierrors.Wrap(err, "failed to get block built data")
}

// handle allotment strategy
txBuilder.AllotAllMana(txBuilder.CreationSlot(), issuer.ID(), 0)
signedTx, err := txBuilder.Build(iotago.NewInMemoryAddressSigner(signingKeys...))
signedTx, err := txBuilder.Build()
if err != nil {
return iotago.EmptyBlockID, nil, ierrors.Wrap(err, "failed to build and sign transaction")
}
Expand Down Expand Up @@ -255,11 +255,9 @@ func (e *EvilWallet) CreateTransaction(ctx context.Context, options ...Option) (
addrAliasMap[tempID] = alias
}
}
txBuilder, signingKeys := e.prepareTransactionBuild(inputs, outputs, buildOptions.inputWallet)
issuanceData := &models.PayloadIssuanceData{
Type: iotago.PayloadSignedTransaction,
TransactionBuilder: txBuilder,
TxSigningKeys: signingKeys,
TransactionBuilder: e.prepareTransactionBuild(inputs, outputs, buildOptions.inputWallet),
}

addedOutputs := e.addOutputsToOutputManager(outputs, buildOptions.outputWallet, tempWallet, tempAddresses)
Expand Down Expand Up @@ -524,25 +522,12 @@ func (e *EvilWallet) updateOutputBalances(ctx context.Context, buildOptions *Opt
return
}

func (e *EvilWallet) prepareTransactionBuild(inputs []*models.OutputData, outputs iotago.Outputs[iotago.Output], w *Wallet) (tx *builder.TransactionBuilder, keys []iotago.AddressKeys) {
func (e *EvilWallet) prepareTransactionBuild(inputs []*models.OutputData, outputs iotago.Outputs[iotago.Output], w *Wallet) *builder.TransactionBuilder {
clt := e.Connector().GetClient()
currentTime := time.Now()
targetSlot := clt.LatestAPI().TimeProvider().SlotFromTime(currentTime)
targetAPI := clt.APIForSlot(targetSlot)

txBuilder := builder.NewTransactionBuilder(targetAPI)

for _, input := range inputs {
txBuilder.AddInput(&builder.TxInput{UnlockTarget: input.Address, InputID: input.OutputID, Input: input.OutputStruct})
}

for _, output := range outputs {
txBuilder.AddOutput(output)
}

randomPayload := tpkg.Rand12ByteArray()
txBuilder.AddTaggedDataPayload(&iotago.TaggedData{Tag: randomPayload[:], Data: randomPayload[:]})

walletKeys := make([]iotago.AddressKeys, len(inputs))
for i, input := range inputs {
addr := input.Address
Expand All @@ -558,9 +543,22 @@ func (e *EvilWallet) prepareTransactionBuild(inputs []*models.OutputData, output
walletKeys[i] = iotago.AddressKeys{Address: addr, Keys: inputPrivateKey}
}

txBuilder := builder.NewTransactionBuilder(targetAPI, iotago.NewInMemoryAddressSigner(walletKeys...))

for _, input := range inputs {
txBuilder.AddInput(&builder.TxInput{UnlockTarget: input.Address, InputID: input.OutputID, Input: input.OutputStruct})
}

for _, output := range outputs {
txBuilder.AddOutput(output)
}

randomPayload := tpkg.Rand12ByteArray()
txBuilder.AddTaggedDataPayload(&iotago.TaggedData{Tag: randomPayload[:], Data: randomPayload[:]})

txBuilder.SetCreationSlot(targetSlot)

return txBuilder, walletKeys
return txBuilder
}

func (e *EvilWallet) PrepareCustomConflictsSpam(ctx context.Context, scenario *EvilScenario) (txsData [][]*models.PayloadIssuanceData, allAliases ScenarioAlias, err error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/evilwallet/faucetfunds.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (e *EvilWallet) splitOutput(ctx context.Context, splitOutput *models.Output
return iotago.EmptyTransactionID, err
}

_, tx, err := e.PrepareAndPostBlockWithTxBuildData(ctx, e.connector.GetClient(), issuanceData.TransactionBuilder, issuanceData.TxSigningKeys, genesisAccount)
_, tx, err := e.PrepareAndPostBlockWithTxBuildData(ctx, e.connector.GetClient(), issuanceData.TransactionBuilder, genesisAccount)
if err != nil {
return iotago.EmptyTransactionID, err
}
Expand Down
15 changes: 11 additions & 4 deletions pkg/models/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ type Client interface {
GetOutput(ctx context.Context, outputID iotago.OutputID) iotago.Output
// GetTransaction gets the transaction.
GetTransaction(ctx context.Context, txID iotago.TransactionID) (resp *iotago.SignedTransaction, err error)
// GetTransactionMetadata gets the transaction metadata.
GetTransactionMetadata(ctx context.Context, txID iotago.TransactionID) (resp *api.TransactionMetadataResponse, err error)
// GetBlockIssuance returns the latest commitment and data needed to create a new block.
GetBlockIssuance(ctx context.Context) (resp *api.IssuanceBlockHeaderResponse, err error)
// GetCongestion returns congestion data such as rmc or issuing readiness.
Expand All @@ -205,8 +207,8 @@ type Client interface {
GetCommittee(ctx context.Context) (*api.CommitteeResponse, error)
// GetValidators returns the validators for the current epoch.
GetValidators(ctx context.Context) (*api.ValidatorsResponse, bool, error)
// GetStaking returns the staking data of a given accountAddress.
GetStaking(ctx context.Context, accountAddress *iotago.AccountAddress) (resp *api.ValidatorResponse, err error)
// GetValidator returns the validator data of a given accountAddress.
GetValidator(ctx context.Context, accountAddress *iotago.AccountAddress) (resp *api.ValidatorResponse, err error)
// GetRewards returns the rewards of a given outputID.
GetRewards(ctx context.Context, outputID iotago.OutputID) (resp *api.ManaRewardsResponse, err error)

Expand Down Expand Up @@ -387,6 +389,11 @@ func (c *WebClient) GetTransaction(ctx context.Context, txID iotago.TransactionI
return tx, nil
}

// GetTransactionMetadata gets the transaction metadata.
func (c *WebClient) GetTransactionMetadata(ctx context.Context, txID iotago.TransactionID) (*api.TransactionMetadataResponse, error) {
return c.client.TransactionMetadata(ctx, txID)
}

func (c *WebClient) GetBlockIssuance(ctx context.Context) (resp *api.IssuanceBlockHeaderResponse, err error) {
return c.client.BlockIssuance(ctx)
}
Expand All @@ -403,8 +410,8 @@ func (c *WebClient) GetValidators(ctx context.Context) (*api.ValidatorsResponse,
return c.client.ValidatorsAll(ctx)
}

func (c *WebClient) GetStaking(ctx context.Context, accountAddress *iotago.AccountAddress) (resp *api.ValidatorResponse, err error) {
return c.client.StakingAccount(ctx, accountAddress)
func (c *WebClient) GetValidator(ctx context.Context, accountAddress *iotago.AccountAddress) (resp *api.ValidatorResponse, err error) {
return c.client.Validator(ctx, accountAddress)
}

func (c *WebClient) GetRewards(ctx context.Context, outputID iotago.OutputID) (*api.ManaRewardsResponse, error) {
Expand Down
1 change: 0 additions & 1 deletion pkg/models/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type PayloadIssuanceData struct {
Type iotago.PayloadType
TransactionBuilder *builder.TransactionBuilder
Payload iotago.Payload
TxSigningKeys []iotago.AddressKeys
}

type TempOutputID [32]byte
Expand Down
Loading

0 comments on commit f3fa2ef

Please sign in to comment.