Documentation ¶
Index ¶
- Variables
- func AuthoredTxToString(authtx interface{}, pretty bool) string
- func DecodeWIF(wif string) (*ltcutil.WIF, error)
- func GetBindAddressFromMemoScipt(memoScript string) (bind string, ok bool)
- func Init(btcExtra *tokens.BtcExtraConfig)
- func MarshalToJSON(obj interface{}, pretty bool) string
- type Bridge
- func (b *Bridge) AggregateUtxos(addrs []string, utxos []*electrs.ElectUtxo) (string, error)
- func (b *Bridge) BuildAggregateTransaction(relayFeePerKb int64, addrs []string, utxos []*electrs.ElectUtxo) (rawTx *txauthor.AuthoredTx, err error)
- func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
- func (b *Bridge) BuildTransaction(from string, receivers []string, amounts []int64, memo string, ...) (rawTx interface{}, err error)
- func (b *Bridge) CalcSignatureHash(sigScript []byte, tx *wire.MsgTx, i int) (sigHash []byte, err error)
- func (b *Bridge) CheckSwapinTxType(tx *electrs.ElectTx) (p2shBindAddrs []string, err error)
- func (b *Bridge) ConvertBTCAddress(addr, btcNet string) (address ltcutil.Address, err error)
- func (b *Bridge) ConvertLTCAddress(addr, net string) (address btcutil.Address, 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 ltcutil.Address, err error)
- func (b *Bridge) EstimateFeePerKb(blocks int) (int64, error)
- func (b *Bridge) FindUtxos(addr string) ([]*electrs.ElectUtxo, error)
- func (b *Bridge) GetBalance(account string) (*big.Int, error)
- func (b *Bridge) GetBlock(blockHash string) (*electrs.ElectBlock, error)
- func (b *Bridge) GetBlockHash(height uint64) (string, error)
- func (b *Bridge) GetBlockTransactions(blockHash string, startIndex uint32) ([]*electrs.ElectTx, error)
- func (b *Bridge) GetBlockTxids(blockHash string) ([]string, error)
- func (b *Bridge) GetChainParams() *chaincfg.Params
- func (b *Bridge) GetCompressedPublicKey(fromPublicKey string, needVerify bool) (cPkData []byte, err error)
- func (b *Bridge) GetElectTransactionStatus(txHash string) (*electrs.ElectTxStatus, error)
- func (b *Bridge) GetLatestBlockNumber() (uint64, error)
- func (b *Bridge) GetLatestBlockNumberOf(apiAddress string) (uint64, error)
- func (b *Bridge) GetOutspend(txHash string, vout uint32) (*electrs.ElectOutspend, 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) GetPoolTransactions(addr string) ([]*electrs.ElectTx, error)
- func (b *Bridge) GetPoolTxidList() ([]string, error)
- func (b *Bridge) GetPublicKeyFromECDSA(privKey *ecdsa.PrivateKey, compressed bool) []byte
- func (b *Bridge) GetReceivedValue(vout []*electrs.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) GetTokenBalance(tokenType, tokenAddress, accountAddress string) (*big.Int, error)
- func (b *Bridge) GetTokenSupply(tokenType, tokenAddress string) (*big.Int, error)
- func (b *Bridge) GetTransaction(txHash string) (interface{}, error)
- func (b *Bridge) GetTransactionByHash(txHash string) (*electrs.ElectTx, error)
- func (b *Bridge) GetTransactionHistory(addr, lastSeenTxid string) ([]*electrs.ElectTx, error)
- func (b *Bridge) GetTransactionStatus(txHash string) *tokens.TxStatus
- func (b *Bridge) InitLatestBlockNumber()
- func (b *Bridge) IsP2pkhAddress(addr string) bool
- func (b *Bridge) IsP2shAddress(addr string) bool
- func (b *Bridge) IsPayToScriptHash(sigScript []byte) bool
- func (b *Bridge) IsValidAddress(addr string) bool
- func (b *Bridge) MakeSignedTransaction(authoredTx *txauthor.AuthoredTx, msgHash, rsv []string, sigScripts [][]byte, ...) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) NewAddressPubKeyHash(pkData []byte) (*ltcutil.AddressPubKeyHash, error)
- func (b *Bridge) NewAddressScriptHash(redeemScript []byte) (*ltcutil.AddressScriptHash, error)
- func (b *Bridge) NewMsgTx(inputs []*wire.TxIn, outputs []*wire.TxOut, locktime uint32) *wire.MsgTx
- 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 []*wireTxOutType, relayFeePerKb ltcAmountType, ...) (*txauthor.AuthoredTx, error)
- func (b *Bridge) NullDataScript(memo string) ([]byte, error)
- func (b *Bridge) ParsePkScript(pkScript []byte) (txscript.PkScript, error)
- func (b *Bridge) PostTransaction(txHex string) (txHash string, err 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) SetChainAndGateway(chainCfg *tokens.ChainConfig, gatewayCfg *tokens.GatewayConfig)
- func (b *Bridge) ShouldAggregate(aggUtxoCount int, aggSumVal uint64) bool
- func (b *Bridge) SignTransaction(rawTx interface{}, pairID string) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, privKey *ecdsa.PrivateKey) (signTx interface{}, txHash string, err error)
- func (b *Bridge) SignTransactionWithWIF(rawTx interface{}, wif string) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) SignWithECDSA(privKey *ecdsa.PrivateKey, msgHash []byte) (rsv string, err error)
- func (b *Bridge) StartChainTransactionScanJob()
- func (b *Bridge) StartPoolTransactionScanJob()
- func (b *Bridge) StartSwapHistoryScanJob()
- func (b *Bridge) ToCompressedPublicKey(pkData []byte) ([]byte, error)
- func (b *Bridge) ToLTCTx(tx *belectrs.ElectTx) *belectrs.ElectTx
- func (b *Bridge) ToLTCVout(vout *belectrs.ElectTxOut) *belectrs.ElectTxOut
- func (b *Bridge) VerifyAggregateMsgHash(msgHash []string, args *tokens.BuildTxArgs) error
- func (b *Bridge) VerifyChainConfig()
- func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHash []string) (err error)
- func (b *Bridge) VerifyP2shTransaction(pairID, txHash, bindAddress string, allowUnstable bool) (*tokens.TxSwapInfo, error)
- func (b *Bridge) VerifyRedeemScript(prevScript, redeemScript []byte) error
- func (b *Bridge) VerifyTokenConfig(tokenCfg *tokens.TokenConfig) error
- func (b *Bridge) VerifyTransaction(pairID, txHash string, allowUnstable bool) (*tokens.TxSwapInfo, error)
- type EncAuthoredTx
- type EncMsgTx
- type EncOutPoint
- type EncTxIn
- type EncTxOut
Constants ¶
This section is empty.
Variables ¶
var PairID = "ltc"
PairID unique ltc pair ID
Functions ¶
func AuthoredTxToString ¶
AuthoredTxToString AuthoredTx to string
func GetBindAddressFromMemoScipt ¶
GetBindAddressFromMemoScipt get bind address
func MarshalToJSON ¶
MarshalToJSON marshal to json
Types ¶
type Bridge ¶
type Bridge struct {
*tokens.CrossChainBridgeBase
}
Bridge ltc bridge
func NewCrossChainBridge ¶
NewCrossChainBridge new ltc bridge
func (*Bridge) AggregateUtxos ¶
AggregateUtxos aggregate uxtos
func (*Bridge) BuildAggregateTransaction ¶
func (b *Bridge) BuildAggregateTransaction(relayFeePerKb int64, 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) BuildTransaction ¶
func (b *Bridge) BuildTransaction(from string, receivers []string, amounts []int64, memo string, relayFeePerKb int64) (rawTx interface{}, err error)
BuildTransaction build 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) CheckSwapinTxType ¶
CheckSwapinTxType check swapin type
func (*Bridge) ConvertBTCAddress ¶
ConvertBTCAddress decode btc address and convert to LTC address nolint:gocyclo // keep it
func (*Bridge) ConvertLTCAddress ¶
ConvertLTCAddress decode ltc address and convert to BTC address nolint:gocyclo // keep it
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) GetBalance ¶
GetBalance impl
func (*Bridge) GetBlock ¶
func (b *Bridge) GetBlock(blockHash string) (*electrs.ElectBlock, error)
GetBlock impl
func (*Bridge) GetBlockHash ¶
GetBlockHash impl
func (*Bridge) GetBlockTransactions ¶
func (b *Bridge) GetBlockTransactions(blockHash string, startIndex uint32) ([]*electrs.ElectTx, error)
GetBlockTransactions impl
func (*Bridge) GetBlockTxids ¶
GetBlockTxids 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) (*electrs.ElectTxStatus, error)
GetElectTransactionStatus impl
func (*Bridge) GetLatestBlockNumber ¶
GetLatestBlockNumber impl
func (*Bridge) GetLatestBlockNumberOf ¶
GetLatestBlockNumberOf impl
func (*Bridge) GetOutspend ¶
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 ¶
GetP2shAddressByRedeemScript get p2sh address by redeem script
func (*Bridge) GetP2shRedeemScript ¶
GetP2shRedeemScript get p2sh redeem script
func (*Bridge) GetP2shSigScript ¶
GetP2shSigScript get p2sh signature script
func (*Bridge) GetPayToAddrScript ¶
GetPayToAddrScript get pay to address script
func (*Bridge) GetPoolTransactions ¶
GetPoolTransactions impl
func (*Bridge) GetPoolTxidList ¶
GetPoolTxidList impl
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 (b *Bridge) GetReceivedValue(vout []*electrs.ElectTxOut, receiver, pubkeyType string) (value uint64, memoScript string, rightReceiver bool)
GetReceivedValue get received value
func (*Bridge) GetSigScript ¶
func (b *Bridge) GetSigScript(sigScripts [][]byte, prevScript, signData, cPkData []byte, i int) (sigScript []byte, err error)
GetSigScript get script
func (*Bridge) GetTokenBalance ¶
GetTokenBalance impl
func (*Bridge) GetTokenSupply ¶
GetTokenSupply impl
func (*Bridge) GetTransaction ¶
GetTransaction impl
func (*Bridge) GetTransactionByHash ¶
GetTransactionByHash impl
func (*Bridge) GetTransactionHistory ¶
GetTransactionHistory impl
func (*Bridge) GetTransactionStatus ¶
GetTransactionStatus impl
func (*Bridge) InitLatestBlockNumber ¶
func (b *Bridge) InitLatestBlockNumber()
InitLatestBlockNumber init latest block number
func (*Bridge) IsP2pkhAddress ¶
IsP2pkhAddress check p2pkh addrss
func (*Bridge) IsP2shAddress ¶
IsP2shAddress check p2sh addrss
func (*Bridge) IsPayToScriptHash ¶
IsPayToScriptHash is p2sh
func (*Bridge) IsValidAddress ¶
IsValidAddress check address
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) (*ltcutil.AddressPubKeyHash, error)
NewAddressPubKeyHash encap
func (*Bridge) NewAddressScriptHash ¶
func (b *Bridge) NewAddressScriptHash(redeemScript []byte) (*ltcutil.AddressScriptHash, error)
NewAddressScriptHash encap
func (*Bridge) NewUnsignedTransaction ¶
func (b *Bridge) NewUnsignedTransaction(outputs []*wireTxOutType, relayFeePerKb ltcAmountType, fetchInputs txauthor.InputSource, fetchChange txauthor.ChangeSource, isAggregate bool) (*txauthor.AuthoredTx, error)
NewUnsignedTransaction ref ltcwallet ref. https://github.com/ltcsuite/ltcwallet/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
func (*Bridge) NullDataScript ¶
NullDataScript encap
func (*Bridge) ParsePkScript ¶
ParsePkScript parse pkScript
func (*Bridge) PostTransaction ¶
PostTransaction impl
func (*Bridge) SendTransaction ¶
SendTransaction send signed tx
func (*Bridge) SerializePublicKey ¶
SerializePublicKey serialize ecdsa public key
func (*Bridge) SerializeSignature ¶
SerializeSignature serialize signature
func (*Bridge) SetChainAndGateway ¶
func (b *Bridge) SetChainAndGateway(chainCfg *tokens.ChainConfig, gatewayCfg *tokens.GatewayConfig)
SetChainAndGateway set chain and gateway config
func (*Bridge) ShouldAggregate ¶
ShouldAggregate should aggregate
func (*Bridge) SignTransaction ¶
func (b *Bridge) SignTransaction(rawTx interface{}, pairID string) (signedTx interface{}, txHash string, err error)
SignTransaction sign tx with pairID
func (*Bridge) SignTransactionWithPrivateKey ¶
func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, privKey *ecdsa.PrivateKey) (signTx interface{}, txHash string, err error)
SignTransactionWithPrivateKey sign tx with ECDSA private key
func (*Bridge) SignTransactionWithWIF ¶
func (b *Bridge) SignTransactionWithWIF(rawTx interface{}, wif string) (signedTx interface{}, txHash string, err error)
SignTransactionWithWIF sign tx with WIF
func (*Bridge) SignWithECDSA ¶
SignWithECDSA sign with ecdsa private key
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) ToCompressedPublicKey ¶
ToCompressedPublicKey convert to compressed public key if not
func (*Bridge) ToLTCVout ¶
func (b *Bridge) ToLTCVout(vout *belectrs.ElectTxOut) *belectrs.ElectTxOut
ToLTCVout convert address in ElectTx to LTC format
func (*Bridge) VerifyAggregateMsgHash ¶
func (b *Bridge) VerifyAggregateMsgHash(msgHash []string, args *tokens.BuildTxArgs) error
VerifyAggregateMsgHash verify aggregate msgHash
func (*Bridge) VerifyChainConfig ¶
func (b *Bridge) VerifyChainConfig()
VerifyChainConfig verify chain config
func (*Bridge) VerifyMsgHash ¶
VerifyMsgHash verify msg hash
func (*Bridge) VerifyP2shTransaction ¶
func (b *Bridge) VerifyP2shTransaction(pairID, txHash, bindAddress string, allowUnstable bool) (*tokens.TxSwapInfo, error)
VerifyP2shTransaction verify p2sh tx
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(pairID, txHash string, allowUnstable bool) (*tokens.TxSwapInfo, error)
VerifyTransaction impl
type EncAuthoredTx ¶
EncAuthoredTx stuct
type EncMsgTx ¶
type EncMsgTx struct { Txid string Version int32 TxIn []*EncTxIn TxOut []*EncTxOut LockTime uint32 }
EncMsgTx struct