doge

package
v0.0.0-...-3f3ae68 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainTestnet = "testnet"
	ChainMainnet = "mainnet"
)

Variables

View Source
var (
	ErrUnsupportedChain = errors.New("Unsupported Doge chainnet")
)

Functions

func EncodePublicDataToAddress

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

func EncodePublicKeyToAddress

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

@param publicKey can start with 0x or not.

func IsValidAddress

func IsValidAddress(address, chainnet string) bool

Types

type Account

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

func AccountWithPrivateKey

func AccountWithPrivateKey(prikey string, chainnet string) (*Account, error)

func AsDogecoinAccount

func AsDogecoinAccount(account base.Account) *Account

func NewAccountWithMnemonic

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

func (*Account) Address

func (a *Account) Address() string

@return default is the mainnet address

func (*Account) DecodeAddressToPublicKey

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

@return publicKey that will start with 0x.

func (*Account) EncodePublicKeyToAddress

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

@param publicKey can start with 0x or not.

func (*Account) IsValidAddress

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

func (*Account) PrivateKey

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

@return privateKey data

func (*Account) PrivateKeyHex

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

@return privateKey string that will start with 0x.

func (*Account) PublicKey

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

@return publicKey data

func (*Account) PublicKeyHex

func (a *Account) PublicKeyHex() string

@return publicKey string that will start with 0x.

func (*Account) Sign

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

TODO: function not implement yet.

func (*Account) SignHex

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

TODO: function not implement yet.

type Chain

type Chain struct {
	*Util
}

func NewChainWithChainnet

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

func (*Chain) BalanceOfAccount

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

func (*Chain) BalanceOfAddress

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

func (*Chain) BalanceOfPublicKey

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

func (*Chain) BatchFetchTransactionStatus

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

func (*Chain) BuildTransfer

func (t *Chain) BuildTransfer(sender, receiver, amount string) (txn base.Transaction, err error)

func (*Chain) BuildTransferAll

func (t *Chain) BuildTransferAll(sender, receiver string) (txn base.Transaction, err error)

func (*Chain) CanTransferAll

func (t *Chain) CanTransferAll() bool

func (*Chain) Chain

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

func (*Chain) EstimateTransactionFee

func (c *Chain) EstimateTransactionFee(transaction base.Transaction) (fee *base.OptionalString, err error)

func (*Chain) EstimateTransactionFeeUsePublicKey

func (c *Chain) EstimateTransactionFeeUsePublicKey(transaction base.Transaction, pubkey string) (fee *base.OptionalString, err error)

func (*Chain) FetchTransactionDetail

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

Fetch transaction details through transaction hash

func (*Chain) FetchTransactionStatus

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

func (*Chain) FetchUtxos

func (c *Chain) FetchUtxos(address string, limit int) (*base.OptionalString, error)

@param limit Specify how many the latest utxos to fetch, The minimum value of the limit is 100.

func (*Chain) MainToken

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

func (*Chain) SendRawTransaction

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

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

func (*Chain) SendSignedTransaction

func (c *Chain) SendSignedTransaction(signedTxn base.SignedTransaction) (hash *base.OptionalString, err error)

func (*Chain) SuggestFeeRate

func (c *Chain) SuggestFeeRate() (*FeeRate, error)

func (*Chain) TokenInfo

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

type FeeRate

type FeeRate struct {
	Low     int64 `json:"low_fee_per_kb"`
	Average int64 `json:"medium_fee_per_kb"`
	High    int64 `json:"high_fee_per_kb"`
}

type SDKUTXOList

type SDKUTXOList struct {
	Txids      []*UTXO `json:"txids"`
	FastestFee int     `json:"fastestFee"`
}

type Transaction

type Transaction struct {
	// Demo: https://api.blockcypher.com/v1/doge/main/txs/7bc313903372776e1eb81d321e3fe27c9721ce8e71a9bcfee1bde6baea31b5c2
	HashString    string               `json:"hash"`
	Total         *big.Int             `json:"total"`
	Fees          *big.Int             `json:"fees"`
	Received      *time.Time           `json:"received"`
	Confirmed     *time.Time           `json:"confirmed"`
	Confirmations int64                `json:"confirmations"`
	Inputs        []*TransactionInput  `json:"inputs"`
	Outputs       []*TransactionOutput `json:"outputs"`
	OpReturn      string               `json:"data_protocol"`
}

func (*Transaction) From

func (t *Transaction) From() string

func (*Transaction) SdkDetail

func (t *Transaction) SdkDetail() *base.TransactionDetail

func (*Transaction) Status

func (t *Transaction) Status() base.TransactionStatus

func (*Transaction) ToAddressAndTransferAmount

func (t *Transaction) ToAddressAndTransferAmount() (string, *big.Int)

type TransactionInput

type TransactionInput struct {
	Addresses []string `json:"addresses"`
}

type TransactionOutput

type TransactionOutput struct {
	Value     *big.Int `json:"value"`
	Addresses []string `json:"addresses"`
}

type UTXO

type UTXO struct {
	// input from like
	// https://api.blockcypher.com/v1/doge/main/addrs/D8aDCsK4TA9NYhmwiqw1BjZ4CP8LQ814Ea?limit=5&unspentOnly=true
	Txid  string   `json:"tx_hash"`
	Index int      `json:"tx_output_n"`
	Value *big.Int `json:"value"`
}

func (*UTXO) MarshalJSON

func (u *UTXO) MarshalJSON() ([]byte, error)

type UTXOList

type UTXOList struct {
	Utxos []*UTXO `json:"txrefs"`
}

type Util

type Util struct {
	Chainnet string
}

func NewUtilWithChainnet

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

func (*Util) DecodeAddressToPublicKey

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

Warning: Dogecoin cannot support decode address to public key

func (*Util) EncodePublicDataToAddress

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

func (*Util) EncodePublicKeyToAddress

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

@param publicKey can start with 0x or not.

func (*Util) IsValidAddress

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