rpc: implement client-side getunspents
This commit is contained in:
parent
29882b076c
commit
826a29cc98
3 changed files with 21 additions and 0 deletions
|
@ -41,6 +41,7 @@ Supported methods
|
|||
|
||||
getblock
|
||||
getaccountstate
|
||||
getunspents
|
||||
invokescript
|
||||
invokefunction
|
||||
sendrawtransaction
|
||||
|
|
|
@ -39,6 +39,18 @@ func (c *Client) GetAccountState(address string) (*AccountStateResponse, error)
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
// GetUnspents returns UTXOs for the given NEO account.
|
||||
func (c *Client) GetUnspents(address string) (*UnspentResponse, error) {
|
||||
var (
|
||||
params = newParams(address)
|
||||
resp = &UnspentResponse{}
|
||||
)
|
||||
if err := c.performRequest("getunspents", params, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// InvokeScript returns the result of the given script after running it true the VM.
|
||||
// NOTE: This is a test invoke and will not affect the blockchain.
|
||||
func (c *Client) InvokeScript(script string) (*InvokeScriptResponse, error) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package rpc
|
|||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/wrappers"
|
||||
"github.com/CityOfZion/neo-go/pkg/vm"
|
||||
)
|
||||
|
||||
|
@ -27,6 +28,13 @@ type AccountStateResponse struct {
|
|||
Result *Account `json:"result"`
|
||||
}
|
||||
|
||||
// UnspentResponse represents server response to the `getunspents` command.
|
||||
type UnspentResponse struct {
|
||||
responseHeader
|
||||
Error *Error `json:"error,omitempty"`
|
||||
Result *wrappers.Unspents `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
// Account represents details about a NEO account.
|
||||
type Account struct {
|
||||
Version int `json:"version"`
|
||||
|
|
Loading…
Reference in a new issue