btc

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AggregateIdentifier used in accepting
	AggregateIdentifier = "aggregate"
)

Variables

This section is empty.

Functions

func AuthoredTxToString

func AuthoredTxToString(authtx interface{}, pretty bool) string

AuthoredTxToString AuthoredTx to string

func GetP2shAddressWithMemo

func GetP2shAddressWithMemo(memo, pubKeyHash []byte, net *chaincfg.Params) (p2shAddress string, redeemScript []byte, err error)

GetP2shAddressWithMemo common

func MarshalToJSON

func MarshalToJSON(obj interface{}, pretty bool) string

MarshalToJSON marshal to json

func NewUnsignedTransaction

func NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb btcutil.Amount, fetchInputs txauthor.InputSource, fetchChange txauthor.ChangeSource, isAggregate bool) (*txauthor.AuthoredTx, error)

NewUnsignedTransaction ref btcwallet ref. https://github.com/btcsuite/btcwallet/blob/b07494fc2d662fdda2b8a9db2a3eacde3e1ef347/wallet/txauthor/author.go we only modify it to support P2PKH change script (the origin only support P2WPKH change script) and update estimate size because we are not use P2WKH

Types

type Bridge

type Bridge struct {
	*tokens.CrossChainBridgeBase
}

Bridge btc bridge

var BridgeInstance *Bridge

BridgeInstance btc bridge instance

func NewCrossChainBridge

func NewCrossChainBridge(isSrc bool) *Bridge

NewCrossChainBridge new btc bridge

func (*Bridge) AggregateUtxos

func (b *Bridge) AggregateUtxos(addrs []string, utxos []*electrs.ElectUtxo) (string, error)

AggregateUtxos aggregate uxtos

func (*Bridge) BuildAggregateTransaction

func (b *Bridge) BuildAggregateTransaction(addrs []string, utxos []*electrs.ElectUtxo) (rawTx *txauthor.AuthoredTx, err error)

BuildAggregateTransaction build aggregate tx (spend p2sh utxo)

func (*Bridge) BuildRawTransaction

func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)

BuildRawTransaction build raw tx

func (*Bridge) CheckSwapinTxType

func (b *Bridge) CheckSwapinTxType(tx *electrs.ElectTx) (p2shBindAddr string, err error)

CheckSwapinTxType check swapin type

func (*Bridge) DcrmSignMsgHash

func (b *Bridge) DcrmSignMsgHash(msgHash []string, args *tokens.BuildTxArgs) (rsv []string, err error)

DcrmSignMsgHash dcrm sign msg hash

func (*Bridge) DcrmSignTransaction

func (b *Bridge) DcrmSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)

DcrmSignTransaction dcrm sign raw tx

func (*Bridge) FindUtxos

func (b *Bridge) FindUtxos(addr string) ([]*electrs.ElectUtxo, error)

FindUtxos impl

func (*Bridge) GetBalance

func (b *Bridge) GetBalance(account string) (*big.Int, error)

GetBalance impl

func (*Bridge) GetBlock

func (b *Bridge) GetBlock(blockHash string) (*electrs.ElectBlock, error)

GetBlock impl

func (*Bridge) GetBlockHash

func (b *Bridge) GetBlockHash(height uint64) (string, error)

GetBlockHash impl

func (*Bridge) GetBlockTransactions

func (b *Bridge) GetBlockTransactions(blockHash string, startIndex uint32) ([]*electrs.ElectTx, error)

GetBlockTransactions impl

func (*Bridge) GetBlockTxids

func (b *Bridge) GetBlockTxids(blockHash string) ([]string, error)

GetBlockTxids impl

func (*Bridge) GetChainConfig

func (b *Bridge) GetChainConfig() *chaincfg.Params

GetChainConfig get chain config (net params)

func (*Bridge) GetCompressedPublicKey

func (b *Bridge) GetCompressedPublicKey(fromPublicKey string, needVerify bool) (cPkData []byte, err error)

GetCompressedPublicKey get compressed public key

func (*Bridge) GetElectTransactionStatus

func (b *Bridge) GetElectTransactionStatus(txHash string) (*electrs.ElectTxStatus, error)

GetElectTransactionStatus impl

func (*Bridge) GetLatestBlockNumber

func (b *Bridge) GetLatestBlockNumber() (uint64, error)

GetLatestBlockNumber impl

func (*Bridge) GetLatestBlockNumberOf

func (b *Bridge) GetLatestBlockNumberOf(apiAddress string) (uint64, error)

GetLatestBlockNumberOf impl

func (*Bridge) GetOutspend

func (b *Bridge) GetOutspend(txHash string, vout uint32) (*electrs.ElectOutspend, error)

GetOutspend impl

func (*Bridge) GetP2shAddress

func (b *Bridge) GetP2shAddress(bindAddr string) (p2shAddress string, redeemScript []byte, err error)

GetP2shAddress get p2sh address from bind address

func (*Bridge) GetP2shAddressByRedeemScript

func (b *Bridge) GetP2shAddressByRedeemScript(redeemScript []byte) (string, error)

GetP2shAddressByRedeemScript get p2sh address by redeem script

func (*Bridge) GetP2shSigScript

func (b *Bridge) GetP2shSigScript(redeemScript []byte) ([]byte, error)

GetP2shSigScript get p2sh signature script

func (*Bridge) GetPoolTransactions

func (b *Bridge) GetPoolTransactions(addr string) ([]*electrs.ElectTx, error)

GetPoolTransactions impl

func (*Bridge) GetPoolTxidList

func (b *Bridge) GetPoolTxidList() ([]string, error)

GetPoolTxidList impl

func (*Bridge) GetReceivedValue

func (b *Bridge) GetReceivedValue(vout []*electrs.ElectTxOut, receiver, pubkeyType string) (value uint64, memoScript string, rightReceiver bool)

GetReceivedValue get received value

func (*Bridge) GetTokenBalance

func (b *Bridge) GetTokenBalance(tokenType, tokenAddress, accountAddress string) (*big.Int, error)

GetTokenBalance impl

func (*Bridge) GetTokenSupply

func (b *Bridge) GetTokenSupply(tokenType, tokenAddress string) (*big.Int, error)

GetTokenSupply impl

func (*Bridge) GetTransaction

func (b *Bridge) GetTransaction(txHash string) (interface{}, error)

GetTransaction impl

func (*Bridge) GetTransactionByHash

func (b *Bridge) GetTransactionByHash(txHash string) (*electrs.ElectTx, error)

GetTransactionByHash impl

func (*Bridge) GetTransactionHistory

func (b *Bridge) GetTransactionHistory(addr, lastSeenTxid string) ([]*electrs.ElectTx, error)

GetTransactionHistory impl

func (*Bridge) GetTransactionStatus

func (b *Bridge) GetTransactionStatus(txHash string) *tokens.TxStatus

GetTransactionStatus impl

func (*Bridge) InitLatestBlockNumber

func (b *Bridge) InitLatestBlockNumber()

InitLatestBlockNumber init latest block number

func (*Bridge) IsP2pkhAddress

func (b *Bridge) IsP2pkhAddress(addr string) bool

IsP2pkhAddress check p2pkh addrss

func (*Bridge) IsP2shAddress

func (b *Bridge) IsP2shAddress(addr string) bool

IsP2shAddress check p2sh addrss

func (*Bridge) IsValidAddress

func (b *Bridge) IsValidAddress(addr string) bool

IsValidAddress check address

func (*Bridge) MakeSignedTransaction

func (b *Bridge) MakeSignedTransaction(authoredTx *txauthor.AuthoredTx, msgHash, rsv []string, sigScripts [][]byte, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)

MakeSignedTransaction make signed tx

func (*Bridge) PostTransaction

func (b *Bridge) PostTransaction(txHex string) (txHash string, err error)

PostTransaction impl

func (*Bridge) SendTransaction

func (b *Bridge) SendTransaction(signedTx interface{}) (txHash string, err error)

SendTransaction send signed tx

func (*Bridge) SetTokenAndGateway

func (b *Bridge) SetTokenAndGateway(tokenCfg *tokens.TokenConfig, gatewayCfg *tokens.GatewayConfig, check bool)

SetTokenAndGateway set token and gateway config

func (*Bridge) SignTransaction

func (b *Bridge) SignTransaction(rawTx interface{}, wif string) (signedTx interface{}, txHash string, err error)

SignTransaction sign tx with wif

func (*Bridge) StartChainTransactionScanJob

func (b *Bridge) StartChainTransactionScanJob()

StartChainTransactionScanJob scan job

func (*Bridge) StartPoolTransactionScanJob

func (b *Bridge) StartPoolTransactionScanJob()

StartPoolTransactionScanJob scan job

func (*Bridge) StartSwapHistoryScanJob

func (b *Bridge) StartSwapHistoryScanJob()

StartSwapHistoryScanJob scan job

func (*Bridge) VerifyAggregateMsgHash

func (b *Bridge) VerifyAggregateMsgHash(msgHash []string, args *tokens.BuildTxArgs) error

VerifyAggregateMsgHash verify aggregate msgHash

func (*Bridge) VerifyConfig

func (b *Bridge) VerifyConfig()

VerifyConfig verify config

func (*Bridge) VerifyMsgHash

func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHash []string, extra interface{}) (err error)

VerifyMsgHash verify msg hash

func (*Bridge) VerifyP2shTransaction

func (b *Bridge) VerifyP2shTransaction(txHash, bindAddress string, allowUnstable bool) (*tokens.TxSwapInfo, error)

VerifyP2shTransaction verify p2sh tx

func (*Bridge) VerifyTransaction

func (b *Bridge) VerifyTransaction(txHash string, allowUnstable bool) (*tokens.TxSwapInfo, error)

VerifyTransaction impl

type EncAuthoredTx

type EncAuthoredTx struct {
	Tx          *EncMsgTx
	TotalInput  btcutil.Amount
	ChangeIndex int
}

EncAuthoredTx stuct

type EncMsgTx

type EncMsgTx struct {
	Txid     string
	Version  int32
	TxIn     []*EncTxIn
	TxOut    []*EncTxOut
	LockTime uint32
}

EncMsgTx struct

type EncOutPoint

type EncOutPoint struct {
	Hash  string
	Index uint32
}

EncOutPoint struct

type EncTxIn

type EncTxIn struct {
	PreviousOutPoint EncOutPoint
	SignatureScript  string
	Witness          []hexutil.Bytes
	Sequence         uint32
	Value            btcutil.Amount
}

EncTxIn struct

type EncTxOut

type EncTxOut struct {
	PkScript string
	Value    int64
}

EncTxOut struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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