Documentation ¶
Index ¶
- Variables
- func DecodeWIF(wif string) (*btcutil.WIF, error)
- func EstimateFeePerKb(url string, blocks int) (fee int64, err error)
- func GetBindAddressFromMemoScipt(memoScript string) (bind string, toChainID string, ok bool)
- func GetLatestBlockNumber(url string) (result uint64, err error)
- func GetP2shBindAddress(p2shAddress string) (bindAddress string)
- func GetStubChainID(network string) *big.Int
- func PostTransaction(url, txHex string) (txHash string, err error)
- func SupportsChainID(chainID *big.Int) bool
- type Bridge
- func (b *Bridge) BroadcastTxCommit(txHex string) (txHash string, err error)
- func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
- func (b *Bridge) CalcSignatureHash(sigScript []byte, tx *wire.MsgTx, i int) (sigHash []byte, err error)
- func (b *Bridge) DcrmSignMsgHash(msgHash []string, args *tokens.BuildTxArgs) (rsv []string, err error)
- func (b *Bridge) DcrmSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) DecodeAddress(addr string) (address btcutil.Address, err error)
- func (b *Bridge) EstimateFeePerKb(blocks int) (result int64, err error)
- func (b *Bridge) FindUtxos(addr string) (result []*ElectUtxo, err error)
- func (b *Bridge) GetChainParams(chainID *big.Int) *chaincfg.Params
- func (b *Bridge) GetCompressedPublicKey(fromPublicKey string, needVerify bool) (cPkData []byte, err error)
- func (b *Bridge) GetElectTransactionStatus(txHash string) (result *ElectTxStatus, err error)
- func (b *Bridge) GetLatestBlockNumber() (result uint64, err error)
- func (b *Bridge) GetLatestBlockNumberOf(apiAddress string) (uint64, error)
- func (b *Bridge) GetP2shAddress(bindAddr string) (p2shAddress string, redeemScript []byte, err error)
- func (b *Bridge) GetP2shAddressByRedeemScript(redeemScript []byte) (string, error)
- func (b *Bridge) GetP2shRedeemScript(memo, pubKeyHash []byte) (redeemScript []byte, err error)
- func (b *Bridge) GetP2shSigScript(redeemScript []byte) ([]byte, error)
- func (b *Bridge) GetPayToAddrScript(address string) ([]byte, error)
- func (b *Bridge) GetPublicKeyFromECDSA(privKey *ecdsa.PrivateKey, compressed bool) []byte
- func (b *Bridge) GetReceivedValue(vout []*ElectTxOut, receiver, pubkeyType string) (value uint64, memoScript string, rightReceiver bool)
- func (b *Bridge) GetSigScript(sigScripts [][]byte, prevScript, signData, cPkData []byte, i int) (sigScript []byte, err error)
- func (b *Bridge) GetTransaction(txHash string) (tx interface{}, err error)
- func (b *Bridge) GetTransactionByHash(txHash string) (result *ElectTx, err error)
- func (b *Bridge) GetTransactionStatus(txHash string) (status *tokens.TxStatus, err error)
- func (b *Bridge) InitAfterConfig()
- func (b *Bridge) InitRouterInfo(routerContract, routerVersion string) (err error)
- func (b *Bridge) IsPayToScriptHash(sigScript []byte) bool
- func (b *Bridge) IsValidAddress(address string) bool
- func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) MakeSignedTransaction(authoredTx *txauthor.AuthoredTx, msgHash, rsv []string, sigScripts [][]byte, ...) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) NewAddressPubKeyHash(pkData []byte) (*btcutil.AddressPubKeyHash, error)
- func (b *Bridge) NewAddressScriptHash(redeemScript []byte) (*btcutil.AddressScriptHash, error)
- func (b *Bridge) NewTxIn(txid string, vout uint32, pkScript []byte) (*wire.TxIn, error)
- func (b *Bridge) NewTxOut(amount int64, pkScript []byte) *wire.TxOut
- func (b *Bridge) NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb btcutil.Amount, ...) (*txauthor.AuthoredTx, error)
- func (b *Bridge) NullDataScript(memo string) ([]byte, error)
- func (b *Bridge) ParsePkScript(pkScript []byte) (txscript.PkScript, error)
- func (b *Bridge) PublicKeyToAddress(pubKey string) (string, error)
- func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
- func (b *Bridge) SendTransaction(signedTx interface{}) (txHash string, err error)
- func (b *Bridge) SerializePublicKey(ecPub *ecdsa.PublicKey, compressed bool) []byte
- func (b *Bridge) SerializeSignature(r, s *big.Int) []byte
- func (b *Bridge) SetTokenConfig(tokenAddr string, tokenCfg *tokens.TokenConfig)
- func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, wifPrivKey string) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) SignWithECDSA(privKey *ecdsa.PrivateKey, msgHash []byte) (rsv string, err error)
- func (b *Bridge) ToCompressedPublicKey(pkData []byte) ([]byte, error)
- func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHashes []string) (err error)
- func (b *Bridge) VerifyPubKey(address, pubKey string) error
- func (b *Bridge) VerifyRedeemScript(prevScript, redeemScript []byte) error
- func (b *Bridge) VerifyTokenConfig(tokenCfg *tokens.TokenConfig) error
- func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
- type ElectBlock
- type ElectOutspend
- type ElectTx
- type ElectTxOut
- type ElectTxStatus
- type ElectTxin
- type ElectUtxo
- type SortableElectUtxoSlice
Constants ¶
This section is empty.
Variables ¶
var (
UnlockMemoPrefix = "SWAPTX:"
)
Functions ¶
func GetBindAddressFromMemoScipt ¶
GetBindAddressFromMemoScipt get bind address
func GetLatestBlockNumber ¶
func GetP2shBindAddress ¶
GetP2shBindAddress get p2sh bind address
func PostTransaction ¶
PostTransaction call post to /tx
Types ¶
type Bridge ¶
type Bridge struct {
*tokens.CrossChainBridgeBase
}
Bridge near bridge
func (*Bridge) BroadcastTxCommit ¶
PostTransaction impl
func (*Bridge) BuildRawTransaction ¶
func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
BuildRawTransaction build raw tx
func (*Bridge) CalcSignatureHash ¶
func (b *Bridge) CalcSignatureHash(sigScript []byte, tx *wire.MsgTx, i int) (sigHash []byte, err error)
CalcSignatureHash calc sig hash
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) DecodeAddress ¶
DecodeAddress decode address
func (*Bridge) EstimateFeePerKb ¶
EstimateFeePerKb impl
func (*Bridge) GetChainParams ¶
GetChainParams 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) (result *ElectTxStatus, err error)
GetElectTransactionStatus impl
func (*Bridge) GetLatestBlockNumber ¶
GetLatestBlockNumber gets latest block number
func (*Bridge) GetLatestBlockNumberOf ¶
GetLatestBlockNumberOf gets latest block number from single api
func (*Bridge) GetP2shAddress ¶
func (*Bridge) GetP2shAddressByRedeemScript ¶
GetP2shAddressByRedeemScript get p2sh address by redeem script
func (*Bridge) GetP2shRedeemScript ¶
func (*Bridge) GetP2shSigScript ¶
GetP2shSigScript get p2sh signature script
func (*Bridge) GetPayToAddrScript ¶
GetPayToAddrScript get pay to address script
func (*Bridge) GetPublicKeyFromECDSA ¶
func (b *Bridge) GetPublicKeyFromECDSA(privKey *ecdsa.PrivateKey, compressed bool) []byte
GetPublicKeyFromECDSA get public key from ecdsa private key
func (*Bridge) GetReceivedValue ¶
func (*Bridge) GetSigScript ¶
func (b *Bridge) GetSigScript(sigScripts [][]byte, prevScript, signData, cPkData []byte, i int) (sigScript []byte, err error)
GetSigScript get script
func (*Bridge) GetTransaction ¶
GetTransaction impl
func (*Bridge) GetTransactionByHash ¶
GetTransactionByHash get tx response by hash
func (*Bridge) GetTransactionStatus ¶
GetTransactionStatus impl
func (*Bridge) InitAfterConfig ¶
func (b *Bridge) InitAfterConfig()
InitAfterConfig init variables (ie. extra members) after loading config
func (*Bridge) InitRouterInfo ¶
InitRouterInfo init router info
func (*Bridge) IsPayToScriptHash ¶
IsPayToScriptHash is p2sh
func (*Bridge) IsValidAddress ¶
IsValidAddress check address
func (*Bridge) MPCSignTransaction ¶
func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)
MPCSignTransaction mpc sign raw tx
func (*Bridge) MakeSignedTransaction ¶
func (b *Bridge) MakeSignedTransaction(authoredTx *txauthor.AuthoredTx, msgHash, rsv []string, sigScripts [][]byte, cPkData []byte) (signedTx interface{}, txHash string, err error)
MakeSignedTransaction make signed tx
func (*Bridge) NewAddressPubKeyHash ¶
func (b *Bridge) NewAddressPubKeyHash(pkData []byte) (*btcutil.AddressPubKeyHash, error)
NewAddressPubKeyHash encap
func (*Bridge) NewAddressScriptHash ¶
func (b *Bridge) NewAddressScriptHash(redeemScript []byte) (*btcutil.AddressScriptHash, error)
NewAddressScriptHash encap
func (*Bridge) NewUnsignedTransaction ¶
func (b *Bridge) NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb btcutil.Amount, fetchInputs txauthor.InputSource, fetchChange txauthor.ChangeSource) (*txauthor.AuthoredTx, error)
func (*Bridge) NullDataScript ¶
NullDataScript encap
func (*Bridge) ParsePkScript ¶
ParsePkScript parse pkScript
func (*Bridge) PublicKeyToAddress ¶
PublicKeyToAddress impl
func (*Bridge) RegisterSwap ¶
func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
RegisterSwap api
func (*Bridge) SendTransaction ¶
SendTransaction send signed tx
func (*Bridge) SerializePublicKey ¶
SerializePublicKey serialize ecdsa public key
func (*Bridge) SetTokenConfig ¶
func (b *Bridge) SetTokenConfig(tokenAddr string, tokenCfg *tokens.TokenConfig)
SetTokenConfig set and verify token config
func (*Bridge) SignTransactionWithPrivateKey ¶
func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, wifPrivKey string) (signedTx interface{}, txHash string, err error)
SignTransactionWithPrivateKey sign tx with ECDSA private key string
func (*Bridge) SignWithECDSA ¶
SignWithECDSA sign with ecdsa private key
func (*Bridge) ToCompressedPublicKey ¶
ToCompressedPublicKey convert to compressed public key if not
func (*Bridge) VerifyMsgHash ¶
VerifyMsgHash verify msg hash
func (*Bridge) VerifyPubKey ¶
todo: read from config
func (*Bridge) VerifyRedeemScript ¶
VerifyRedeemScript verify redeem script
func (*Bridge) VerifyTokenConfig ¶
func (b *Bridge) VerifyTokenConfig(tokenCfg *tokens.TokenConfig) error
VerifyTokenConfig verify token config
func (*Bridge) VerifyTransaction ¶
func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
VerifyTransaction impl
type ElectBlock ¶
type ElectBlock struct { Hash *string `json:"id"` Height *uint32 `json:"height"` Version *uint32 `json:"version"` Timestamp *uint32 `json:"timestamp"` TxCount *uint32 `json:"tx_count"` Size *uint32 `json:"size"` Weight *uint32 `json:"weight"` MerkleRoot *string `json:"merkle_root"` PreviousHash *string `json:"previousblockhash"` Nonce *uint32 `json:"nonce"` Bits *uint32 `json:"bits"` Difficulty *uint64 `json:"difficulty"` }
ElectBlock struct
type ElectOutspend ¶
type ElectOutspend struct { Spent *bool `json:"spent"` Txid *string `json:"txid"` Vin *uint32 `json:"vin"` Status *ElectTxStatus `json:"status,omitempty"` }
ElectOutspend struct
func (*ElectOutspend) String ¶
func (outspend *ElectOutspend) String() string
type ElectTx ¶
type ElectTx struct { Txid *string `json:"txid"` Version *uint32 `json:"version"` Locktime *uint32 `json:"locktime"` Size *uint32 `json:"size"` Weight *uint32 `json:"weight"` Fee *uint64 `json:"fee"` Vin []*ElectTxin `json:"vin"` Vout []*ElectTxOut `json:"vout"` Status *ElectTxStatus `json:"status,omitempty"` }
ElectTx struct
func GetTransactionByHash ¶
GetTransactionByHash get tx by hash
type ElectTxOut ¶
type ElectTxOut struct { Scriptpubkey *string `json:"scriptpubkey"` ScriptpubkeyAsm *string `json:"scriptpubkey_asm"` ScriptpubkeyType *string `json:"scriptpubkey_type"` ScriptpubkeyAddress *string `json:"scriptpubkey_address"` Value *uint64 `json:"value"` }
ElectTxOut struct
type ElectTxStatus ¶
type ElectTxStatus struct { Confirmed *bool `json:"confirmed"` BlockHeight *uint64 `json:"block_height"` BlockHash *string `json:"block_hash"` BlockTime *uint64 `json:"block_time"` }
ElectTxStatus struct
func GetElectTransactionStatus ¶
func GetElectTransactionStatus(url, txHash string) (result *ElectTxStatus, err error)
GetElectTransactionStatus call /tx/{txHash}/status
func (*ElectTxStatus) String ¶
func (status *ElectTxStatus) String() string
type ElectTxin ¶
type ElectTxin struct { Txid *string `json:"txid"` Vout *uint32 `json:"vout"` Scriptsig *string `json:"scriptsig"` ScriptsigAsm *string `json:"scriptsig_asm"` IsCoinbase *bool `json:"is_coinbase"` Sequence *uint32 `json:"sequence"` InnerRedeemscriptAsm *string `json:"inner_redeemscript_asm"` Prevout *ElectTxOut `json:"prevout"` }
ElectTxin struct
type ElectUtxo ¶
type ElectUtxo struct { Txid *string `json:"txid"` Vout *uint32 `json:"vout"` Value *uint64 `json:"value"` Status *ElectTxStatus `json:"status"` }
ElectUtxo struct
type SortableElectUtxoSlice ¶
type SortableElectUtxoSlice []*ElectUtxo
SortableElectUtxoSlice sortable
func (SortableElectUtxoSlice) Less ¶
func (s SortableElectUtxoSlice) Less(i, j int) bool
Less impl Sortable sort utxos 1. confirmed fisrt 2. value first
func (SortableElectUtxoSlice) Swap ¶
func (s SortableElectUtxoSlice) Swap(i, j int)
Swap impl Sortable