chequebook.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. // Code generated - DO NOT EDIT.
  2. // This file is a generated binding and any manual changes will be lost.
  3. package contract
  4. import (
  5. "math/big"
  6. "strings"
  7. ethereum "github.com/ethereum/go-ethereum"
  8. "github.com/ethereum/go-ethereum/accounts/abi"
  9. "github.com/ethereum/go-ethereum/accounts/abi/bind"
  10. "github.com/ethereum/go-ethereum/common"
  11. "github.com/ethereum/go-ethereum/core/types"
  12. "github.com/ethereum/go-ethereum/event"
  13. )
  14. // ChequebookABI is the input ABI used to generate the binding from.
  15. const ChequebookABI = "[{\"constant\":false,\"inputs\":[],\"name\":\"kill\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"sent\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"beneficiary\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"sig_v\",\"type\":\"uint8\"},{\"name\":\"sig_r\",\"type\":\"bytes32\"},{\"name\":\"sig_s\",\"type\":\"bytes32\"}],\"name\":\"cash\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"deadbeat\",\"type\":\"address\"}],\"name\":\"Overdraft\",\"type\":\"event\"}]"
  16. // ChequebookBin is the compiled bytecode used for deploying new contracts.
  17. const ChequebookBin = `0x606060405260008054600160a060020a033316600160a060020a03199091161790556102ec806100306000396000f3006060604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166341c0e1b581146100585780637bf786f81461006b578063fbf788d61461009c575b005b341561006357600080fd5b6100566100ca565b341561007657600080fd5b61008a600160a060020a03600435166100f1565b60405190815260200160405180910390f35b34156100a757600080fd5b610056600160a060020a036004351660243560ff60443516606435608435610103565b60005433600160a060020a03908116911614156100ef57600054600160a060020a0316ff5b565b60016020526000908152604090205481565b600160a060020a0385166000908152600160205260408120548190861161012957600080fd5b3087876040516c01000000000000000000000000600160a060020a03948516810282529290931690910260148301526028820152604801604051809103902091506001828686866040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f115156101cf57600080fd5b505060206040510351600054600160a060020a039081169116146101f257600080fd5b50600160a060020a03808716600090815260016020526040902054860390301631811161026257600160a060020a0387166000818152600160205260409081902088905582156108fc0290839051600060405180830381858888f19350505050151561025d57600080fd5b6102b7565b6000547f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f97890600160a060020a0316604051600160a060020a03909116815260200160405180910390a186600160a060020a0316ff5b505050505050505600a165627a7a72305820533e856fc37e3d64d1706bcc7dfb6b1d490c8d566ea498d9d01ec08965a896ca0029`
  18. // DeployChequebook deploys a new Ethereum contract, binding an instance of Chequebook to it.
  19. func DeployChequebook(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Chequebook, error) {
  20. parsed, err := abi.JSON(strings.NewReader(ChequebookABI))
  21. if err != nil {
  22. return common.Address{}, nil, nil, err
  23. }
  24. address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ChequebookBin), backend)
  25. if err != nil {
  26. return common.Address{}, nil, nil, err
  27. }
  28. return address, tx, &Chequebook{ChequebookCaller: ChequebookCaller{contract: contract}, ChequebookTransactor: ChequebookTransactor{contract: contract}, ChequebookFilterer: ChequebookFilterer{contract: contract}}, nil
  29. }
  30. // Chequebook is an auto generated Go binding around an Ethereum contract.
  31. type Chequebook struct {
  32. ChequebookCaller // Read-only binding to the contract
  33. ChequebookTransactor // Write-only binding to the contract
  34. ChequebookFilterer // Log filterer for contract events
  35. }
  36. // ChequebookCaller is an auto generated read-only Go binding around an Ethereum contract.
  37. type ChequebookCaller struct {
  38. contract *bind.BoundContract // Generic contract wrapper for the low level calls
  39. }
  40. // ChequebookTransactor is an auto generated write-only Go binding around an Ethereum contract.
  41. type ChequebookTransactor struct {
  42. contract *bind.BoundContract // Generic contract wrapper for the low level calls
  43. }
  44. // ChequebookFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
  45. type ChequebookFilterer struct {
  46. contract *bind.BoundContract // Generic contract wrapper for the low level calls
  47. }
  48. // ChequebookSession is an auto generated Go binding around an Ethereum contract,
  49. // with pre-set call and transact options.
  50. type ChequebookSession struct {
  51. Contract *Chequebook // Generic contract binding to set the session for
  52. CallOpts bind.CallOpts // Call options to use throughout this session
  53. TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
  54. }
  55. // ChequebookCallerSession is an auto generated read-only Go binding around an Ethereum contract,
  56. // with pre-set call options.
  57. type ChequebookCallerSession struct {
  58. Contract *ChequebookCaller // Generic contract caller binding to set the session for
  59. CallOpts bind.CallOpts // Call options to use throughout this session
  60. }
  61. // ChequebookTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
  62. // with pre-set transact options.
  63. type ChequebookTransactorSession struct {
  64. Contract *ChequebookTransactor // Generic contract transactor binding to set the session for
  65. TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
  66. }
  67. // ChequebookRaw is an auto generated low-level Go binding around an Ethereum contract.
  68. type ChequebookRaw struct {
  69. Contract *Chequebook // Generic contract binding to access the raw methods on
  70. }
  71. // ChequebookCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
  72. type ChequebookCallerRaw struct {
  73. Contract *ChequebookCaller // Generic read-only contract binding to access the raw methods on
  74. }
  75. // ChequebookTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
  76. type ChequebookTransactorRaw struct {
  77. Contract *ChequebookTransactor // Generic write-only contract binding to access the raw methods on
  78. }
  79. // NewChequebook creates a new instance of Chequebook, bound to a specific deployed contract.
  80. func NewChequebook(address common.Address, backend bind.ContractBackend) (*Chequebook, error) {
  81. contract, err := bindChequebook(address, backend, backend, backend)
  82. if err != nil {
  83. return nil, err
  84. }
  85. return &Chequebook{ChequebookCaller: ChequebookCaller{contract: contract}, ChequebookTransactor: ChequebookTransactor{contract: contract}, ChequebookFilterer: ChequebookFilterer{contract: contract}}, nil
  86. }
  87. // NewChequebookCaller creates a new read-only instance of Chequebook, bound to a specific deployed contract.
  88. func NewChequebookCaller(address common.Address, caller bind.ContractCaller) (*ChequebookCaller, error) {
  89. contract, err := bindChequebook(address, caller, nil, nil)
  90. if err != nil {
  91. return nil, err
  92. }
  93. return &ChequebookCaller{contract: contract}, nil
  94. }
  95. // NewChequebookTransactor creates a new write-only instance of Chequebook, bound to a specific deployed contract.
  96. func NewChequebookTransactor(address common.Address, transactor bind.ContractTransactor) (*ChequebookTransactor, error) {
  97. contract, err := bindChequebook(address, nil, transactor, nil)
  98. if err != nil {
  99. return nil, err
  100. }
  101. return &ChequebookTransactor{contract: contract}, nil
  102. }
  103. // NewChequebookFilterer creates a new log filterer instance of Chequebook, bound to a specific deployed contract.
  104. func NewChequebookFilterer(address common.Address, filterer bind.ContractFilterer) (*ChequebookFilterer, error) {
  105. contract, err := bindChequebook(address, nil, nil, filterer)
  106. if err != nil {
  107. return nil, err
  108. }
  109. return &ChequebookFilterer{contract: contract}, nil
  110. }
  111. // bindChequebook binds a generic wrapper to an already deployed contract.
  112. func bindChequebook(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
  113. parsed, err := abi.JSON(strings.NewReader(ChequebookABI))
  114. if err != nil {
  115. return nil, err
  116. }
  117. return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
  118. }
  119. // Call invokes the (constant) contract method with params as input values and
  120. // sets the output to result. The result type might be a single field for simple
  121. // returns, a slice of interfaces for anonymous returns and a struct for named
  122. // returns.
  123. func (_Chequebook *ChequebookRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
  124. return _Chequebook.Contract.ChequebookCaller.contract.Call(opts, result, method, params...)
  125. }
  126. // Transfer initiates a plain transaction to move funds to the contract, calling
  127. // its default method if one is available.
  128. func (_Chequebook *ChequebookRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
  129. return _Chequebook.Contract.ChequebookTransactor.contract.Transfer(opts)
  130. }
  131. // Transact invokes the (paid) contract method with params as input values.
  132. func (_Chequebook *ChequebookRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
  133. return _Chequebook.Contract.ChequebookTransactor.contract.Transact(opts, method, params...)
  134. }
  135. // Call invokes the (constant) contract method with params as input values and
  136. // sets the output to result. The result type might be a single field for simple
  137. // returns, a slice of interfaces for anonymous returns and a struct for named
  138. // returns.
  139. func (_Chequebook *ChequebookCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
  140. return _Chequebook.Contract.contract.Call(opts, result, method, params...)
  141. }
  142. // Transfer initiates a plain transaction to move funds to the contract, calling
  143. // its default method if one is available.
  144. func (_Chequebook *ChequebookTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
  145. return _Chequebook.Contract.contract.Transfer(opts)
  146. }
  147. // Transact invokes the (paid) contract method with params as input values.
  148. func (_Chequebook *ChequebookTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
  149. return _Chequebook.Contract.contract.Transact(opts, method, params...)
  150. }
  151. // Sent is a free data retrieval call binding the contract method 0x7bf786f8.
  152. //
  153. // Solidity: function sent( address) constant returns(uint256)
  154. func (_Chequebook *ChequebookCaller) Sent(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) {
  155. var (
  156. ret0 = new(*big.Int)
  157. )
  158. out := ret0
  159. err := _Chequebook.contract.Call(opts, out, "sent", arg0)
  160. return *ret0, err
  161. }
  162. // Sent is a free data retrieval call binding the contract method 0x7bf786f8.
  163. //
  164. // Solidity: function sent( address) constant returns(uint256)
  165. func (_Chequebook *ChequebookSession) Sent(arg0 common.Address) (*big.Int, error) {
  166. return _Chequebook.Contract.Sent(&_Chequebook.CallOpts, arg0)
  167. }
  168. // Sent is a free data retrieval call binding the contract method 0x7bf786f8.
  169. //
  170. // Solidity: function sent( address) constant returns(uint256)
  171. func (_Chequebook *ChequebookCallerSession) Sent(arg0 common.Address) (*big.Int, error) {
  172. return _Chequebook.Contract.Sent(&_Chequebook.CallOpts, arg0)
  173. }
  174. // Cash is a paid mutator transaction binding the contract method 0xfbf788d6.
  175. //
  176. // Solidity: function cash(beneficiary address, amount uint256, sig_v uint8, sig_r bytes32, sig_s bytes32) returns()
  177. func (_Chequebook *ChequebookTransactor) Cash(opts *bind.TransactOpts, beneficiary common.Address, amount *big.Int, sig_v uint8, sig_r [32]byte, sig_s [32]byte) (*types.Transaction, error) {
  178. return _Chequebook.contract.Transact(opts, "cash", beneficiary, amount, sig_v, sig_r, sig_s)
  179. }
  180. // Cash is a paid mutator transaction binding the contract method 0xfbf788d6.
  181. //
  182. // Solidity: function cash(beneficiary address, amount uint256, sig_v uint8, sig_r bytes32, sig_s bytes32) returns()
  183. func (_Chequebook *ChequebookSession) Cash(beneficiary common.Address, amount *big.Int, sig_v uint8, sig_r [32]byte, sig_s [32]byte) (*types.Transaction, error) {
  184. return _Chequebook.Contract.Cash(&_Chequebook.TransactOpts, beneficiary, amount, sig_v, sig_r, sig_s)
  185. }
  186. // Cash is a paid mutator transaction binding the contract method 0xfbf788d6.
  187. //
  188. // Solidity: function cash(beneficiary address, amount uint256, sig_v uint8, sig_r bytes32, sig_s bytes32) returns()
  189. func (_Chequebook *ChequebookTransactorSession) Cash(beneficiary common.Address, amount *big.Int, sig_v uint8, sig_r [32]byte, sig_s [32]byte) (*types.Transaction, error) {
  190. return _Chequebook.Contract.Cash(&_Chequebook.TransactOpts, beneficiary, amount, sig_v, sig_r, sig_s)
  191. }
  192. // Kill is a paid mutator transaction binding the contract method 0x41c0e1b5.
  193. //
  194. // Solidity: function kill() returns()
  195. func (_Chequebook *ChequebookTransactor) Kill(opts *bind.TransactOpts) (*types.Transaction, error) {
  196. return _Chequebook.contract.Transact(opts, "kill")
  197. }
  198. // Kill is a paid mutator transaction binding the contract method 0x41c0e1b5.
  199. //
  200. // Solidity: function kill() returns()
  201. func (_Chequebook *ChequebookSession) Kill() (*types.Transaction, error) {
  202. return _Chequebook.Contract.Kill(&_Chequebook.TransactOpts)
  203. }
  204. // Kill is a paid mutator transaction binding the contract method 0x41c0e1b5.
  205. //
  206. // Solidity: function kill() returns()
  207. func (_Chequebook *ChequebookTransactorSession) Kill() (*types.Transaction, error) {
  208. return _Chequebook.Contract.Kill(&_Chequebook.TransactOpts)
  209. }
  210. // ChequebookOverdraftIterator is returned from FilterOverdraft and is used to iterate over the raw logs and unpacked data for Overdraft events raised by the Chequebook contract.
  211. type ChequebookOverdraftIterator struct {
  212. Event *ChequebookOverdraft // Event containing the contract specifics and raw log
  213. contract *bind.BoundContract // Generic contract to use for unpacking event data
  214. event string // Event name to use for unpacking event data
  215. logs chan types.Log // Log channel receiving the found contract events
  216. sub ethereum.Subscription // Subscription for errors, completion and termination
  217. done bool // Whether the subscription completed delivering logs
  218. fail error // Occurred error to stop iteration
  219. }
  220. // Next advances the iterator to the subsequent event, returning whether there
  221. // are any more events found. In case of a retrieval or parsing error, false is
  222. // returned and Error() can be queried for the exact failure.
  223. func (it *ChequebookOverdraftIterator) Next() bool {
  224. // If the iterator failed, stop iterating
  225. if it.fail != nil {
  226. return false
  227. }
  228. // If the iterator completed, deliver directly whatever's available
  229. if it.done {
  230. select {
  231. case log := <-it.logs:
  232. it.Event = new(ChequebookOverdraft)
  233. if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
  234. it.fail = err
  235. return false
  236. }
  237. it.Event.Raw = log
  238. return true
  239. default:
  240. return false
  241. }
  242. }
  243. // Iterator still in progress, wait for either a data or an error event
  244. select {
  245. case log := <-it.logs:
  246. it.Event = new(ChequebookOverdraft)
  247. if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
  248. it.fail = err
  249. return false
  250. }
  251. it.Event.Raw = log
  252. return true
  253. case err := <-it.sub.Err():
  254. it.done = true
  255. it.fail = err
  256. return it.Next()
  257. }
  258. }
  259. // Error retruned any retrieval or parsing error occurred during filtering.
  260. func (it *ChequebookOverdraftIterator) Error() error {
  261. return it.fail
  262. }
  263. // Close terminates the iteration process, releasing any pending underlying
  264. // resources.
  265. func (it *ChequebookOverdraftIterator) Close() error {
  266. it.sub.Unsubscribe()
  267. return nil
  268. }
  269. // ChequebookOverdraft represents a Overdraft event raised by the Chequebook contract.
  270. type ChequebookOverdraft struct {
  271. Deadbeat common.Address
  272. Raw types.Log // Blockchain specific contextual infos
  273. }
  274. // FilterOverdraft is a free log retrieval operation binding the contract event 0x2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f978.
  275. //
  276. // Solidity: event Overdraft(deadbeat address)
  277. func (_Chequebook *ChequebookFilterer) FilterOverdraft(opts *bind.FilterOpts) (*ChequebookOverdraftIterator, error) {
  278. logs, sub, err := _Chequebook.contract.FilterLogs(opts, "Overdraft")
  279. if err != nil {
  280. return nil, err
  281. }
  282. return &ChequebookOverdraftIterator{contract: _Chequebook.contract, event: "Overdraft", logs: logs, sub: sub}, nil
  283. }
  284. // WatchOverdraft is a free log subscription operation binding the contract event 0x2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f978.
  285. //
  286. // Solidity: event Overdraft(deadbeat address)
  287. func (_Chequebook *ChequebookFilterer) WatchOverdraft(opts *bind.WatchOpts, sink chan<- *ChequebookOverdraft) (event.Subscription, error) {
  288. logs, sub, err := _Chequebook.contract.WatchLogs(opts, "Overdraft")
  289. if err != nil {
  290. return nil, err
  291. }
  292. return event.NewSubscription(func(quit <-chan struct{}) error {
  293. defer sub.Unsubscribe()
  294. for {
  295. select {
  296. case log := <-logs:
  297. // New log arrived, parse the event and forward to the user
  298. event := new(ChequebookOverdraft)
  299. if err := _Chequebook.contract.UnpackLog(event, "Overdraft", log); err != nil {
  300. return err
  301. }
  302. event.Raw = log
  303. select {
  304. case sink <- event:
  305. case err := <-sub.Err():
  306. return err
  307. case <-quit:
  308. return nil
  309. }
  310. case err := <-sub.Err():
  311. return err
  312. case <-quit:
  313. return nil
  314. }
  315. }
  316. }), nil
  317. }