bitcoin

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InsufficientBalanceError = errors.New("InsufficientBalanceError")
)

Functions

func CreateDogeWallet

func CreateDogeWallet(compress bool) error

func GetBalanceDoge

func GetBalanceDoge(addr string) (result resultBalance, err error)

func GetDogeMainNetParams

func GetDogeMainNetParams() chaincfg.Params

doge net params

func HexPrivateKeyToScript

func HexPrivateKeyToScript(addr string, params chaincfg.Params, privateKeyHex string) (pkScript []byte, privateKey *btcec.PrivateKey, compress bool, e error)

func VinScriptSigToAddress

func VinScriptSigToAddress(sig *btcjson.ScriptSig, params chaincfg.Params) (string, string, error)

Types

type BaseRequest

type BaseRequest struct {
	RpcUrl   string
	User     string
	Password string
	Proxy    string
}

BaseRequest

func (*BaseRequest) DecodeRawTransaction

func (b *BaseRequest) DecodeRawTransaction(raw string) (e error)

'{"jsonrpc":"2.0","id":"0","method":"decoderawtransaction","params":[""]}' -H 'Content-Type: application/json'

func (*BaseRequest) EstimateFee

func (b *BaseRequest) EstimateFee() (fee float64, e error)

'{"jsonrpc":"2.0","id":"0","method":"estimatefee","params":[10]}' -H 'Content-Type: application/json'

func (*BaseRequest) GetBlock

func (b *BaseRequest) GetBlock(hash string) (block BlockInfo, e error)

func (*BaseRequest) GetBlockChainInfo

func (b *BaseRequest) GetBlockChainInfo() (data BlockChainInfo, e error)

func (*BaseRequest) GetBlockHash

func (b *BaseRequest) GetBlockHash(blockNumber uint64) (hash string, e error)

'{"jsonrpc":"2.0","id":"0","method":"getblockhash","params":[4600472]}' -H 'Content-Type: application/json'

func (*BaseRequest) GetRawTransaction

func (b *BaseRequest) GetRawTransaction(hash string) (data btcjson.TxRawResult, e error)

'{"jsonrpc":"2.0","id":"0","method":"getrawtransaction","params":["c9b477a5afabbd6ff7afea9a2b0dce9687e1dc56a452b72e336b2961126fe411",true]}' -H 'Content-Type: application/json'

func (*BaseRequest) Request

func (b *BaseRequest) Request(method RpcMethod, params []interface{}, result interface{}) error

func (*BaseRequest) SendRawTransaction

func (b *BaseRequest) SendRawTransaction(raw string) (hash string, e error)

'{"jsonrpc":"2.0","id":"0","method":"sendrawtransaction","params":["",false]}' -H 'Content-Type: application/json'

type BaseResponse

type BaseResponse struct {
	JsonRpc string      `json:"jsonrpc"`
	Id      string      `json:"id"`
	Result  interface{} `json:"result"`
	Error   Error       `json:"error"`
}

BaseResponse

type BlockChainInfo

type BlockChainInfo struct {
	BestBlockHash string `json:"bestblockhash"`
	Blocks        uint64 `json:"blocks"`
	Chain         string `json:"chain"`
	ChainWork     string `json:"chainwork"`
	Headers       uint64 `json:"headers"`
	MedianTime    uint64 `json:"mediantime"`
}

'{"jsonrpc":"2.0","id":"0","method":"getblockchaininfo"}' -H 'Content-Type: application/json'

type BlockInfo

type BlockInfo struct {
	ChainWork         string   `json:"chainwork"`
	Confirmations     uint64   `json:"confirmations"`
	Hash              string   `json:"hash"`
	Height            uint64   `json:"height"`
	MedianTime        uint64   `json:"mediantime"`
	NextBlockHash     string   `json:"nextblockhash"`
	PreviousBlockHash string   `json:"previousblockhash"`
	Time              uint64   `json:"time"`
	Tx                []string `json:"tx"`
}

'{"jsonrpc":"2.0","id":"0","method":"getblock","params":["5d0954672b3d7bc9becbfa017f7cb47714c39ef74ab99c969217ee2af0d40a82"]}' -H 'Content-Type: application/json'

type DustLimit

type DustLimit = int64
const (
	DustLimitBtc  DustLimit = 546
	DustLimitBch  DustLimit = 546
	DustLimitLtc  DustLimit = 5460
	DustLimitDoge DustLimit = 100000000
)

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error

type RemoteSignMethod

type RemoteSignMethod = string
const (
	RemoteSignMethodDogeTx RemoteSignMethod = "wallet_dogSignMsg"
)

type ReqJsonRpc

type ReqJsonRpc struct {
	Jsonrpc string      `json:"jsonrpc"`
	Method  RpcMethod   `json:"method"`
	Params  interface{} `json:"params"`
	Id      string      `json:"id"`
}

type RpcMethod

type RpcMethod string
const (
	RpcMethodGetBlockChainInfo    RpcMethod = "getblockchaininfo"
	RpcMethodGetBlockHash         RpcMethod = "getblockhash"
	RpcMethodGetBlock             RpcMethod = "getblock"
	RpcMethodGetRawTransaction    RpcMethod = "getrawtransaction"
	RpcMethodSendRawTransaction   RpcMethod = "sendrawtransaction"
	RpcMethodEstimateFee          RpcMethod = "estimatefee"
	RpcMethodDecodeRawTransaction RpcMethod = "decoderawtransaction"
)

type TxTool

type TxTool struct {
	RpcClient        *BaseRequest
	Ctx              context.Context
	RemoteSignClient rpc.Client

	DustLimit DustLimit
	Params    chaincfg.Params
}

func (*TxTool) GetUnspentOutputsDoge

func (t *TxTool) GetUnspentOutputsDoge(addr, privateKey string, value int64) (int64, []UnspentOutputs, error)

func (*TxTool) LocalSignTx

func (t *TxTool) LocalSignTx(tx *wire.MsgTx, uos []UnspentOutputs) (string, error)

func (*TxTool) NewTx

func (t *TxTool) NewTx(uos []UnspentOutputs, addresses []string, values []int64, opReturn string) (*wire.MsgTx, error)

func (*TxTool) RemoteSignTx

func (t *TxTool) RemoteSignTx(method RemoteSignMethod, tx *wire.MsgTx, uos []UnspentOutputs) (*wire.MsgTx, error)

func (*TxTool) SendTx

func (t *TxTool) SendTx(tx *wire.MsgTx) (hash string, err error)

type UnspentOutputs

type UnspentOutputs struct {
	Private string `json:"private"`
	Address string `json:"address"`
	Hash    string `json:"hash"`
	Index   uint32 `json:"index"`
	Value   int64  `json:"value"`
}

Jump to

Keyboard shortcuts

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