Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { TokenNetworkIdentifier common.Address ChannelIdentifier int64 PartnerAddress common.Address TokenAddress common.Address Balance int64 TotalDeposit int64 State string SettleTimeout int64 RevealTimeout int64 }
Channel represents a payment channel between two ethereum addresses. This contains high level information about the network, partners, the token being used.
type Client ¶
type Client struct { Opener Closer IncreaseDepositor }
Client allows for all Channel operations to be perfomed over HTTP calls to a Raiden node.
type Closer ¶
type Closer interface {
Close(ctx context.Context, tokenAddress, partnerAddress common.Address) (*Channel, error)
}
Closer represents a generic interface to Close a Payment Channel given a token and partner address.
Example ¶
var ( channelClient *Client config = &config.Config{ Host: "http://localhost:5001", APIVersion: "v1", } tokenAddress = common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359") // DAI Stablecoin partnerAddress = common.HexToAddress("0x1f7402f55e142820ea3812106d0657103fc1709e") channel *Channel err error ) channelClient = NewClient(config, http.DefaultClient) if channel, err = channelClient.Close(context.Background(), tokenAddress, partnerAddress); err != nil { panic(fmt.Sprintf("unable to close channel: %s", err.Error())) } fmt.Printf("Close Channel Info: %+v\n", channel)
Output:
type IncreaseDepositor ¶
type IncreaseDepositor interface {
IncreaseDeposit(ctx context.Context, tokenAddress, partnerAddress common.Address, deposit int64) (*Channel, error)
}
IncreaseDepositor represents a generic interface to Increase the Deposit of a Payment Channel given a token and partner address.
Example ¶
var ( channelClient *Client config = &config.Config{ Host: "http://localhost:5001", APIVersion: "v1", } tokenAddress = common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359") // DAI Stablecoin partnerAddress = common.HexToAddress("0x1f7402f55e142820ea3812106d0657103fc1709e") deposit = int64(1000) channel *Channel err error ) channelClient = NewClient(config, http.DefaultClient) if channel, err = channelClient.IncreaseDeposit(context.Background(), tokenAddress, partnerAddress, deposit); err != nil { panic(fmt.Sprintf("unable to increase deposit in payment channel: %s", err.Error())) } fmt.Printf("Channel Info: %+v\n", channel)
Output:
func NewIncreaseDepositor ¶
func NewIncreaseDepositor(config *config.Config, httpClient *http.Client) IncreaseDepositor
NewIncreaseDepositor creates a new default Channel depositor increaser given a Raiden node configuration and an http client.
type Opener ¶
type Opener interface {
Open(ctx context.Context, tokenAddress, partnerAddress common.Address, deposit, settleTimeout int64) (*Channel, error)
}
Opener represents a generic interface to Open a Payment Channel given a token, partner address, deposit and a settle timeout.
Example ¶
var ( channelClient *Client config = &config.Config{ Host: "http://localhost:5001", APIVersion: "v1", } tokenAddress = common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359") // DAI Stablecoin partnerAddress = common.HexToAddress("0x1f7402f55e142820ea3812106d0657103fc1709e") settleTimeout = int64(60) channel *Channel err error ) channelClient = NewClient(config, http.DefaultClient) if channel, err = channelClient.IncreaseDeposit(context.Background(), tokenAddress, partnerAddress, settleTimeout); err != nil { panic(fmt.Sprintf("unable to open payment channel: %s", err.Error())) } fmt.Printf("Channel Info: %+v\n", channel)
Output: