ethereum

package
v0.0.0-...-787377c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const PrivateKeySize = 256 / 8

Variables

View Source
var DefaultKeystore = "~/.ethereum/keystore"

Functions

func GetAccountAndSigner

func GetAccountAndSigner(accountString string, client *ethclient.Client) (*bind.TransactOpts, func(data []byte) ([]byte, error), error)

func GetClient

func GetClient(url string) (*ethclient.Client, error)

Types

type PaymentChannel

type PaymentChannel struct {
	Payment      *abi.Payment
	TransactOpts *bind.TransactOpts
	Publisher    common.Address
	PodID        common.Hash
	PricingTable resource.PricingTableMap
}

Manipulator encompassing some of the typical operations one can do with a payment channel

func (*PaymentChannel) Available

func (p *PaymentChannel) Available() (*big.Int, error)

Get how much funds are still available in the channel

func (*PaymentChannel) WithdrawIfOverMargin

func (p *PaymentChannel) WithdrawIfOverMargin(transferAddress common.Address, amount *big.Int, tolerance *big.Int) (*types.Transaction, error)

Withdraw the funds between Withdrawn() and amount; that is, withdraw amount - Withdrawn() -- but only if the amount that will be withdrawn in such a transaction is over the given tolerance. Useful to avoid spamming costly transactions that only net small amounts of income.

func (*PaymentChannel) WithdrawUpTo

func (p *PaymentChannel) WithdrawUpTo(transferAddress common.Address, amount *big.Int) (*types.Transaction, error)

Withdraw the funds between Withdrawn() and amount; that is, withdraw amount - Withdrawn()

func (*PaymentChannel) Withdrawn

func (p *PaymentChannel) Withdrawn() (*big.Int, error)

Get how much funds have been withdrawn from the channel this far

type PaymentChannelValidator

type PaymentChannelValidator struct {
	ChainID *big.Int
	// contains filtered or unexported fields
}

A validator for payment channels which confirms they have sufficient funds and are established on a permissible contract before returning a PaymentChannel that can be used to interact with them.

func NewPaymentChannelValidator

func NewPaymentChannelValidator(ethClient *ethclient.Client, pricingTables map[common.Address]resource.PricingTableMap, transactOpts *bind.TransactOpts) (*PaymentChannelValidator, error)

Create a new PaymentChannelValidator

func (*PaymentChannelValidator) Parse

Parse/validate a pb.PaymentChannel to create a PaymentChannel

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL