app

package
v0.1.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName             = "shuttler"
	InternalKeyringName = "side"
)
View Source
const (
	DefaultTimeout = 15 * time.Second
)

Variables

View Source
var (
	DefaultHome           = filepath.Join(os.Getenv("HOME"), ".shuttler")
	CA_FILE               = "rpc.cert"
	DefaultConfigFilePath = DefaultHome + "/config.toml"
)

Functions

func ChainParams

func ChainParams(chain string) *chaincfg.Params

func GenerateMerkleProof

func GenerateMerkleProof(txs []*btcutil.Tx, hn *chainhash.Hash) []string

Function to generate a Merkle proof

func VerifyMerkleProof

func VerifyMerkleProof(proofs []string, hn, root *chainhash.Hash) bool

VerifyMerkleProof verifies 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 Config

type Config struct {
	Global      Global  `toml:"global"`
	Bitcoin     Bitcoin `toml:"bitcoin"`
	Side        Side    `toml:"side"`
	FromAddress string  `toml:"from-address" comment:"from address for the transaction"`
}

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 NewAppState

func NewAppState(home string) *State

NewState creates a new State object.

func (*State) Close

func (a *State) Close()

Close the application state

func (*State) FastSyncLightClient

func (a *State) FastSyncLightClient()

Sync the light client with the bitcoin network

func (*State) GetChainCfg

func (a *State) GetChainCfg() *chaincfg.Params

Return current chaincfg based on the configuration

func (*State) Init

func (a *State) Init() error

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 (a *State) InitLogger(configLogLevel string) error

func (*State) InitRPC

func (a *State) InitRPC() error

func (*State) OnNewBtcBlock

func (a *State) OnNewBtcBlock(c []string)

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

func (a *State) QuerySequence() (uint64, error)

Query Sequence of Side Account

func (*State) ScanVaultTx

func (a *State) ScanVaultTx(current int32) error

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

func (a *State) SendSideTx(msg sdk.Msg) error

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

func (a *State) SubmitDepositTx(blockhash *chainhash.Hash, tx *btcutil.Tx, txs []*btcutil.Tx) error

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

Jump to

Keyboard shortcuts

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