btc

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ChainSignet  = "signet"
	ChainMainnet = "mainnet"
	// ComingChat used, similar mainnet's alias.
	ChainBitcoin = "bitcoin"
)

Variables

View Source
var (
	ErrUnsupportedChain  = errors.New("Unsupported BTC chainnet")
	ErrHttpResponseParse = errors.New("Network data parsing error")

	ErrDecodeAddress = errors.New("Btc cannot support decode address to public key")
)

Functions

func EncodePublicDataToAddress added in v0.2.0

func EncodePublicDataToAddress(public []byte, chainnet string) (string, error)

func EncodePublicKeyToAddress added in v0.2.0

func EncodePublicKeyToAddress(publicKey, chainnet string) (string, error)

@param publicKey can start with 0x or not.

func FetchTransactionDetail deprecated added in v0.1.5

func FetchTransactionDetail(hashString, chainnet string) (*base.TransactionDetail, error)

Deprecated: FetchTransactionDetail is deprecated. Please Use Chain.FetchTransactionDetail() instead.

func FetchTransactionStatus deprecated added in v0.1.5

func FetchTransactionStatus(hashString string, chainnet string) base.TransactionStatus

Deprecated: FetchTransactionStatus is deprecated. Please Use Chain.FetchTransactionStatus() instead.

func IsValidAddress

func IsValidAddress(address, chainnet string) bool

@param chainnet chain name

func QueryBalance deprecated added in v0.1.5

func QueryBalance(address, chainnet string) (string, error)

Deprecated: QueryBalance is deprecated. Please Use Chain.QueryBalanceWithAddress() instead.

func QueryBalancePubkey deprecated added in v0.1.5

func QueryBalancePubkey(pubkey, chainnet string) (string, error)

Deprecated: QueryBalancePubkey is deprecated. Please Use Chain.QueryBalanceWithPublicKey() instead.

func SdkBatchTransactionStatus deprecated added in v0.1.5

func SdkBatchTransactionStatus(hashListString string, chainnet string) string

Deprecated: SdkBatchTransactionStatus is deprecated. Please Use Chain.BatchFetchTransactionStatus() instead.

func SendRawTransaction deprecated added in v0.1.5

func SendRawTransaction(signedTx string, chainnet string) (string, error)

Deprecated: SendRawTransaction is deprecated. Please Use Chain.SendRawTransaction() instead.

Types

type Account added in v0.2.0

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

func NewAccountWithMnemonic added in v0.2.0

func NewAccountWithMnemonic(mnemonic, chainnet string) (*Account, error)

func (*Account) Address added in v0.2.0

func (a *Account) Address() string

@return default is the mainnet address

func (*Account) DecodeAddressToPublicKey added in v0.2.2

func (a *Account) DecodeAddressToPublicKey(address string) (string, error)

@return publicKey that will start with 0x.

func (*Account) DeriveAccountAt added in v0.2.0

func (a *Account) DeriveAccountAt(chainnet string) (*Account, error)

func (*Account) EncodePublicKeyToAddress added in v0.2.2

func (a *Account) EncodePublicKeyToAddress(publicKey string) (string, error)

@param publicKey can start with 0x or not.

func (*Account) IsValidAddress added in v0.2.2

func (a *Account) IsValidAddress(address string) bool

func (*Account) PrivateKey added in v0.2.0

func (a *Account) PrivateKey() ([]byte, error)

@return privateKey data

func (*Account) PrivateKeyHex added in v0.2.0

func (a *Account) PrivateKeyHex() (string, error)

@return privateKey string that will start with 0x.

func (*Account) PublicKey added in v0.2.0

func (a *Account) PublicKey() []byte

@return publicKey data

func (*Account) PublicKeyHex added in v0.2.0

func (a *Account) PublicKeyHex() string

@return publicKey string that will start with 0x.

func (*Account) Sign added in v0.2.0

func (a *Account) Sign(message []byte, password string) ([]byte, error)

TODO: function not implement yet.

func (*Account) SignHex added in v0.2.0

func (a *Account) SignHex(messageHex string, password string) (*base.OptionalString, error)

TODO: function not implement yet.

type Chain added in v0.2.0

type Chain struct {
	*Util
}

func NewChainWithChainnet added in v0.2.0

func NewChainWithChainnet(chainnet string) (*Chain, error)

func (*Chain) BalanceOfAccount added in v0.2.0

func (c *Chain) BalanceOfAccount(account base.Account) (*base.Balance, error)

func (*Chain) BalanceOfAddress added in v0.2.0

func (c *Chain) BalanceOfAddress(address string) (*base.Balance, error)

func (*Chain) BalanceOfPublicKey added in v0.2.0

func (c *Chain) BalanceOfPublicKey(publicKey string) (*base.Balance, error)

func (*Chain) BatchFetchTransactionStatus added in v0.2.0

func (c *Chain) BatchFetchTransactionStatus(hashListString string) string

func (*Chain) Chain added in v0.2.0

func (c *Chain) Chain() base.Chain

func (*Chain) FetchTransactionDetail added in v0.2.0

func (c *Chain) FetchTransactionDetail(hash string) (*base.TransactionDetail, error)

Fetch transaction details through transaction hash Note: The input parsing of bitcoin is very complex and the network cost is relatively high, So only the status and timestamp can be queried.

func (*Chain) FetchTransactionStatus added in v0.2.0

func (c *Chain) FetchTransactionStatus(hash string) base.TransactionStatus

func (*Chain) MainToken added in v0.2.0

func (c *Chain) MainToken() base.Token

func (*Chain) SendRawTransaction added in v0.2.0

func (c *Chain) SendRawTransaction(signedTx string) (string, error)

Send the raw transaction on-chain @return the hex hash string

func (*Chain) TokenInfo added in v0.2.0

func (c *Chain) TokenInfo() (*base.TokenInfo, error)

type FeeRate added in v0.2.3

type FeeRate struct {
	Low     int64
	Average int64
	High    int64
}

func SuggestFeeRate added in v0.2.3

func SuggestFeeRate() (*FeeRate, error)

type Util added in v0.2.0

type Util struct {
	Chainnet string
}

func NewUtilWithChainnet added in v0.2.0

func NewUtilWithChainnet(chainnet string) (*Util, error)

func (*Util) DecodeAddressToPublicKey added in v0.2.0

func (u *Util) DecodeAddressToPublicKey(address string) (string, error)

Warning: Btc cannot support decode address to public key

func (*Util) EncodePublicDataToAddress added in v0.2.0

func (u *Util) EncodePublicDataToAddress(public []byte) (string, error)

func (*Util) EncodePublicKeyToAddress added in v0.2.0

func (u *Util) EncodePublicKeyToAddress(publicKey string) (string, error)

@param publicKey can start with 0x or not.

func (*Util) IsValidAddress added in v0.2.0

func (u *Util) IsValidAddress(address string) bool

Jump to

Keyboard shortcuts

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