Documentation ¶
Index ¶
- Constants
- func BuildTransaction(b Builder) error
- func SignTransaction(s Signer, sf SignerFunc) ([][]byte, error)
- type Block
- type Builder
- type ChallengeUTXOData
- type Client
- func (c *Client) GetBalance(address string) (*WatcherBalanceFromAddress, error)
- func (c *Client) GetChallengeData(utxoPosition int) (*ChallengeUTXOData, error)
- func (c *Client) GetTransaction(txHash string) (*TransactionGetResponse, error)
- func (c *Client) GetUTXOExitData(utxoPosition int) (*StandardExitUTXOData, error)
- func (c *Client) GetUTXOsFromAddress(address string) (*WatcherUTXOsFromAddress, error)
- func (c *Client) GetWatcher() string
- func (c *Client) GetWatcherStatus() (*WatcherStatus, error)
- func (c *Client) NewPaymentTx(popts ...PaymentOption) (p *PaymentTx)
- type ClientError
- type ContractAddr
- type CreateTransaction
- type CreateTransactionResponse
- type Data
- type Domain
- type EIP712Domain
- type Fee
- type GetTxData
- type HttpClient
- type Input
- type Input0
- type Input1
- type Input2
- type Input3
- type Inputs
- type Message
- type Output
- type Output0
- type Output1
- type Output2
- type Output3
- type Outputs
- type Payment
- type PaymentOption
- type PaymentTx
- type PlasmaTransaction
- type Signer
- type SignerFunc
- type StandardExitUTXOData
- type Submitter
- type Transaction
- type TransactionGetResponse
- type TransactionSubmitResponse
- type Transactions
- type TypedData
- type TypedTransaction
- type Types
- type WatcherBalanceFromAddress
- type WatcherStatus
- type WatcherUTXOsFromAddress
Constants ¶
const ( EthCurrency = "0x0000000000000000000000000000000000000000" DefaultMetadata = "0x0000000000000000000000000000000000000000000000000000000000000000" MaxOutputs = 4 )
Variables ¶
This section is empty.
Functions ¶
func BuildTransaction ¶
BuildTransaction to prepare for signing
func SignTransaction ¶
func SignTransaction(s Signer, sf SignerFunc) ([][]byte, error)
SignTransaction with Signer interface and a signing function SignFunc agnostic to the actual implementation of signer function
Types ¶
type Builder ¶
type Builder interface {
BuildTransaction() error
}
Builder is a struct that can build plasma tx
type ChallengeUTXOData ¶
type ChallengeUTXOData struct { Version string `json:"version"` Success bool `json:"success"` Data struct { ExitId *big.Int `json:"exit_id"` InputIndex uint8 `json:"input_index"` Sig string `json:"sig"` Txbytes string `json:"txbytes"` } `json:"data"` }
ChallengeUTXOData is a response from watcher from /utxo.get_challenge_data endpoint
type Client ¶
type Client struct { Watcher *url.URL HttpClient HttpClient }
Client is a childchain client that holds a Watcher endpoint and HttpClient
func NewClient ¶
func NewClient(watcher string, httpclient HttpClient) (*Client, error)
NewClient Creates new instance of child chain client with a watcher endpoint and a HTTP client
func (*Client) GetBalance ¶
func (c *Client) GetBalance(address string) (*WatcherBalanceFromAddress, error)
GetBalance fetchs a balance for a certain address
func (*Client) GetChallengeData ¶
func (c *Client) GetChallengeData(utxoPosition int) (*ChallengeUTXOData, error)
GetChallengeData from the watcher based on UTXO position to be used in rootchain Challenge function call
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction(txHash string) (*TransactionGetResponse, error)
GetTransaction fetches data about a certain transaction hash via transaction.get endpoint
func (*Client) GetUTXOExitData ¶
func (c *Client) GetUTXOExitData(utxoPosition int) (*StandardExitUTXOData, error)
GetUTXOExitData from watcher based on utxo position from /utxo.get_exit_data endpoint to be used in rootchain exit function call
func (*Client) GetUTXOsFromAddress ¶
func (c *Client) GetUTXOsFromAddress(address string) (*WatcherUTXOsFromAddress, error)
GetUTXOsFromAddress Retrieve the UTXOs associated with an address from the Watcher client
func (*Client) GetWatcher ¶
GetWatcher returns the watcher URL string
func (*Client) GetWatcherStatus ¶
func (c *Client) GetWatcherStatus() (*WatcherStatus, error)
GetWatcherStatus retrieves watcher status via status.get API
func (*Client) NewPaymentTx ¶
func (c *Client) NewPaymentTx(popts ...PaymentOption) (p *PaymentTx)
type ClientError ¶
type ClientError struct { Version string `json:"version"` Success bool `json:"success"` Data struct { Object string `json:"object"` Description string `json:"description"` Code string `json:"code"` } `json:"data"` }
ClientError is a general error message expected from a Watcher response
type ContractAddr ¶
type ContractAddr struct { Erc20Vault string `json:"erc20_vault"` EthVault string `json:"eth_vault"` PaymentExitGame string `json:"payment_exit_game"` PlasmaFramework string `json:"plasma_framework"` }
WatcherStatus is a returned response from calling status.get
type CreateTransaction ¶
type CreateTransaction struct { Owner common.Address `json:"owner"` Payments []Payment `json:"payments"` Fee Fee `json:"fee"` Metadata string `json:"metadata"` }
CreateTransaction is a payload to be submitted via transaction.create endpoint
type Data ¶
type Data struct { Result string `json:"result"` Transactions []Transactions `json:"transactions"` Object string `json:"object"` Code string `json:"code"` Description string `json:"description"` }
type EIP712Domain ¶
type Message ¶
type Message struct { Input0 Input0 `json:"input0"` Input1 Input1 `json:"input1"` Input2 Input2 `json:"input2"` Input3 Input3 `json:"input3"` Output0 Output0 `json:"output0"` Output1 Output1 `json:"output1"` Output2 Output2 `json:"output2"` Output3 Output3 `json:"output3"` Metadata string `json:"metadata"` }
type Payment ¶
type Payment struct { Amount *big.Int `json:"amount"` Currency common.Address `json:"currency"` Owner common.Address `json:"owner"` }
Payment specifies the amount, currency and recipient of the output
type PaymentOption ¶
type PaymentOption func(*CreateTransaction)
func AddFee ¶
func AddFee(curr common.Address) PaymentOption
func AddMetadata ¶
func AddMetadata(m string) PaymentOption
func AddOwner ¶
func AddOwner(o common.Address) PaymentOption
func AddPayment ¶
func AddPayment(amount string, addr, curr common.Address) PaymentOption
type PaymentTx ¶
type PaymentTx struct { Client *Client CreateTransaction *CreateTransaction CreateTransactionResponse *CreateTransactionResponse Signatures [][]byte TypedTransaction TypedTransaction }
PaymentTx is a general P2P payment transaction implemented using Watcher's set of convenience API it can be used to transfer funds from one to many
func (*PaymentTx) BuildTransaction ¶
BuildTransaction forms a transaction to be signed via transaction.create endpoint NOTE: if response.Data.Result == "intermediate" means payment cannot be completed in one transaction, this tx will automatically performs a merge instead TODO: clients should be able to respond to intermediate transactions
func (*PaymentTx) SignTransaction ¶
func (p *PaymentTx) SignTransaction(signer SignerFunc) ([][]byte, error)
SignTransaction takes in any Signer function and uses it on the SignHash a custom signing function can be used as input
func (*PaymentTx) SubmitTransaction ¶
func (p *PaymentTx) SubmitTransaction() (*TransactionSubmitResponse, error)
SubmitTransaction submit payment transaction through /transaction.submit_typed endpoint
type PlasmaTransaction ¶
PlasmaTransaction interface, can build, sign, submit
type Signer ¶
type Signer interface {
SignTransaction(SignerFunc) ([][]byte, error)
}
Signer is a struct that can sign plasma tx
type SignerFunc ¶
SignerFunc is any function that takes in raw byte and return signature of type [][]byte
func SignWithRawKeys ¶
func SignWithRawKeys(keys ...string) SignerFunc
SignWithRawKeys takes private key as raw strings and return a function of type SignerFunc NOTE: this is a default convenience function for signing, user should implement different Signing function
type StandardExitUTXOData ¶
type StandardExitUTXOData struct { Version string `json:"version"` Success bool `json:"success"` Data struct { UtxoPos *big.Int `json:"utxo_pos"` Txbytes string `json:"txbytes"` Sigs string `json:"sigs"` Proof string `json:"proof"` } `json:"data"` }
StandardExitUTXOData is a response from watcher from /utxo.get_exit_data endpoint
type Submitter ¶
type Submitter interface {
SubmitTransaction() (*TransactionSubmitResponse, error)
}
Submitter is a struct that can submit plasma tx
type Transaction ¶
type TransactionGetResponse ¶
type TransactionSubmitResponse ¶
type TransactionSubmitResponse struct { Version string `json:"version"` Success bool `json:"success"` Data struct { Blknum int `json:"blknum"` Txindex int `json:"txindex"` Txhash string `json:"txhash"` Object string `json:"object"` Code string `json:"code"` Description string `json:"description"` Messages struct { ErrorKey string `json:"error_key"` } `json:"messages"` } `json:"data"` }
TransactionSubmitResponse is an expected response from making transaction to watcher
func SubmitTransaction ¶
func SubmitTransaction(s Submitter) (*TransactionSubmitResponse, error)
SubmitTransaction with submitter interface
type Transactions ¶
type TypedTransaction ¶
type TypedTransaction struct { Domain Domain `json:"domain"` Message Message `json:"message"` Signatures []string `json:"signatures"` }
TypedTransaction is a transaction data to be submitted to submit_typed endpoint
type Types ¶
type Types struct { EIP712Domain []EIP712Domain `json:"EIP712Domain"` Transaction []Transaction `json:"Transaction"` Input []Input `json:"Input"` Output []Output `json:"Output"` }
type WatcherBalanceFromAddress ¶
type WatcherBalanceFromAddress struct { Version string `json:"version"` Success bool `json:"success"` Data []struct { Currency string `json:"currency"` Amount float64 `json:"amount"` } `json:"data"` }
WatcherBalanceFromAddress is a returned response from calling account.get_balance
type WatcherStatus ¶
type WatcherStatus struct { Data struct { ByzantineEvents []struct { Event string `json:"event"` Details map[string]interface{} `json:"details"` } `json:"byzantine_events"` ContractAddr ContractAddr `json:"contract_addr"` EthSyncing bool `json:"eth_syncing"` InFlightExits []struct { EthHeight int `json:"eth_height"` PiggybackedInputs []interface{} `json:"piggybacked_inputs"` PiggybackedOutputs []interface{} `json:"piggybacked_outputs"` Txbytes string `json:"txbytes"` Txhash string `json:"txhash"` } `json:"in_flight_exits"` LastMinedChildBlockNumber int `json:"last_mined_child_block_number"` LastMinedChildBlockTimestamp int `json:"last_mined_child_block_timestamp"` LastSeenEthBlockNumber int `json:"last_seen_eth_block_number"` LastSeenEthBlockTimestamp int `json:"last_seen_eth_block_timestamp"` LastValidatedChildBlockNumber int `json:"last_validated_child_block_number"` LastValidatedChildBlockTimestamp int `json:"last_validated_child_block_timestamp"` ServicesSyncedHeights []struct { Height int `json:"height"` Service string `json:"service"` } `json:"services_synced_heights"` } `json:"data"` Success bool `json:"success"` Version string `json:"version"` }
type WatcherUTXOsFromAddress ¶
type WatcherUTXOsFromAddress struct { Version string `json:"version"` Success bool `json:"success"` Data []struct { UtxoPos *big.Int `json:"utxo_pos"` Txindex int `json:"txindex"` Owner string `json:"owner"` Oindex int `json:"oindex"` Currency string `json:"currency"` Blknum int `json:"blknum"` Amount float64 `json:"amount"` } `json:"data"` }
WatcherUTXOsFromAddress is a returned response from calling account.get_utxos