├── .gitignore ├── .golangci.yml ├── LICENSE ├── README.md ├── bitcoin_core.go ├── client.go ├── errors.go ├── go.mod ├── infra.go ├── omni_core.go ├── omnijson ├── createrawtransaction.go ├── getblockchaininfo.go ├── importaddress.go ├── listunspent.go ├── omni_createpayload_simplesend.go ├── omni_createrawtx_change.go ├── omni_createrawtx_opreturn.go ├── omni_createrawtx_reference.go ├── omni_getbalance.go ├── omni_getinfo.go ├── omni_gettransaction.go ├── omni_listblocktransactions.go ├── sendrawtransaction.go ├── signrawtransaction.go └── signrawtransactionwithkey.go └── rpc.go /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | example 4 | 5 | # Test binary, build with `go test -c` 6 | *.test 7 | 8 | # Output of the go coverage tool, specifically when used with LiteIDE 9 | *.out 10 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | run: 2 | concurrency: 8 3 | deadline: 180s 4 | issues-exit-code: 1 5 | tests: false 6 | skip-dirs: 7 | - vendor 8 | - example 9 | 10 | output: 11 | format: colored-line-number 12 | print-issued-lines: true 13 | print-linter-name: true 14 | 15 | linters-settings: 16 | errcheck: 17 | check-type-assertions: true 18 | check-blank: true 19 | govet: 20 | check-shadowing: true 21 | gocyclo: 22 | min-complexity: 15 23 | maligned: 24 | suggest-new: true 25 | dupl: 26 | threshold: 100 27 | goconst: 28 | min-len: 3 29 | min-occurrences: 3 30 | misspell: 31 | locale: US 32 | lll: 33 | line-length: 150 34 | tab-width: 1 35 | unused: 36 | check-exported: false 37 | unparam: 38 | algo: cha 39 | check-exported: false 40 | nakedret: 41 | max-func-lines: 30 42 | prealloc: 43 | simple: true 44 | range-loops: true 45 | for-loops: true 46 | 47 | linters: 48 | enable-all: true 49 | disable: 50 | - golint 51 | - varcheck 52 | - megacheck 53 | 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # omnilayer-go 2 | Golang client for bitcoin omni layer 3 | -------------------------------------------------------------------------------- /bitcoin_core.go: -------------------------------------------------------------------------------- 1 | package omnilayer 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/ibclabs/omnilayer-go/omnijson" 7 | ) 8 | 9 | type futureCreateRawTransaction chan *response 10 | 11 | func (f futureCreateRawTransaction) Receive() (omnijson.CreateRawTransactionResult, error) { 12 | var result omnijson.CreateRawTransactionResult 13 | 14 | data, err := receive(f) 15 | if err != nil { 16 | return result, err 17 | } 18 | 19 | err = json.Unmarshal(data, &result) 20 | return result, err 21 | } 22 | 23 | type futureGetBlockChainInfo chan *response 24 | 25 | func (f futureGetBlockChainInfo) Receive() (omnijson.GetBlockChainInfoResult, error) { 26 | var result omnijson.GetBlockChainInfoResult 27 | 28 | data, err := receive(f) 29 | if err != nil { 30 | return result, err 31 | } 32 | 33 | err = json.Unmarshal(data, &result) 34 | return result, err 35 | } 36 | 37 | type futureListUnspent chan *response 38 | 39 | func (f futureListUnspent) Receive() (omnijson.ListUnspentResult, error) { 40 | data, err := receive(f) 41 | if err != nil { 42 | return nil, err 43 | } 44 | 45 | result := make(omnijson.ListUnspentResult, 0) 46 | 47 | err = json.Unmarshal(data, &result) 48 | return result, err 49 | } 50 | 51 | type futureImportAddress chan *response 52 | 53 | func (f futureImportAddress) Receive() error { 54 | _, err := receive(f) 55 | return err 56 | } 57 | 58 | type futureSendRawTransaction chan *response 59 | 60 | func (f futureSendRawTransaction) Receive() (omnijson.SendRawTransactionResult, error) { 61 | var result omnijson.SendRawTransactionResult 62 | 63 | data, err := receive(f) 64 | if err != nil { 65 | return result, err 66 | } 67 | 68 | err = json.Unmarshal(data, &result) 69 | return result, err 70 | } 71 | 72 | type futureSignRawTransaction chan *response 73 | 74 | func (f futureSignRawTransaction) Receive() (omnijson.SignRawTransactionResult, error) { 75 | var result omnijson.SignRawTransactionResult 76 | 77 | data, err := receive(f) 78 | if err != nil { 79 | return result, err 80 | } 81 | 82 | err = json.Unmarshal(data, &result) 83 | return result, err 84 | } 85 | 86 | type futureSignRawTransactionWithKey chan *response 87 | 88 | func (f futureSignRawTransactionWithKey) Receive() (omnijson.SignRawTransactionWithKeyResult, error) { 89 | var result omnijson.SignRawTransactionWithKeyResult 90 | 91 | data, err := receive(f) 92 | if err != nil { 93 | return result, err 94 | } 95 | 96 | err = json.Unmarshal(data, &result) 97 | return result, err 98 | } 99 | -------------------------------------------------------------------------------- /client.go: -------------------------------------------------------------------------------- 1 | package omnilayer 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | "sync/atomic" 9 | "time" 10 | ) 11 | 12 | const ( 13 | contentType = "Content-Type" 14 | contentTypeJSON = "application/json" 15 | ) 16 | 17 | type Client struct { 18 | id uint64 19 | config *ConnConfig 20 | httpClient *http.Client 21 | sendPostChan chan *sendPostDetails 22 | 23 | shutdown chan struct{} 24 | done chan struct{} 25 | } 26 | 27 | func (c *Client) do(cmd command) chan *response { 28 | body, err := marshalCmd(cmd) 29 | if err != nil { 30 | return newFutureError(err) 31 | } 32 | 33 | responseChan := make(chan *response, 1) 34 | jReq := &jsonRequest{ 35 | id: c.NextID(), 36 | cmd: cmd, 37 | body: body, 38 | responseChan: responseChan, 39 | } 40 | 41 | c.sendPost(jReq) 42 | 43 | return responseChan 44 | } 45 | 46 | func (c *Client) sendPost(jReq *jsonRequest) { 47 | req, err := http.NewRequest(http.MethodPost, "http://"+c.config.Host, bytes.NewReader(jReq.body)) 48 | if err != nil { 49 | jReq.responseChan <- &response{result: nil, err: err} 50 | return 51 | } 52 | 53 | req.Close = true 54 | req.Header.Set(contentType, contentTypeJSON) 55 | req.SetBasicAuth(c.config.User, c.config.Pass) 56 | 57 | select { 58 | case <-c.shutdown: 59 | jReq.responseChan <- &response{err: errClientShutdown()} 60 | default: 61 | c.sendPostChan <- &sendPostDetails{ 62 | jsonRequest: jReq, 63 | httpRequest: req, 64 | } 65 | } 66 | } 67 | 68 | func New(config *ConnConfig) *Client { 69 | httpClient := newHTTPClient() 70 | 71 | client := &Client{ 72 | config: config, 73 | httpClient: httpClient, 74 | sendPostChan: make(chan *sendPostDetails, sendPostBufferSize), 75 | 76 | shutdown: make(chan struct{}, 1), 77 | done: make(chan struct{}, 1), 78 | } 79 | 80 | go client.sendPostHandler() 81 | 82 | return client 83 | } 84 | 85 | func (c *Client) sendPostHandler() { 86 | out: 87 | for { 88 | select { 89 | case details := <-c.sendPostChan: 90 | c.handleSendPostMessage(details) 91 | 92 | case <-c.shutdown: 93 | break out 94 | } 95 | } 96 | 97 | cleanup: 98 | for { 99 | select { 100 | case details := <-c.sendPostChan: 101 | details.jsonRequest.responseChan <- &response{ 102 | result: nil, 103 | err: errClientShutdown(), 104 | } 105 | 106 | default: 107 | break cleanup 108 | } 109 | } 110 | 111 | close(c.done) 112 | } 113 | 114 | func (c *Client) handleSendPostMessage(details *sendPostDetails) { 115 | jReq := details.jsonRequest 116 | httpResponse, err := c.httpClient.Do(details.httpRequest) 117 | if err != nil { 118 | jReq.responseChan <- &response{err: err} 119 | return 120 | } 121 | 122 | respBytes, err := ioutil.ReadAll(httpResponse.Body) 123 | if err != nil { 124 | jReq.responseChan <- &response{err: err} 125 | return 126 | } 127 | err = httpResponse.Body.Close() 128 | if err != nil { 129 | jReq.responseChan <- &response{err: err} 130 | return 131 | } 132 | 133 | var resp rawResponse 134 | err = json.Unmarshal(respBytes, &resp) 135 | if err != nil { 136 | jReq.responseChan <- &response{err: err} 137 | return 138 | } 139 | 140 | res, err := resp.result() 141 | jReq.responseChan <- &response{result: res, err: err} 142 | } 143 | 144 | func newHTTPClient() *http.Client { 145 | return &http.Client{ 146 | Transport: &http.Transport{ 147 | ResponseHeaderTimeout: 5 * time.Second, 148 | ExpectContinueTimeout: 4 * time.Second, 149 | IdleConnTimeout: 5 * 60 * time.Second, 150 | }, 151 | } 152 | } 153 | 154 | func (c *Client) NextID() uint64 { 155 | return atomic.AddUint64(&c.id, 1) 156 | } 157 | 158 | func (c *Client) Shutdown() { 159 | select { 160 | case <-c.shutdown: 161 | return 162 | default: 163 | } 164 | 165 | close(c.shutdown) 166 | <-c.done 167 | } 168 | -------------------------------------------------------------------------------- /errors.go: -------------------------------------------------------------------------------- 1 | package omnilayer 2 | 3 | type ErrClientShutdown struct{} 4 | 5 | func (*ErrClientShutdown) Error() string { 6 | return "the client has been shutdown" 7 | } 8 | 9 | func errClientShutdown() error { 10 | return &ErrClientShutdown{} 11 | } 12 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ibclabs/omnilayer-go 2 | 3 | go 1.12 4 | -------------------------------------------------------------------------------- /infra.go: -------------------------------------------------------------------------------- 1 | package omnilayer 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/http" 7 | ) 8 | 9 | const sendPostBufferSize = 100 10 | 11 | type SigHashType = string 12 | 13 | // Constants used to indicate the signature hash type for SignRawTransaction. 14 | const ( 15 | // SigHashAll indicates ALL of the outputs should be signed. 16 | SigHashAll SigHashType = "ALL" 17 | 18 | // SigHashNone indicates NONE of the outputs should be signed. This 19 | // can be thought of as specifying the signer does not care where the 20 | // bitcoins go. 21 | SigHashNone SigHashType = "NONE" 22 | 23 | // SigHashSingle indicates that a SINGLE output should be signed. This 24 | // can be thought of specifying the signer only cares about where ONE of 25 | // the outputs goes, but not any of the others. 26 | SigHashSingle SigHashType = "SINGLE" 27 | 28 | // SigHashAllAnyoneCanPay indicates that signer does not care where the 29 | // other inputs to the transaction come from, so it allows other people 30 | // to add inputs. In addition, it uses the SigHashAll signing method 31 | // for outputs. 32 | SigHashAllAnyoneCanPay SigHashType = "ALL|ANYONECANPAY" 33 | 34 | // SigHashNoneAnyoneCanPay indicates that signer does not care where the 35 | // other inputs to the transaction come from, so it allows other people 36 | // to add inputs. In addition, it uses the SigHashNone signing method 37 | // for outputs. 38 | SigHashNoneAnyoneCanPay SigHashType = "NONE|ANYONECANPAY" 39 | 40 | // SigHashSingleAnyoneCanPay indicates that signer does not care where 41 | // the other inputs to the transaction come from, so it allows other 42 | // people to add inputs. In addition, it uses the SigHashSingle signing 43 | // method for outputs. 44 | SigHashSingleAnyoneCanPay SigHashType = "SINGLE|ANYONECANPAY" 45 | ) 46 | 47 | type rawResponse struct { 48 | Result json.RawMessage `json:"result"` 49 | Error *rpcError `json:"error"` 50 | } 51 | 52 | func (r rawResponse) result() (result []byte, err error) { 53 | if r.Error != nil { 54 | return nil, r.Error 55 | } 56 | return r.Result, nil 57 | } 58 | 59 | type sendPostDetails struct { 60 | httpRequest *http.Request 61 | jsonRequest *jsonRequest 62 | } 63 | 64 | type jsonRequest struct { 65 | id uint64 66 | cmd command 67 | body []byte 68 | responseChan chan *response 69 | } 70 | 71 | type response struct { 72 | result []byte 73 | err error 74 | } 75 | 76 | func receive(resp chan *response) ([]byte, error) { 77 | r := <-resp 78 | return r.result, r.err 79 | } 80 | 81 | func newFutureError(err error) chan *response { 82 | responseChan := make(chan *response, 1) 83 | responseChan <- &response{err: err} 84 | return responseChan 85 | } 86 | 87 | type ConnConfig struct { 88 | Host string 89 | Endpoint string 90 | User string 91 | Pass string 92 | Proxy string 93 | ProxyUser string 94 | ProxyPass string 95 | Certificates []byte 96 | DisableAutoReconnect bool 97 | DisableConnectOnNew bool 98 | EnableBCInfoHacks bool 99 | } 100 | 101 | type rpcError struct { 102 | Code int `json:"code"` 103 | Message string `json:"message"` 104 | } 105 | 106 | func (e *rpcError) Error() string { 107 | return fmt.Sprintf("%d: %s", e.Code, e.Message) 108 | } 109 | 110 | type command interface { 111 | ID() string 112 | Method() string 113 | Params() []interface{} 114 | } 115 | 116 | func marshalCmd(cmd command) ([]byte, error) { 117 | rawCmd, err := newRpcRequest(cmd) 118 | if err != nil { 119 | return nil, err 120 | } 121 | 122 | return json.Marshal(rawCmd) 123 | } 124 | 125 | func newRpcRequest(cmd command) (*rpcRequest, error) { 126 | method := cmd.Method() 127 | params := cmd.Params() 128 | id := cmd.ID() 129 | 130 | rawParams := make([]json.RawMessage, len(params)) 131 | 132 | for i := range params { 133 | msg, err := json.Marshal(params[i]) 134 | if err != nil { 135 | return nil, err 136 | } 137 | 138 | rawParams[i] = json.RawMessage(msg) 139 | } 140 | 141 | return &rpcRequest{ 142 | JsonRPC: "1.0", 143 | ID: id, 144 | Method: method, 145 | Params: rawParams, 146 | }, nil 147 | } 148 | 149 | type rpcRequest struct { 150 | JsonRPC string `json:"jsonrpc"` 151 | Method string `json:"method"` 152 | Params []json.RawMessage `json:"params"` 153 | ID string `json:"id"` 154 | } 155 | -------------------------------------------------------------------------------- /omni_core.go: -------------------------------------------------------------------------------- 1 | package omnilayer 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/ibclabs/omnilayer-go/omnijson" 7 | ) 8 | 9 | type futureOmniCreatePayloadSimpleSend chan *response 10 | 11 | func (f futureOmniCreatePayloadSimpleSend) Receive() (omnijson.OmniCreatePayloadSimpleSendResult, error) { 12 | var result omnijson.OmniCreatePayloadSimpleSendResult 13 | 14 | data, err := receive(f) 15 | if err != nil { 16 | return result, err 17 | } 18 | 19 | err = json.Unmarshal(data, &result) 20 | return result, err 21 | } 22 | 23 | type futureOmniCreateRawTxChange chan *response 24 | 25 | func (f futureOmniCreateRawTxChange) Receive() (omnijson.OmniCreateRawTxChangeResult, error) { 26 | var result omnijson.OmniCreateRawTxChangeResult 27 | 28 | data, err := receive(f) 29 | if err != nil { 30 | return result, err 31 | } 32 | 33 | err = json.Unmarshal(data, &result) 34 | return result, err 35 | } 36 | 37 | type futureOmniCreateRawTxOpReturn chan *response 38 | 39 | func (f futureOmniCreateRawTxOpReturn) Receive() (omnijson.OmniCreateRawTxOpReturnResult, error) { 40 | var result omnijson.OmniCreateRawTxOpReturnResult 41 | 42 | data, err := receive(f) 43 | if err != nil { 44 | return result, err 45 | } 46 | 47 | err = json.Unmarshal(data, &result) 48 | return result, err 49 | } 50 | 51 | type futureOmniCreateRawTxReference chan *response 52 | 53 | func (f futureOmniCreateRawTxReference) Receive() (omnijson.OmniCreateRawTxReferenceResult, error) { 54 | var result omnijson.OmniCreateRawTxReferenceResult 55 | 56 | data, err := receive(f) 57 | if err != nil { 58 | return result, err 59 | } 60 | 61 | err = json.Unmarshal(data, &result) 62 | return result, err 63 | } 64 | 65 | type futureGetInfo chan *response 66 | 67 | func (f futureGetInfo) Receive() (omnijson.OmniGetInfoResult, error) { 68 | var result omnijson.OmniGetInfoResult 69 | 70 | data, err := receive(f) 71 | if err != nil { 72 | return result, err 73 | } 74 | 75 | err = json.Unmarshal(data, &result) 76 | return result, err 77 | } 78 | 79 | type futureOmniGetTransaction chan *response 80 | 81 | func (f futureOmniGetTransaction) Receive() (omnijson.OmniGettransactionResult, error) { 82 | var result omnijson.OmniGettransactionResult 83 | 84 | data, err := receive(f) 85 | if err != nil { 86 | return result, err 87 | } 88 | 89 | err = json.Unmarshal(data, &result) 90 | return result, err 91 | } 92 | 93 | type futureOmniListBlockTransactions chan *response 94 | 95 | func (f futureOmniListBlockTransactions) Receive() (omnijson.OmniListBlockTransactionsResult, error) { 96 | data, err := receive(f) 97 | if err != nil { 98 | return nil, err 99 | } 100 | 101 | result := make(omnijson.OmniListBlockTransactionsResult, 0) 102 | 103 | err = json.Unmarshal(data, &result) 104 | return result, err 105 | } 106 | 107 | type futureOmniGetBalance chan *response 108 | 109 | func (f futureOmniGetBalance) Receive() (omnijson.OmniGetBalanceResult, error) { 110 | var result omnijson.OmniGetBalanceResult 111 | 112 | data, err := receive(f) 113 | if err != nil { 114 | return result, err 115 | } 116 | 117 | err = json.Unmarshal(data, &result) 118 | return result, err 119 | } 120 | -------------------------------------------------------------------------------- /omnijson/createrawtransaction.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | Result: 5 | "transaction" (string) hex string of the transaction 6 | */ 7 | 8 | type CreateRawTransactionResult = string 9 | 10 | type CreateRawTransactionCommand struct { 11 | Parameters []CreateRawTransactionParameter 12 | } 13 | 14 | type CreateRawTransactionParameter struct { 15 | Tx string `json:"txid"` 16 | Vout uint32 `json:"vout"` 17 | } 18 | 19 | type createrawtransactionOutput struct { 20 | Address string `json:"address,omitempty"` 21 | Data string `json:"data,omitempty"` 22 | } 23 | 24 | func (CreateRawTransactionCommand) Method() string { 25 | return "createrawtransaction" 26 | } 27 | 28 | func (CreateRawTransactionCommand) ID() string { 29 | return "1" 30 | } 31 | 32 | func (cmd CreateRawTransactionCommand) Params() []interface{} { 33 | return []interface{}{cmd.Parameters, createrawtransactionOutput{}} 34 | } 35 | -------------------------------------------------------------------------------- /omnijson/getblockchaininfo.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | Result 5 | { 6 | "chain": "xxxx", (string) current network name as defined in BIP70 (main, test, regtest) 7 | "blocks": xxxxxx, (numeric) the current number of blocks processed in the server 8 | "headers": xxxxxx, (numeric) the current number of headers we have validated 9 | "bestblockhash": "...", (string) the hash of the currently best block 10 | "difficulty": xxxxxx, (numeric) the current difficulty 11 | "mediantime": xxxxxx, (numeric) median time for the current best block 12 | "verificationprogress": xxxx, (numeric) estimate of verification progress [0..1] 13 | "chainwork": "xxxx" (string) total amount of work in active chain, in hexadecimal 14 | "pruned": xx, (boolean) if the blocks are subject to pruning 15 | "pruneheight": xxxxxx, (numeric) lowest-height complete block stored 16 | "softforks": [ (array) status of softforks in progress 17 | { 18 | "id": "xxxx", (string) name of softfork 19 | "version": xx, (numeric) block version 20 | "enforce": { (object) progress toward enforcing the softfork rules for new-version blocks 21 | "status": xx, (boolean) true if threshold reached 22 | "found": xx, (numeric) number of blocks with the new version found 23 | "required": xx, (numeric) number of blocks required to trigger 24 | "window": xx, (numeric) maximum size of examined window of recent blocks 25 | }, 26 | "reject": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as "enforce") 27 | }, ... 28 | ], 29 | "bip9_softforks": { (object) status of BIP9 softforks in progress 30 | "xxxx" : { (string) name of the softfork 31 | "status": "xxxx", (string) one of "defined", "started", "locked_in", "active", "failed" 32 | "bit": xx, (numeric) the bit (0-28) in the block version field used to signal this softfork (only for "started" status) 33 | "startTime": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning 34 | "timeout": xx (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in 35 | } 36 | } 37 | } 38 | */ 39 | 40 | type GetBlockChainInfoResult struct { 41 | Blocks int64 `json:"blocks"` 42 | BestBlockHash string `json:"bestblockhash"` 43 | } 44 | 45 | type GetBlockChainInfoCommand struct{} 46 | 47 | func (GetBlockChainInfoCommand) Method() string { 48 | return "getblockchaininfo" 49 | } 50 | 51 | func (GetBlockChainInfoCommand) ID() string { 52 | return "1" 53 | } 54 | 55 | func (GetBlockChainInfoCommand) Params() []interface{} { 56 | return nil 57 | } 58 | -------------------------------------------------------------------------------- /omnijson/importaddress.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | type ImportAddressCommand struct { 4 | Adress string 5 | Tag string 6 | Rescan bool 7 | } 8 | 9 | func (ImportAddressCommand) Method() string { 10 | return "importaddress" 11 | } 12 | 13 | func (ImportAddressCommand) ID() string { 14 | return "1" 15 | } 16 | 17 | func (cmd ImportAddressCommand) Params() []interface{} { 18 | return []interface{}{cmd.Adress, cmd.Tag, cmd.Rescan} 19 | } 20 | -------------------------------------------------------------------------------- /omnijson/listunspent.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | Result 5 | [ (array of json object) 6 | { 7 | "txid" : "txid", (string) the transaction id 8 | "vout" : n, (numeric) the vout value 9 | "address" : "address", (string) the bitcoin address 10 | "account" : "account", (string) DEPRECATED. The associated account, or "" for the default account 11 | "scriptPubKey" : "key", (string) the script key 12 | "amount" : x.xxx, (numeric) the transaction amount in BTC 13 | "confirmations" : n, (numeric) The number of confirmations 14 | "redeemScript" : n (string) The redeemScript if scriptPubKey is P2SH 15 | "spendable" : xxx, (bool) Whether we have the private keys to spend this output 16 | "solvable" : xxx (bool) Whether we know how to spend this output, ignoring the lack of keys 17 | } 18 | ,... 19 | ] 20 | */ 21 | 22 | type ListUnspentResult = []struct { 23 | Tx string `json:"txid"` 24 | Address string `json:"address"` 25 | ScriptPubKey string `json:"scriptPubKey"` 26 | RedeemScript string `json:"redeemScript"` 27 | Amount float64 `json:"amount"` 28 | Confirmations int64 `json:"confirmations"` 29 | Vout uint32 `json:"vout"` 30 | Spendable bool `json:"spendable"` 31 | Solvable bool `json:"solvable"` 32 | } 33 | 34 | type ListUnspentCommand struct { 35 | Min int 36 | Addresses []string 37 | } 38 | 39 | func (ListUnspentCommand) Method() string { 40 | return "listunspent" 41 | } 42 | 43 | func (ListUnspentCommand) ID() string { 44 | return "1" 45 | } 46 | 47 | func (cmd ListUnspentCommand) Params() []interface{} { 48 | return []interface{}{cmd.Min, 9999999, cmd.Addresses} 49 | } 50 | -------------------------------------------------------------------------------- /omnijson/omni_createpayload_simplesend.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | Result: 5 | "payload" (string) the hex-encoded payload 6 | */ 7 | 8 | type OmniCreatePayloadSimpleSendResult = string 9 | 10 | type OmniCreatePayloadSimpleSendCommand struct { 11 | Property int32 12 | Amount string 13 | } 14 | 15 | func (OmniCreatePayloadSimpleSendCommand) Method() string { 16 | return "omni_createpayload_simplesend" 17 | } 18 | 19 | func (OmniCreatePayloadSimpleSendCommand) ID() string { 20 | return "1" 21 | } 22 | 23 | func (cmd OmniCreatePayloadSimpleSendCommand) Params() []interface{} { 24 | return []interface{}{cmd.Property, cmd.Amount} 25 | } 26 | -------------------------------------------------------------------------------- /omnijson/omni_createrawtx_change.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | type OmniCreateRawTxChangeResult = string 4 | 5 | type OmniCreateRawTxChangeCommand struct { 6 | Raw string 7 | Previous []OmniCreateRawTxChangeParameter 8 | Destination string 9 | Fee float64 10 | } 11 | 12 | type OmniCreateRawTxChangeParameter struct { 13 | Tx string `json:"txid"` 14 | Vout uint32 `json:"vout"` 15 | ScriptPubKey string `json:"scriptPubKey"` 16 | Value float64 `json:"value"` 17 | } 18 | 19 | func (OmniCreateRawTxChangeCommand) Method() string { 20 | return "omni_createrawtx_change" 21 | } 22 | 23 | func (OmniCreateRawTxChangeCommand) ID() string { 24 | return "1" 25 | } 26 | 27 | func (cmd OmniCreateRawTxChangeCommand) Params() []interface{} { 28 | return []interface{}{cmd.Raw, cmd.Previous, cmd.Destination, cmd.Fee} 29 | } 30 | -------------------------------------------------------------------------------- /omnijson/omni_createrawtx_opreturn.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | type OmniCreateRawTxOpReturnResult = string 4 | 5 | type OmniCreateRawTxOpReturnCommand struct { 6 | Raw string 7 | Payload string 8 | } 9 | 10 | func (OmniCreateRawTxOpReturnCommand) Method() string { 11 | return "omni_createrawtx_opreturn" 12 | } 13 | 14 | func (OmniCreateRawTxOpReturnCommand) ID() string { 15 | return "1" 16 | } 17 | 18 | func (cmd OmniCreateRawTxOpReturnCommand) Params() []interface{} { 19 | return []interface{}{cmd.Raw, cmd.Payload} 20 | } 21 | -------------------------------------------------------------------------------- /omnijson/omni_createrawtx_reference.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | type OmniCreateRawTxReferenceResult = string 4 | 5 | type OmniCreateRawTxReferenceCommand struct { 6 | Raw string 7 | Destination string 8 | Amount float64 9 | } 10 | 11 | func (OmniCreateRawTxReferenceCommand) Method() string { 12 | return "omni_createrawtx_reference" 13 | } 14 | 15 | func (OmniCreateRawTxReferenceCommand) ID() string { 16 | return "1" 17 | } 18 | 19 | func (cmd OmniCreateRawTxReferenceCommand) Params() []interface{} { 20 | return []interface{}{cmd.Raw, cmd.Destination, cmd.Amount} 21 | } 22 | -------------------------------------------------------------------------------- /omnijson/omni_getbalance.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | { 5 | "balance" : "n.nnnnnnnn", (string) the available balance of the address 6 | "reserved" : "n.nnnnnnnn" (string) the amount reserved by sell offers and accepts 7 | "frozen" : "n.nnnnnnnn" (string) the amount frozen by the issuer (applies to managed properties only) 8 | } 9 | */ 10 | 11 | type OmniGetBalanceResult = struct { 12 | Balance string 13 | Reserved string 14 | Frozen string 15 | } 16 | 17 | type OmniGetBalanceCommand struct { 18 | Address string 19 | PropertyID int32 20 | } 21 | 22 | func (OmniGetBalanceCommand) Method() string { 23 | return "omni_getbalance" 24 | } 25 | 26 | func (OmniGetBalanceCommand) ID() string { 27 | return "1" 28 | } 29 | 30 | func (cmd OmniGetBalanceCommand) Params() []interface{} { 31 | return []interface{}{cmd.Address, cmd.PropertyID} 32 | } 33 | -------------------------------------------------------------------------------- /omnijson/omni_getinfo.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | Result 5 | { 6 | "omnicoreversion_int" : xxxxxxx, // (number) client version as integer 7 | "omnicoreversion" : "x.x.x.x-xxx", // (string) client version 8 | "mastercoreversion" : "x.x.x.x-xxx", // (string) client version (DEPRECIATED) 9 | "bitcoincoreversion" : "x.x.x", // (string) Bitcoin Core version 10 | "commitinfo" : "xxxxxxx", // (string) build commit identifier 11 | "block" : nnnnnn, // (number) index of the last processed block 12 | "blocktime" : nnnnnnnnnn, // (number) timestamp of the last processed block 13 | "blocktransactions" : nnnn, // (number) Omni transactions found in the last processed block 14 | "totaltransactions" : nnnnnnnn, // (number) Omni transactions processed in total 15 | "alerts" : [ // (array of JSON objects) active protocol alert (if any) 16 | { 17 | "alerttype" : n // (number) alert type as integer 18 | "alerttype" : "xxx" // "alertexpiringbyblock", "alertexpiringbyblocktime", "alertexpiringbyclientversion" or "error" 19 | "alertexpiry" : "nnnnnnnnnn" // (string) expiration criteria (can refer to block height, timestamp or client verion) 20 | "alertmessage" : "xxx" // (string) information about the alert 21 | }, 22 | ... 23 | ] 24 | } 25 | */ 26 | 27 | type OmniGetInfoResult struct { 28 | VersionInt int32 `json:"omnicoreversion_int"` 29 | Version string `json:"omnicoreversion"` 30 | BitcoinCoreVersion string `json:"bitcoincoreversion"` 31 | CommitInfo string `json:"commitinfo"` 32 | Block int32 `json:"block"` 33 | BlockTimestamp int32 `json:"blocktime"` 34 | BlockTransaction int32 `json:"blocktransactions"` 35 | TotalTransaction int32 `json:"totaltransactions"` 36 | } 37 | 38 | type OmniGetInfoCommand struct{} 39 | 40 | func (OmniGetInfoCommand) Method() string { 41 | return "omni_getinfo" 42 | } 43 | 44 | func (OmniGetInfoCommand) ID() string { 45 | return "1" 46 | } 47 | 48 | func (OmniGetInfoCommand) Params() []interface{} { 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /omnijson/omni_gettransaction.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | Result: 5 | { 6 | "txid": "84504b62edb18d6b9fa7089c5cba09fabaa7f1f46034ad9d49fb5781d7cf1bc6", 7 | "fee": "0.00100000", 8 | "sendingaddress": "1Po1oWkD2LmodfkBYiAktwh76vkF93LKnh", 9 | "referenceaddress": "1PowyXXycpvSEbfY7cFcuDzpVAh6sTNejo", 10 | "ismine": false, 11 | "version": 0, 12 | "type_int": 0, 13 | "type": "Simple Send", 14 | "propertyid": 31, 15 | "divisible": true, 16 | "amount": "97.96000000", 17 | "valid": true, 18 | "blockhash": "000000000000000000190b41bf8c7b5e1c49275ab71b5fe1aef57864bedf2b5b", 19 | "blocktime": 1549012217, 20 | "positioninblock": 38, 21 | "block": 561034, 22 | "confirmations": 2 23 | } 24 | */ 25 | 26 | type OmniGettransactionResult struct { 27 | ID string `json:"txid"` 28 | Fee string `json:"fee"` 29 | From string `json:"sendingaddress"` 30 | To string `json:"referenceaddress"` 31 | Type string `json:"type"` 32 | Amount string `json:"amount"` 33 | BlockHash string `json:"blockhash"` 34 | InvalidReason string `json:"invalidreason"` 35 | Version int32 `json:"version"` 36 | TypeInt int32 `json:"type_int"` 37 | PropertyID uint32 `json:"propertyid"` 38 | BlockTimestamp int32 `json:"blocktime"` 39 | PositionInBlock int32 `json:"positioninblock"` 40 | BlockHeight int32 `json:"block"` 41 | Confirmations uint32 `json:"confirmations"` 42 | Mine bool `json:"ismine"` 43 | Divisible bool `json:"divisible"` 44 | Valid bool `json:"valid"` 45 | } 46 | 47 | type OmniGetTransactionCommand struct { 48 | Hash string 49 | } 50 | 51 | func (OmniGetTransactionCommand) Method() string { 52 | return "omni_gettransaction" 53 | } 54 | 55 | func (OmniGetTransactionCommand) ID() string { 56 | return "1" 57 | } 58 | 59 | func (cmd OmniGetTransactionCommand) Params() []interface{} { 60 | return []interface{}{cmd.Hash} 61 | } 62 | -------------------------------------------------------------------------------- /omnijson/omni_listblocktransactions.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | Result 5 | [ (array of string) 6 | "hash", (string) the hash of the transaction 7 | ... 8 | ] 9 | */ 10 | 11 | type OmniListBlockTransactionsResult = []string 12 | 13 | type OmniListBlockTransactionsCommand struct { 14 | Block int64 15 | } 16 | 17 | func (OmniListBlockTransactionsCommand) Method() string { 18 | return "omni_listblocktransactions" 19 | } 20 | 21 | func (OmniListBlockTransactionsCommand) ID() string { 22 | return "1" 23 | } 24 | 25 | func (cmd OmniListBlockTransactionsCommand) Params() []interface{} { 26 | return []interface{}{cmd.Block} 27 | } 28 | -------------------------------------------------------------------------------- /omnijson/sendrawtransaction.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | type SendRawTransactionResult = string 4 | 5 | type SendRawTransactionCommand struct { 6 | Hex string 7 | AllowHighFees bool 8 | } 9 | 10 | func (SendRawTransactionCommand) Method() string { 11 | return "sendrawtransaction" 12 | } 13 | 14 | func (SendRawTransactionCommand) ID() string { 15 | return "1" 16 | } 17 | 18 | func (cmd SendRawTransactionCommand) Params() []interface{} { 19 | return []interface{}{cmd.Hex, cmd.AllowHighFees} 20 | } 21 | -------------------------------------------------------------------------------- /omnijson/signrawtransaction.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | /* 4 | { 5 | "hex" : "value", (string) The hex-encoded raw transaction with signature(s) 6 | "complete" : true|false, (boolean) If the transaction has a complete set of signatures 7 | "errors" : [ (json array of objects) Script verification errors (if there are any) 8 | { 9 | "txid" : "hash", (string) The hash of the referenced, previous transaction 10 | "vout" : n, (numeric) The index of the output to spent and used as input 11 | "scriptSig" : "hex", (string) The hex-encoded signature script 12 | "sequence" : n, (numeric) Script sequence number 13 | "error" : "text" (string) Verification or signing error related to the input 14 | } 15 | ,... 16 | ] 17 | } 18 | */ 19 | 20 | type SignRawTransactionResult = struct { 21 | Hex string `json:"hex"` 22 | Complete bool `json:"complete"` 23 | Errors []signRawTransactionError `json:"errors"` 24 | } 25 | 26 | type signRawTransactionError struct { 27 | TxID string `json:"txid"` 28 | ScriptSig string `json:"scriptSig"` 29 | Error string `json:"error"` 30 | Vout uint32 `json:"vout"` 31 | Sequence uint32 `json:"sequence"` 32 | } 33 | 34 | type SignRawTransactionCommand struct { 35 | Hex string 36 | Previous []Previous 37 | Keys []string 38 | Type string 39 | } 40 | 41 | type Previous struct { 42 | TxID string `json:"txid"` 43 | Vout uint32 `json:"vout"` 44 | ScriptPubKey string `json:"scriptPubKey"` 45 | RedeemScript string `json:"redeemScript"` 46 | Value float64 `json:"value"` 47 | } 48 | 49 | func (SignRawTransactionCommand) Method() string { 50 | return "signrawtransaction" 51 | } 52 | 53 | func (SignRawTransactionCommand) ID() string { 54 | return "1" 55 | } 56 | 57 | func (cmd SignRawTransactionCommand) Params() []interface{} { 58 | return []interface{}{cmd.Hex, cmd.Previous, cmd.Keys, cmd.Type} 59 | } 60 | -------------------------------------------------------------------------------- /omnijson/signrawtransactionwithkey.go: -------------------------------------------------------------------------------- 1 | package omnijson 2 | 3 | type SignRawTransactionWithKeyResult = string 4 | 5 | type SignRawTransactionWithKeyCommand struct { 6 | Hex string 7 | Previous []Previous 8 | Keys []string 9 | Type string 10 | } 11 | 12 | func (SignRawTransactionWithKeyCommand) Method() string { 13 | return "signrawtransactionwithkey" 14 | } 15 | 16 | func (SignRawTransactionWithKeyCommand) ID() string { 17 | return "1" 18 | } 19 | 20 | func (cmd SignRawTransactionWithKeyCommand) Params() []interface{} { 21 | return []interface{}{cmd.Hex, cmd.Keys, cmd.Previous, cmd.Type} 22 | } 23 | -------------------------------------------------------------------------------- /rpc.go: -------------------------------------------------------------------------------- 1 | package omnilayer 2 | 3 | import "github.com/ibclabs/omnilayer-go/omnijson" 4 | 5 | func (c *Client) GetBlockChainInfo() (omnijson.GetBlockChainInfoResult, error) { 6 | return futureGetBlockChainInfo(c.do(omnijson.GetBlockChainInfoCommand{})).Receive() 7 | } 8 | 9 | func (c *Client) OmniListBlockTransactions(block int64) (omnijson.OmniListBlockTransactionsResult, error) { 10 | return futureOmniListBlockTransactions(c.do(omnijson.OmniListBlockTransactionsCommand{ 11 | Block: block, 12 | })).Receive() 13 | } 14 | 15 | func (c *Client) GetInfo() (omnijson.OmniGetInfoResult, error) { 16 | return futureGetInfo(c.do(omnijson.OmniGetInfoCommand{})).Receive() 17 | } 18 | 19 | func (c *Client) OmniGetTransaction(hash string) (omnijson.OmniGettransactionResult, error) { 20 | return futureOmniGetTransaction(c.do(omnijson.OmniGetTransactionCommand{ 21 | Hash: hash, 22 | })).Receive() 23 | } 24 | 25 | func (c *Client) ListUnspent(cmd omnijson.ListUnspentCommand) (omnijson.ListUnspentResult, error) { 26 | return futureListUnspent(c.do(cmd)).Receive() 27 | } 28 | 29 | func (c *Client) OmniCreatePayloadSimpleSend(cmd omnijson.OmniCreatePayloadSimpleSendCommand) (omnijson.OmniCreatePayloadSimpleSendResult, error) { 30 | return futureOmniCreatePayloadSimpleSend(c.do(cmd)).Receive() 31 | } 32 | 33 | func (c *Client) CreateRawTransaction(cmd omnijson.CreateRawTransactionCommand) (omnijson.CreateRawTransactionResult, error) { 34 | return futureCreateRawTransaction(c.do(cmd)).Receive() 35 | } 36 | 37 | func (c *Client) OmniCreateRawTxOpReturn(cmd omnijson.OmniCreateRawTxOpReturnCommand) (omnijson.OmniCreateRawTxOpReturnResult, error) { 38 | return futureOmniCreateRawTxOpReturn(c.do(cmd)).Receive() 39 | } 40 | 41 | func (c *Client) OmniCreateRawTxReference(cmd omnijson.OmniCreateRawTxReferenceCommand) (omnijson.OmniCreateRawTxReferenceResult, error) { 42 | return futureOmniCreateRawTxReference(c.do(cmd)).Receive() 43 | } 44 | 45 | func (c *Client) OmniCreateRawTxChange(cmd omnijson.OmniCreateRawTxChangeCommand) (omnijson.OmniCreateRawTxChangeResult, error) { 46 | return futureOmniCreateRawTxChange(c.do(cmd)).Receive() 47 | } 48 | 49 | func (c *Client) ImportAddress(address string, rescan bool) error { 50 | return futureImportAddress(c.do(omnijson.ImportAddressCommand{Adress: address, Rescan: rescan})).Receive() 51 | } 52 | 53 | func (c *Client) SendRawTransaction(cmd omnijson.SendRawTransactionCommand) (omnijson.SendRawTransactionResult, error) { 54 | return futureSendRawTransaction(c.do(cmd)).Receive() 55 | } 56 | 57 | func (c *Client) SignRawTransaction(cmd omnijson.SignRawTransactionCommand) (omnijson.SignRawTransactionResult, error) { 58 | return futureSignRawTransaction(c.do(cmd)).Receive() 59 | } 60 | 61 | func (c *Client) SignRawTransactionWithKey(cmd omnijson.SignRawTransactionWithKeyCommand) (omnijson.SignRawTransactionWithKeyResult, error) { 62 | return futureSignRawTransactionWithKey(c.do(cmd)).Receive() 63 | } 64 | 65 | func (c *Client) OmniGetBalance(cmd omnijson.OmniGetBalanceCommand) (omnijson.OmniGetBalanceResult, error) { 66 | return futureOmniGetBalance(c.do(cmd)).Receive() 67 | } 68 | --------------------------------------------------------------------------------