Skip to content

Instantly share code, notes, and snippets.

@dshulyak
Last active August 21, 2018 13:51
Show Gist options
  • Save dshulyak/b959b8ff3f97424b34ef9918a652a0eb to your computer and use it in GitHub Desktop.
Save dshulyak/b959b8ff3f97424b34ef9918a652a0eb to your computer and use it in GitHub Desktop.
validation for addBalance transaction
package main
import (
"bytes"
"crypto/rand"
"math/big"
"strings"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/rlp"
vipnode "github.com/vipnode/vipnode-contract/go-vipnode"
)
type Request struct {
MethodName string
NodeID [64]byte
TX *types.Transaction
Signature []byte
}
func main() {
as := make([]byte, 20)
rand.Read(as)
poolAddress := common.BytesToAddress(as)
client, err := crypto.GenerateKey()
noerror(err)
clientID := discover.PubkeyID(&client.PublicKey)
funds, err := crypto.GenerateKey()
noerror(err)
signer := types.NewEIP155Signer(big.NewInt(1))
parsed, err := abi.JSON(strings.NewReader(vipnode.VipnodePoolABI))
noerror(err)
packed, err := parsed.Pack("addBalance", clientID) // fails here because clientID is not [32]byte but [64]byte
noerror(err)
tx := types.NewTransaction(0, poolAddress, big.NewInt(10*18), 100000, big.NewInt(10*9), packed)
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), funds)
noerror(err)
tx, err = tx.WithSignature(signer, signature)
noerror(err)
req := Request{
MethodName: "vipnode_bootstrap",
TX: tx,
}
txBytes, err := rlp.EncodeToBytes(tx)
noerror(err)
hash := crypto.Keccak256([]byte(req.MethodName), txBytes)
req.Signature, err = crypto.Sign(hash, client)
noerror(err)
// tx is proxied to pool api and it verifies content. request is signed and node id can be even derived from signature key
poolTxHash := hash
clientPub, err := crypto.SigToPub(poolTxHash, req.Signature)
noerror(err)
clientIDFromPub := discover.PubkeyID(clientPub)
restored, _ := parsed.Pack("addBalance", clientIDFromPub)
must(bytes.Equal(restored, tx.Data()), "addBalance must be called with the same node id as in request")
must(tx.Value().Cmp(big.NewInt(0)) == 1, "deposit must be higher than zero")
must(*tx.To() == poolAddress, "pool api proxies only transactions sent to pool address")
// if verification passed - send transaction to ethereum pool and wait f
}
func noerror(err error) {
if err != nil {
panic(err)
}
}
func must(v bool, msg string) {
if !v {
panic(msg)
}
}
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package vipnode
import (
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// VipnodePoolABI is the input ABI used to generate the binding from.
const VipnodePoolABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"withdrawInterval\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"operator\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"clients\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"},{\"name\":\"timeLocked\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_nodeID\",\"type\":\"bytes32\"}],\"name\":\"addBalance\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"forceWithdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\"},{\"name\":\"_release\",\"type\":\"bool\"}],\"name\":\"opSettle\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"opWithdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"forceSettle\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"address\"},{\"name\":\"_nodeID\",\"type\":\"bytes32\"},{\"name\":\"_minBalance\",\"type\":\"uint256\"}],\"name\":\"checkBalance\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_operator\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"client\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"timeLocked\",\"type\":\"uint256\"}],\"name\":\"ForceSettle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"client\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"balance\",\"type\":\"uint256\"}],\"name\":\"Balance\",\"type\":\"event\"}]"
// VipnodePoolBin is the compiled bytecode used for deploying new contracts.
const VipnodePoolBin = `0x608060405262093a8060015534801561001757600080fd5b506040516020806106bc8339810160405251600160a060020a038116151561003e57600080fd5b60008054600160a060020a03909216600160a060020a031990921691909117905561064e8061006e6000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663162075d8811461009d578063570ca735146100c457806361eed2a9146100f55780636dd4c6181461012f5780637be80b391461013c578063a73e679a14610151578063ae5fa7e71461017a578063aeea1f7b14610192578063e17b4707146101a7575b600080fd5b3480156100a957600080fd5b506100b26101e2565b60408051918252519081900360200190f35b3480156100d057600080fd5b506100d96101e8565b60408051600160a060020a039092168252519081900360200190f35b34801561010157600080fd5b50610116600160a060020a03600435166101f7565b6040805192835260208301919091528051918290030190f35b61013a600435610213565b005b34801561014857600080fd5b5061013a61028c565b34801561015d57600080fd5b5061013a600160a060020a03600435166024356044351515610357565b34801561018657600080fd5b5061013a60043561044b565b34801561019e57600080fd5b5061013a61049f565b3480156101b357600080fd5b506101ce600160a060020a0360043516602435604435610509565b604080519115158252519081900360200190f35b60015481565b600054600160a060020a031681565b6002602081905260009182526040909120600181015491015482565b336000908152600260205260409020600181018054340190558115610248578054600181018255600082815260209020018290555b600181015460408051338152602081019290925280517f134e340554ff8a7d64280a2a28b982df554e2595e5bf45cd39368f31099172a69281900390910190a15050565b336000908152600260205260408120600181015490919081106102ae57600080fd5b60028201546000106102bf57600080fd5b60028201544210156102d057600080fd5b50600181018054600091829055600283018290556040519091339183156108fc0291849190818181858888f19350505050158015610312573d6000803e3d6000fd5b50600182015460408051338152602081019290925280517f134e340554ff8a7d64280a2a28b982df554e2595e5bf45cd39368f31099172a69281900390910190a15050565b600080548190600160a060020a0316331461037157600080fd5b600160a060020a0385166000908152600260205260409020600181015490925084111561039d57600080fd5b600182018054859003905582156103fb5750600181018054600091829055600283018290556040519091600160a060020a0387169183156108fc0291849190818181858888f193505050501580156103f9573d6000803e3d6000fd5b505b600182015460408051600160a060020a0388168152602081019290925280517f134e340554ff8a7d64280a2a28b982df554e2595e5bf45cd39368f31099172a69281900390910190a15050505050565b600054600160a060020a0316331461046257600080fd5b60008054604051600160a060020a039091169183156108fc02918491818181858888f1935050505015801561049b573d6000803e3d6000fd5b5050565b33600090815260026020526040812060018101549091106104bf57600080fd5b60015442016002820181905560408051338152602081019290925280517fde112f62320281f04efec46e09ed286851fdd0b428dfc7214fe0e64f9364323b9281900390910190a150565b6000610513610600565b600160a060020a0385166000908152600260209081526040808320815181546080948102820185019093526060810183815290939192849284919084018282801561057e57602002820191906000526020600020905b81548152600190910190602001808311610569575b5050505050815260200160018201548152602001600282015481525050915083826020015110156105b257600092506105f7565b5060005b8151518110156105f25781518051869190839081106105d157fe5b6020908102909101015114156105ea57600192506105f7565b6001016105b6565b600092505b50509392505050565b60606040519081016040528060608152602001600081526020016000815250905600a165627a7a72305820b6c739834fed1f68b79217abe4d4514c879f186ca3efc3b362acffb23c7d8b3e0029`
// DeployVipnodePool deploys a new Ethereum contract, binding an instance of VipnodePool to it.
func DeployVipnodePool(auth *bind.TransactOpts, backend bind.ContractBackend, _operator common.Address) (common.Address, *types.Transaction, *VipnodePool, error) {
parsed, err := abi.JSON(strings.NewReader(VipnodePoolABI))
if err != nil {
return common.Address{}, nil, nil, err
}
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(VipnodePoolBin), backend, _operator)
if err != nil {
return common.Address{}, nil, nil, err
}
return address, tx, &VipnodePool{VipnodePoolCaller: VipnodePoolCaller{contract: contract}, VipnodePoolTransactor: VipnodePoolTransactor{contract: contract}, VipnodePoolFilterer: VipnodePoolFilterer{contract: contract}}, nil
}
// VipnodePool is an auto generated Go binding around an Ethereum contract.
type VipnodePool struct {
VipnodePoolCaller // Read-only binding to the contract
VipnodePoolTransactor // Write-only binding to the contract
VipnodePoolFilterer // Log filterer for contract events
}
// VipnodePoolCaller is an auto generated read-only Go binding around an Ethereum contract.
type VipnodePoolCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// VipnodePoolTransactor is an auto generated write-only Go binding around an Ethereum contract.
type VipnodePoolTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// VipnodePoolFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type VipnodePoolFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// VipnodePoolSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type VipnodePoolSession struct {
Contract *VipnodePool // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// VipnodePoolCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type VipnodePoolCallerSession struct {
Contract *VipnodePoolCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// VipnodePoolTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type VipnodePoolTransactorSession struct {
Contract *VipnodePoolTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// VipnodePoolRaw is an auto generated low-level Go binding around an Ethereum contract.
type VipnodePoolRaw struct {
Contract *VipnodePool // Generic contract binding to access the raw methods on
}
// VipnodePoolCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type VipnodePoolCallerRaw struct {
Contract *VipnodePoolCaller // Generic read-only contract binding to access the raw methods on
}
// VipnodePoolTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type VipnodePoolTransactorRaw struct {
Contract *VipnodePoolTransactor // Generic write-only contract binding to access the raw methods on
}
// NewVipnodePool creates a new instance of VipnodePool, bound to a specific deployed contract.
func NewVipnodePool(address common.Address, backend bind.ContractBackend) (*VipnodePool, error) {
contract, err := bindVipnodePool(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &VipnodePool{VipnodePoolCaller: VipnodePoolCaller{contract: contract}, VipnodePoolTransactor: VipnodePoolTransactor{contract: contract}, VipnodePoolFilterer: VipnodePoolFilterer{contract: contract}}, nil
}
// NewVipnodePoolCaller creates a new read-only instance of VipnodePool, bound to a specific deployed contract.
func NewVipnodePoolCaller(address common.Address, caller bind.ContractCaller) (*VipnodePoolCaller, error) {
contract, err := bindVipnodePool(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &VipnodePoolCaller{contract: contract}, nil
}
// NewVipnodePoolTransactor creates a new write-only instance of VipnodePool, bound to a specific deployed contract.
func NewVipnodePoolTransactor(address common.Address, transactor bind.ContractTransactor) (*VipnodePoolTransactor, error) {
contract, err := bindVipnodePool(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &VipnodePoolTransactor{contract: contract}, nil
}
// NewVipnodePoolFilterer creates a new log filterer instance of VipnodePool, bound to a specific deployed contract.
func NewVipnodePoolFilterer(address common.Address, filterer bind.ContractFilterer) (*VipnodePoolFilterer, error) {
contract, err := bindVipnodePool(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &VipnodePoolFilterer{contract: contract}, nil
}
// bindVipnodePool binds a generic wrapper to an already deployed contract.
func bindVipnodePool(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(VipnodePoolABI))
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_VipnodePool *VipnodePoolRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _VipnodePool.Contract.VipnodePoolCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_VipnodePool *VipnodePoolRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _VipnodePool.Contract.VipnodePoolTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_VipnodePool *VipnodePoolRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _VipnodePool.Contract.VipnodePoolTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_VipnodePool *VipnodePoolCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
return _VipnodePool.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_VipnodePool *VipnodePoolTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _VipnodePool.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_VipnodePool *VipnodePoolTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _VipnodePool.Contract.contract.Transact(opts, method, params...)
}
// CheckBalance is a free data retrieval call binding the contract method 0xe17b4707.
//
// Solidity: function checkBalance(_client address, _nodeID bytes32, _minBalance uint256) constant returns(bool)
func (_VipnodePool *VipnodePoolCaller) CheckBalance(opts *bind.CallOpts, _client common.Address, _nodeID [32]byte, _minBalance *big.Int) (bool, error) {
var (
ret0 = new(bool)
)
out := ret0
err := _VipnodePool.contract.Call(opts, out, "checkBalance", _client, _nodeID, _minBalance)
return *ret0, err
}
// CheckBalance is a free data retrieval call binding the contract method 0xe17b4707.
//
// Solidity: function checkBalance(_client address, _nodeID bytes32, _minBalance uint256) constant returns(bool)
func (_VipnodePool *VipnodePoolSession) CheckBalance(_client common.Address, _nodeID [32]byte, _minBalance *big.Int) (bool, error) {
return _VipnodePool.Contract.CheckBalance(&_VipnodePool.CallOpts, _client, _nodeID, _minBalance)
}
// CheckBalance is a free data retrieval call binding the contract method 0xe17b4707.
//
// Solidity: function checkBalance(_client address, _nodeID bytes32, _minBalance uint256) constant returns(bool)
func (_VipnodePool *VipnodePoolCallerSession) CheckBalance(_client common.Address, _nodeID [32]byte, _minBalance *big.Int) (bool, error) {
return _VipnodePool.Contract.CheckBalance(&_VipnodePool.CallOpts, _client, _nodeID, _minBalance)
}
// Clients is a free data retrieval call binding the contract method 0x61eed2a9.
//
// Solidity: function clients( address) constant returns(balance uint256, timeLocked uint256)
func (_VipnodePool *VipnodePoolCaller) Clients(opts *bind.CallOpts, arg0 common.Address) (struct {
Balance *big.Int
TimeLocked *big.Int
}, error) {
ret := new(struct {
Balance *big.Int
TimeLocked *big.Int
})
out := ret
err := _VipnodePool.contract.Call(opts, out, "clients", arg0)
return *ret, err
}
// Clients is a free data retrieval call binding the contract method 0x61eed2a9.
//
// Solidity: function clients( address) constant returns(balance uint256, timeLocked uint256)
func (_VipnodePool *VipnodePoolSession) Clients(arg0 common.Address) (struct {
Balance *big.Int
TimeLocked *big.Int
}, error) {
return _VipnodePool.Contract.Clients(&_VipnodePool.CallOpts, arg0)
}
// Clients is a free data retrieval call binding the contract method 0x61eed2a9.
//
// Solidity: function clients( address) constant returns(balance uint256, timeLocked uint256)
func (_VipnodePool *VipnodePoolCallerSession) Clients(arg0 common.Address) (struct {
Balance *big.Int
TimeLocked *big.Int
}, error) {
return _VipnodePool.Contract.Clients(&_VipnodePool.CallOpts, arg0)
}
// Operator is a free data retrieval call binding the contract method 0x570ca735.
//
// Solidity: function operator() constant returns(address)
func (_VipnodePool *VipnodePoolCaller) Operator(opts *bind.CallOpts) (common.Address, error) {
var (
ret0 = new(common.Address)
)
out := ret0
err := _VipnodePool.contract.Call(opts, out, "operator")
return *ret0, err
}
// Operator is a free data retrieval call binding the contract method 0x570ca735.
//
// Solidity: function operator() constant returns(address)
func (_VipnodePool *VipnodePoolSession) Operator() (common.Address, error) {
return _VipnodePool.Contract.Operator(&_VipnodePool.CallOpts)
}
// Operator is a free data retrieval call binding the contract method 0x570ca735.
//
// Solidity: function operator() constant returns(address)
func (_VipnodePool *VipnodePoolCallerSession) Operator() (common.Address, error) {
return _VipnodePool.Contract.Operator(&_VipnodePool.CallOpts)
}
// WithdrawInterval is a free data retrieval call binding the contract method 0x162075d8.
//
// Solidity: function withdrawInterval() constant returns(uint256)
func (_VipnodePool *VipnodePoolCaller) WithdrawInterval(opts *bind.CallOpts) (*big.Int, error) {
var (
ret0 = new(*big.Int)
)
out := ret0
err := _VipnodePool.contract.Call(opts, out, "withdrawInterval")
return *ret0, err
}
// WithdrawInterval is a free data retrieval call binding the contract method 0x162075d8.
//
// Solidity: function withdrawInterval() constant returns(uint256)
func (_VipnodePool *VipnodePoolSession) WithdrawInterval() (*big.Int, error) {
return _VipnodePool.Contract.WithdrawInterval(&_VipnodePool.CallOpts)
}
// WithdrawInterval is a free data retrieval call binding the contract method 0x162075d8.
//
// Solidity: function withdrawInterval() constant returns(uint256)
func (_VipnodePool *VipnodePoolCallerSession) WithdrawInterval() (*big.Int, error) {
return _VipnodePool.Contract.WithdrawInterval(&_VipnodePool.CallOpts)
}
// AddBalance is a paid mutator transaction binding the contract method 0x6dd4c618.
//
// Solidity: function addBalance(_nodeID bytes32) returns()
func (_VipnodePool *VipnodePoolTransactor) AddBalance(opts *bind.TransactOpts, _nodeID [32]byte) (*types.Transaction, error) {
return _VipnodePool.contract.Transact(opts, "addBalance", _nodeID)
}
// AddBalance is a paid mutator transaction binding the contract method 0x6dd4c618.
//
// Solidity: function addBalance(_nodeID bytes32) returns()
func (_VipnodePool *VipnodePoolSession) AddBalance(_nodeID [32]byte) (*types.Transaction, error) {
return _VipnodePool.Contract.AddBalance(&_VipnodePool.TransactOpts, _nodeID)
}
// AddBalance is a paid mutator transaction binding the contract method 0x6dd4c618.
//
// Solidity: function addBalance(_nodeID bytes32) returns()
func (_VipnodePool *VipnodePoolTransactorSession) AddBalance(_nodeID [32]byte) (*types.Transaction, error) {
return _VipnodePool.Contract.AddBalance(&_VipnodePool.TransactOpts, _nodeID)
}
// ForceSettle is a paid mutator transaction binding the contract method 0xaeea1f7b.
//
// Solidity: function forceSettle() returns()
func (_VipnodePool *VipnodePoolTransactor) ForceSettle(opts *bind.TransactOpts) (*types.Transaction, error) {
return _VipnodePool.contract.Transact(opts, "forceSettle")
}
// ForceSettle is a paid mutator transaction binding the contract method 0xaeea1f7b.
//
// Solidity: function forceSettle() returns()
func (_VipnodePool *VipnodePoolSession) ForceSettle() (*types.Transaction, error) {
return _VipnodePool.Contract.ForceSettle(&_VipnodePool.TransactOpts)
}
// ForceSettle is a paid mutator transaction binding the contract method 0xaeea1f7b.
//
// Solidity: function forceSettle() returns()
func (_VipnodePool *VipnodePoolTransactorSession) ForceSettle() (*types.Transaction, error) {
return _VipnodePool.Contract.ForceSettle(&_VipnodePool.TransactOpts)
}
// ForceWithdraw is a paid mutator transaction binding the contract method 0x7be80b39.
//
// Solidity: function forceWithdraw() returns()
func (_VipnodePool *VipnodePoolTransactor) ForceWithdraw(opts *bind.TransactOpts) (*types.Transaction, error) {
return _VipnodePool.contract.Transact(opts, "forceWithdraw")
}
// ForceWithdraw is a paid mutator transaction binding the contract method 0x7be80b39.
//
// Solidity: function forceWithdraw() returns()
func (_VipnodePool *VipnodePoolSession) ForceWithdraw() (*types.Transaction, error) {
return _VipnodePool.Contract.ForceWithdraw(&_VipnodePool.TransactOpts)
}
// ForceWithdraw is a paid mutator transaction binding the contract method 0x7be80b39.
//
// Solidity: function forceWithdraw() returns()
func (_VipnodePool *VipnodePoolTransactorSession) ForceWithdraw() (*types.Transaction, error) {
return _VipnodePool.Contract.ForceWithdraw(&_VipnodePool.TransactOpts)
}
// OpSettle is a paid mutator transaction binding the contract method 0xa73e679a.
//
// Solidity: function opSettle(_client address, _amount uint256, _release bool) returns()
func (_VipnodePool *VipnodePoolTransactor) OpSettle(opts *bind.TransactOpts, _client common.Address, _amount *big.Int, _release bool) (*types.Transaction, error) {
return _VipnodePool.contract.Transact(opts, "opSettle", _client, _amount, _release)
}
// OpSettle is a paid mutator transaction binding the contract method 0xa73e679a.
//
// Solidity: function opSettle(_client address, _amount uint256, _release bool) returns()
func (_VipnodePool *VipnodePoolSession) OpSettle(_client common.Address, _amount *big.Int, _release bool) (*types.Transaction, error) {
return _VipnodePool.Contract.OpSettle(&_VipnodePool.TransactOpts, _client, _amount, _release)
}
// OpSettle is a paid mutator transaction binding the contract method 0xa73e679a.
//
// Solidity: function opSettle(_client address, _amount uint256, _release bool) returns()
func (_VipnodePool *VipnodePoolTransactorSession) OpSettle(_client common.Address, _amount *big.Int, _release bool) (*types.Transaction, error) {
return _VipnodePool.Contract.OpSettle(&_VipnodePool.TransactOpts, _client, _amount, _release)
}
// OpWithdraw is a paid mutator transaction binding the contract method 0xae5fa7e7.
//
// Solidity: function opWithdraw(_amount uint256) returns()
func (_VipnodePool *VipnodePoolTransactor) OpWithdraw(opts *bind.TransactOpts, _amount *big.Int) (*types.Transaction, error) {
return _VipnodePool.contract.Transact(opts, "opWithdraw", _amount)
}
// OpWithdraw is a paid mutator transaction binding the contract method 0xae5fa7e7.
//
// Solidity: function opWithdraw(_amount uint256) returns()
func (_VipnodePool *VipnodePoolSession) OpWithdraw(_amount *big.Int) (*types.Transaction, error) {
return _VipnodePool.Contract.OpWithdraw(&_VipnodePool.TransactOpts, _amount)
}
// OpWithdraw is a paid mutator transaction binding the contract method 0xae5fa7e7.
//
// Solidity: function opWithdraw(_amount uint256) returns()
func (_VipnodePool *VipnodePoolTransactorSession) OpWithdraw(_amount *big.Int) (*types.Transaction, error) {
return _VipnodePool.Contract.OpWithdraw(&_VipnodePool.TransactOpts, _amount)
}
// VipnodePoolBalanceIterator is returned from FilterBalance and is used to iterate over the raw logs and unpacked data for Balance events raised by the VipnodePool contract.
type VipnodePoolBalanceIterator struct {
Event *VipnodePoolBalance // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *VipnodePoolBalanceIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(VipnodePoolBalance)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(VipnodePoolBalance)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *VipnodePoolBalanceIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *VipnodePoolBalanceIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// VipnodePoolBalance represents a Balance event raised by the VipnodePool contract.
type VipnodePoolBalance struct {
Client common.Address
Balance *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterBalance is a free log retrieval operation binding the contract event 0x134e340554ff8a7d64280a2a28b982df554e2595e5bf45cd39368f31099172a6.
//
// Solidity: e Balance(client address, balance uint256)
func (_VipnodePool *VipnodePoolFilterer) FilterBalance(opts *bind.FilterOpts) (*VipnodePoolBalanceIterator, error) {
logs, sub, err := _VipnodePool.contract.FilterLogs(opts, "Balance")
if err != nil {
return nil, err
}
return &VipnodePoolBalanceIterator{contract: _VipnodePool.contract, event: "Balance", logs: logs, sub: sub}, nil
}
// WatchBalance is a free log subscription operation binding the contract event 0x134e340554ff8a7d64280a2a28b982df554e2595e5bf45cd39368f31099172a6.
//
// Solidity: e Balance(client address, balance uint256)
func (_VipnodePool *VipnodePoolFilterer) WatchBalance(opts *bind.WatchOpts, sink chan<- *VipnodePoolBalance) (event.Subscription, error) {
logs, sub, err := _VipnodePool.contract.WatchLogs(opts, "Balance")
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(VipnodePoolBalance)
if err := _VipnodePool.contract.UnpackLog(event, "Balance", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// VipnodePoolForceSettleIterator is returned from FilterForceSettle and is used to iterate over the raw logs and unpacked data for ForceSettle events raised by the VipnodePool contract.
type VipnodePoolForceSettleIterator struct {
Event *VipnodePoolForceSettle // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *VipnodePoolForceSettleIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(VipnodePoolForceSettle)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(VipnodePoolForceSettle)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *VipnodePoolForceSettleIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *VipnodePoolForceSettleIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// VipnodePoolForceSettle represents a ForceSettle event raised by the VipnodePool contract.
type VipnodePoolForceSettle struct {
Client common.Address
TimeLocked *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterForceSettle is a free log retrieval operation binding the contract event 0xde112f62320281f04efec46e09ed286851fdd0b428dfc7214fe0e64f9364323b.
//
// Solidity: e ForceSettle(client address, timeLocked uint256)
func (_VipnodePool *VipnodePoolFilterer) FilterForceSettle(opts *bind.FilterOpts) (*VipnodePoolForceSettleIterator, error) {
logs, sub, err := _VipnodePool.contract.FilterLogs(opts, "ForceSettle")
if err != nil {
return nil, err
}
return &VipnodePoolForceSettleIterator{contract: _VipnodePool.contract, event: "ForceSettle", logs: logs, sub: sub}, nil
}
// WatchForceSettle is a free log subscription operation binding the contract event 0xde112f62320281f04efec46e09ed286851fdd0b428dfc7214fe0e64f9364323b.
//
// Solidity: e ForceSettle(client address, timeLocked uint256)
func (_VipnodePool *VipnodePoolFilterer) WatchForceSettle(opts *bind.WatchOpts, sink chan<- *VipnodePoolForceSettle) (event.Subscription, error) {
logs, sub, err := _VipnodePool.contract.WatchLogs(opts, "ForceSettle")
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(VipnodePoolForceSettle)
if err := _VipnodePool.contract.UnpackLog(event, "ForceSettle", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment