mobile

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: LGPL-3.0 Imports: 16 Imported by: 0

README

Yeth Apis

public native byte[] call(String api, byte[] params) throws Exception public native String createAccount(String passphrase) public native Account find(byte[] address) throws Exception public native Account importECDSAKey(byte[] key, String passphrase) throws Exception public native String importKeyJson(byte[] keyJson, String passphrase, String newPassphrase) throws Exception public native void lock(Address address) throws Exception public native byte[] sendTransaction(Account account, Transaction tx) throws Exception public native byte[] sendTransactionWithPassphrase(Account account, String passphrase, Transaction tx) throws Exception public native byte[] sendTransactions(Account account, Transactions txs) throws Exception public native byte[] sendTransactionsWithPassphrase(Account account, String passphrase, Transactions txs) throws Exception public native void timedUnlock(Account account, String passphrase, long timeout) throws Exception public native void unlock(Account account, String passphrase) throws Exception public native void updateAccount(Account account, String passphrase, String newPassphrase) throws Exception

yeth, _ := NewYeth(nil)
var address string = yeth.CreateAccount("111111")
var account Account := yeth.find(address)
tx := new Transaction(nonce, toAddress, amount, long gasLimit, BigInt gasPrice, byte[] data)
yeth.sendTransactionWithPassphrase(account, "111111", tx)

changelog

0917
  1. Find(address *Address)接口修改参数类型 string -> *Address
  2. GetBalance(address *Address) 参数类型 string -> *Address
  3. NewAddress(address string) (*Address, error) 增加返回错误信息

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StandardScryptN = keystore.StandardScryptN
	StandardScryptP = keystore.StandardScryptP
	LightScryptN    = keystore.LightScryptN
	LightScryptP    = keystore.LightScryptP

	PassphraseKeyStore = 0
	PlaintextKeyStore  = 1
)

Functions

This section is empty.

Types

type Account

type Account struct {
	// contains filtered or unexported fields
}

func (*Account) GetAddress

func (acc *Account) GetAddress() *Address

func (*Account) GetPath

func (acc *Account) GetPath() string

type Address

type Address struct {
	// contains filtered or unexported fields
}

Address represents the 20 byte address of an Ethereum account.

func NewAddress

func NewAddress(address string) (*Address, error)

func (Address) String

func (address Address) String() string

type BigInt

type BigInt struct {
	// contains filtered or unexported fields
}

A BigInt represents a signed multi-precision integer.

func NewBigInt

func NewBigInt(x int64) *BigInt

NewBigInt allocates and returns a new BigInt set to x.

func (*BigInt) Add

func (bi *BigInt) Add(num int64)

func (*BigInt) GetBytes

func (bi *BigInt) GetBytes() []byte

GetBytes returns the absolute value of x as a big-endian byte slice.

func (*BigInt) GetInt64

func (bi *BigInt) GetInt64() int64

GetInt64 returns the int64 representation of x. If x cannot be represented in an int64, the result is undefined.

func (*BigInt) GetString

func (bi *BigInt) GetString(base int) string

GetString returns the value of x as a formatted string in some number base.

func (*BigInt) Hex

func (bi *BigInt) Hex() string

func (*BigInt) SetBytes

func (bi *BigInt) SetBytes(buf []byte)

SetBytes interprets buf as the bytes of a big-endian unsigned integer and sets the big int to that value.

func (*BigInt) SetHexString

func (bi *BigInt) SetHexString(hexString string) error

func (*BigInt) SetInt64

func (bi *BigInt) SetInt64(x int64)

SetInt64 sets the big int to x.

func (*BigInt) SetString

func (bi *BigInt) SetString(x string, base int)

SetString sets the big int to x.

The string prefix determines the actual conversion base. A prefix of "0x" or "0X" selects base 16; the "0" prefix selects base 8, and a "0b" or "0B" prefix selects base 2. Otherwise the selected base is 10.

func (*BigInt) Sign

func (bi *BigInt) Sign() int

Sign returns:

-1 if x <  0
 0 if x == 0
+1 if x >  0

func (*BigInt) String

func (bi *BigInt) String() string

String returns the value of x as a formatted decimal string.

type BigInts

type BigInts struct {
	// contains filtered or unexported fields
}

BigInts represents a slice of big ints.

func (*BigInts) Get

func (bi *BigInts) Get(index int) (bigint *BigInt, _ error)

Get returns the bigint at the given index from the slice.

func (*BigInts) Set

func (bi *BigInts) Set(index int, bigint *BigInt) error

Set sets the big int at the given index in the slice.

func (*BigInts) Size

func (bi *BigInts) Size() int

Size returns the number of big ints in the slice.

type Config

type Config struct {
	Endpoint string
	DataDir  string
	ScryptN  int
	ScryptP  int
	Keystore int
}

func NewConfig

func NewConfig() *Config

NewConfig creates a new node option set, initialized to the default values.

type JsonRpcIntResponse

type JsonRpcIntResponse struct {
	JsonRpc string `json:"jsonrpc"`
	Id      int64  `json:"id"`
	Result  string `json:"result"`
}

{"jsonrpc":"2.0","id":2,"result":0}

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

Transaction represents a single transaction.

func NewTransaction

func NewTransaction(nonce string, to *Address, amount string, gasLimit string, gasPrice string, data []byte) (*Transaction, error)

NewTransaction creates a new transaction with the given properties.

type Transactions

type Transactions struct {
	// contains filtered or unexported fields
}

func (*Transactions) Append

func (t *Transactions) Append(tx *Transaction)

Append Transaction to list

type YouMobile

type YouMobile struct {
	// contains filtered or unexported fields
}

func NewYouMobile

func NewYouMobile(config *Config) (*YouMobile, error)

func (*YouMobile) AccountManager

func (y *YouMobile) AccountManager() accounts.AccountManager

func (*YouMobile) Call

func (y *YouMobile) Call(api string, params []byte) (string, error)

func (*YouMobile) CreateAccount

func (y *YouMobile) CreateAccount(passphrase string) (*Account, error)

func (*YouMobile) ExportECDSAKey

func (y *YouMobile) ExportECDSAKey(account *Account, passphrase string) (string, error)

func (*YouMobile) ExportKeyJson

func (y *YouMobile) ExportKeyJson(account *Account, passphrase, newPassphrase string) (string, error)

func (*YouMobile) Find

func (y *YouMobile) Find(address string) (*Account, error)

func (*YouMobile) ImportECDSAKey

func (y *YouMobile) ImportECDSAKey(key string, passphrase string) (*Account, error)

ImportECDSA stores the given key into the key directory, encrypting it with the passphrase.

func (*YouMobile) ImportKeyJson

func (y *YouMobile) ImportKeyJson(keyJson string, passphrase, newPassphrase string) (*Account, error)

func (*YouMobile) Lock

func (y *YouMobile) Lock(address *Address) error

Lock removes the private key with the given address from memory.

func (*YouMobile) SignTransaction

func (y *YouMobile) SignTransaction(account *Account, tx *Transaction) (string, error)

SignTransaction sign tx for SignRawTransaction

func (*YouMobile) TimedUnlock

func (y *YouMobile) TimedUnlock(account *Account, passphrase string, timeout int64) error

TimedUnlock unlocks the given account with the passphrase. The account stays unlocked for the duration of timeout (nanoseconds). A timeout of 0 unlocks the account until the program exits. The account must match a unique key file.

If the account address is already unlocked for a duration, TimedUnlock extends or shortens the active unlock timeout. If the address was previously unlocked indefinitely the timeout is not altered.

func (*YouMobile) Unlock

func (y *YouMobile) Unlock(account *Account, passphrase string) error

Unlock unlocks the given account indefinitely.

func (*YouMobile) UpdateAccount

func (y *YouMobile) UpdateAccount(account *Account, passphrase, newPassphrase string) error

UpdateAccount changes the passphrase of an existing account.

Jump to

Keyboard shortcuts

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