Documentation ¶
Index ¶
- Constants
- Variables
- func ChainParams(chain string) *chaincfg.Params
- func GenerateMerkleProof(txs []*btcutil.Tx, hn *chainhash.Hash) []string
- func VerifyMerkleProof(proofs []string, hn, root *chainhash.Hash) bool
- type Bitcoin
- type Config
- type ConfigBuilder
- type EncodingConfig
- type Global
- type Side
- type State
- func (a *State) Close()
- func (a *State) FastSyncLightClient()
- func (a *State) GetChainCfg() *chaincfg.Params
- func (a *State) Init() error
- func (a *State) InitLogger(configLogLevel string) error
- func (a *State) InitRPC() error
- func (a *State) OnNewBtcBlock(c []string)
- func (a *State) QueryAndCheckLightClientPermission() (*btclightclient.QueryParamsResponse, error)
- func (a *State) QueryChainTip() (*btclightclient.QueryChainTipResponse, error)
- func (a *State) QuerySequence() (uint64, error)
- func (a *State) ScanVaultTx(current int32) error
- func (a *State) SendSideTx(msg sdk.Msg) error
- func (a *State) SendSubmitBlockHeaderRequest(headers []*btcbridge.BlockHeader) error
- func (a *State) SignWithdrawalTxns()
- func (a *State) SubmitBlock(blocks []*btcjson.GetBlockHeaderVerboseResult)
- func (a *State) SubmitDepositTx(blockhash *chainhash.Hash, tx *btcutil.Tx, txs []*btcutil.Tx) error
- func (a *State) SubmitWithdrawalTx(blockhash *chainhash.Hash, tx *btcutil.Tx, txs []*btcutil.Tx) error
- func (a *State) SyncWithdrawalTxns()
Constants ¶
const ( AppName = "shuttler" InternalKeyringName = "side" )
const (
DefaultTimeout = 15 * time.Second
)
Variables ¶
var ( DefaultHome = filepath.Join(os.Getenv("HOME"), ".shuttler") CA_FILE = "rpc.cert" DefaultConfigFilePath = DefaultHome + "/config.toml" )
Functions ¶
func ChainParams ¶
func GenerateMerkleProof ¶
Function to generate a Merkle proof
Types ¶
type Bitcoin ¶
type Bitcoin struct { Chain string `` /* 163-byte string literal not displayed */ // Bitcoin specific configuration RPC string `toml:"rpc" comment:"Bitcoin RPC endpoint"` RPCUser string `toml:"rpcuser" comment:"Bitcoin RPC user"` RPCPassword string `toml:"rpcpassword" comment:"Bitcoin RPC password"` Protocol string `toml:"protocol" comment:"Bitcoin RPC protocol"` ZMQHost string `toml:"zmqhost" comment:"Bitcoin ZMQ host"` ZMQPort int `toml:"zmqport" comment:"Bitcoin ZMQ port"` VaultAddress string `toml:"vault-address" comment:"Vault address for the transaction"` VaultSigner bool `toml:"vault-signer" comment:"Enable vault signer to sign the transaction, only used for testing"` }
type ConfigBuilder ¶
type ConfigBuilder struct {
// contains filtered or unexported fields
}
func NewConfigBuilder ¶
func NewConfigBuilder(homePath string) *ConfigBuilder
func (*ConfigBuilder) ConfigFilePath ¶
func (c *ConfigBuilder) ConfigFilePath() string
func (*ConfigBuilder) InitConfig ¶
func (c *ConfigBuilder) InitConfig(m, network string) *Config
func (*ConfigBuilder) LoadConfigFile ¶
func (c *ConfigBuilder) LoadConfigFile() *Config
type EncodingConfig ¶
type EncodingConfig struct { InterfaceRegistry types.InterfaceRegistry Codec codec.Codec TxConfig client.TxConfig Amino *codec.LegacyAmino }
func MakeEncodingConfig ¶
func MakeEncodingConfig() EncodingConfig
type Global ¶
type Global struct {
LogLevel string `toml:"log-level" comment:"log level of the daemon"`
}
type Side ¶
type Side struct { // Side specific configuration GRPC string `toml:"grpc" comment:"Side gRPC endpoint"` RPC string `toml:"rpc" comment:"Side RPC endpoint"` REST string `toml:"rest" comment:"Side REST endpoint"` Frequency int `toml:"frequency" comment:"frequency of Side block polling in seconds"` Sender string `toml:"sender" comment:"Side sender address"` ChainID string `toml:"chain-id" comment:"Side chain ID"` Gas uint64 `toml:"gas" comment:"Side chain gas"` }
type State ¶
type State struct { // General application state // Log is the root logger of the application. // Consumers are expected to store and use local copies of the logger // after modifying with the .With method. Log *zap.Logger Viper *viper.Viper HomePath string Debug bool Config *Config // contains filtered or unexported fields }
AppState is the modifiable state of the application. App connects both the bitcoin and cosmos network Connect to the bitcoin network via RPC; txindex, zmq must be enabled Connect to the cosmos network via gRPC
func (*State) FastSyncLightClient ¶
func (a *State) FastSyncLightClient()
Sync the light client with the bitcoin network
func (*State) GetChainCfg ¶
Return current chaincfg based on the configuration
func (*State) Init ¶
Initialize the application state This function is called by the root command before executing any subcommands. and should not be called for `init` and `version` commands.
func (*State) InitLogger ¶
func (*State) OnNewBtcBlock ¶
func (*State) QueryAndCheckLightClientPermission ¶
func (a *State) QueryAndCheckLightClientPermission() (*btclightclient.QueryParamsResponse, error)
Query Parameters of Light Client
func (*State) QueryChainTip ¶
func (a *State) QueryChainTip() (*btclightclient.QueryChainTipResponse, error)
Query Light Client Chain Tip
func (*State) QuerySequence ¶
Query Sequence of Side Account
func (*State) ScanVaultTx ¶
Scan the transanctions in the block Check if the transaction is a deposit/withdraw transaction If it is, submit the transaction to the sidechain This block should be confirmed
func (*State) SendSideTx ¶
SendTx sends a transaction to the sidechain
func (*State) SendSubmitBlockHeaderRequest ¶
func (a *State) SendSubmitBlockHeaderRequest(headers []*btcbridge.BlockHeader) error
Send Submit Block Header Request
func (*State) SignWithdrawalTxns ¶
func (a *State) SignWithdrawalTxns()
SignWithdrawalTxns signs the withdrawal transactions
func (*State) SubmitBlock ¶
func (a *State) SubmitBlock(blocks []*btcjson.GetBlockHeaderVerboseResult)
func (*State) SubmitDepositTx ¶
Submit Deposit Transaction to Sidechain
func (*State) SubmitWithdrawalTx ¶
func (a *State) SubmitWithdrawalTx(blockhash *chainhash.Hash, tx *btcutil.Tx, txs []*btcutil.Tx) error
Submit Withdrawal Transaction to Sidechain to close the withdrawal and burn the tokens
func (*State) SyncWithdrawalTxns ¶
func (a *State) SyncWithdrawalTxns()
SyncWithdrawalTxns sends the withdrawal transactions to the bitcoin network