diff --git a/listener/cmd/app/main.go b/listener/cmd/app/main.go index 71b7d083..3881a4b4 100644 --- a/listener/cmd/app/main.go +++ b/listener/cmd/app/main.go @@ -15,6 +15,7 @@ func main() { cfg := config.LoadConfig() db := initiates.InitDB(cfg.Database) + bitcoinRpc := initiates.InitBitcoinRpc(cfg.Bitcoin) bsquaredRpc := initiates.InitEthereumRpc(cfg.Bsquared) arbitrumRpc := initiates.InitEthereumRpc(cfg.Arbitrum) @@ -24,25 +25,22 @@ func main() { arbitrumBuilder := builder.NewBuilder(cfg.Builder.Arbitrum, cfg.Log, cfg.Arbitrum, db, arbitrumRpc) arbitrumBuilder.Start() + // listener //bsquaredRpc := initiates.InitEthereumRpc(cfg.Bsquared) bsquaredListener := ethereum.NewListener(cfg.Log, cfg.Bsquared, bsquaredRpc, db) bsquaredListener.Start() - //arbitrumRpc := initiates.InitEthereumRpc(cfg.Arbitrum) arbitrumListener := ethereum.NewListener(cfg.Log, cfg.Arbitrum, arbitrumRpc, db) arbitrumListener.Start() - bitcoinRpc := initiates.InitBitcoinRpc(cfg.Bitcoin) bitcoinListener := bitcoin.NewListener(cfg.Log, cfg.Bitcoin, cfg.Particle, bitcoinRpc, db) bitcoinListener.Start() - // validator - //bsquaredRpc := initiates.InitEthereumRpc(cfg.Bsquared) + // validator bsquaredValidator := validator.NewValidator(cfg.Validator.Bsquared, cfg.Log, cfg.Bsquared, db, bsquaredRpc) bsquaredValidator.Start() - //arbitrumRpc := initiates.InitEthereumRpc(cfg.Arbitrum) arbitrumValidator := validator.NewValidator(cfg.Validator.Arbitrum, cfg.Log, cfg.Arbitrum, db, arbitrumRpc) arbitrumValidator.Start() select {} diff --git a/listener/cmd/listener/main.go b/listener/cmd/listener/main.go index 61c72d57..065d6edd 100644 --- a/listener/cmd/listener/main.go +++ b/listener/cmd/listener/main.go @@ -4,6 +4,7 @@ import ( "bsquared.network/b2-message-channel-listener/internal/config" "bsquared.network/b2-message-channel-listener/internal/initiates" "bsquared.network/b2-message-channel-listener/internal/serves/listener/bitcoin" + "bsquared.network/b2-message-channel-listener/internal/serves/listener/ethereum" "encoding/json" "fmt" "github.com/shopspring/decimal" @@ -16,13 +17,13 @@ func main() { fmt.Println(string(value)) db := initiates.InitDB(cfg.Database) - //bsquaredRpc := initiates.InitEthereumRpc(cfg.Bsquared) - //bsquaredListener := ethereum.NewListener(cfg.Log, cfg.Bsquared, bsquaredRpc, db) - //bsquaredListener.Start() - // - //arbitrumRpc := initiates.InitEthereumRpc(cfg.Arbitrum) - //arbitrumListener := ethereum.NewListener(cfg.Log, cfg.Arbitrum, arbitrumRpc, db) - //arbitrumListener.Start() + bsquaredRpc := initiates.InitEthereumRpc(cfg.Bsquared) + bsquaredListener := ethereum.NewListener(cfg.Log, cfg.Bsquared, bsquaredRpc, db) + bsquaredListener.Start() + + arbitrumRpc := initiates.InitEthereumRpc(cfg.Arbitrum) + arbitrumListener := ethereum.NewListener(cfg.Log, cfg.Arbitrum, arbitrumRpc, db) + arbitrumListener.Start() bitcoinRpc := initiates.InitBitcoinRpc(cfg.Bitcoin) bitcoinListener := bitcoin.NewListener(cfg.Log, cfg.Bitcoin, cfg.Particle, bitcoinRpc, db) diff --git a/listener/cmd/test/main.go b/listener/cmd/test/main.go index 71e65be4..1df4a877 100644 --- a/listener/cmd/test/main.go +++ b/listener/cmd/test/main.go @@ -1,36 +1,44 @@ package main import ( - "bsquared.network/b2-message-channel-listener/internal/utils/ethereum/message" - "crypto/ecdsa" + "bsquared.network/b2-message-channel-listener/internal/config" + "bsquared.network/b2-message-channel-listener/internal/initiates" + "encoding/json" "fmt" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "math/big" + "github.com/shopspring/decimal" ) func main() { - - var chainId int64 = 1 - var messageContract string = "0xb4a88c4086055b8f546911BaaED28b7CEE134EF9" - var fromChainId int64 = 0 - fromId := big.NewInt(1) - var fromSender string = common.HexToAddress("0x0").Hex() - var toChainId int64 = 1 - var contractAddress string = "0xbf99D4875C47D07Db5381c5092D669D3A0eBfB72" - var data string = "0xbee471d044748a02b1440b19e0e1b4caaccb14d3c9f6f20ec6c02a90445b34c700000000000000000000000000000000000000000000000000000000000000800000000000000000000000000b0c0149d5dbb9eec2c87cff703eadfe428df89100000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000002a746231716b707464737573786b73636176756473326175646663367036377a7533726c307a6d6e377a7500000000000000000000000000000000000000000000" - var key *ecdsa.PrivateKey - key, err := crypto.ToECDSA(common.FromHex("0x67f20dc3b0842117c049b292dd88794b3321c95a1b607e735be88c34327420ba")) - signer := crypto.PubkeyToAddress(key.PublicKey).Hex() - fmt.Println("signer:", signer) - - signature, err := message.SignMessageSend(chainId, messageContract, fromChainId, fromId, fromSender, toChainId, contractAddress, data, key) - if err != nil { - panic(err) - } - verify, err := message.VerifyMessageSend(chainId, messageContract, fromChainId, fromId, fromSender, toChainId, contractAddress, data, signer, signature) + decimal.DivisionPrecision = 18 + cfg := config.LoadConfig() + bitcoinRpc := initiates.InitBitcoinRpc(cfg.Bitcoin) + info, err := bitcoinRpc.GetBlockChainInfo() if err != nil { panic(err) } - fmt.Println("verify:", verify) + value, _ := json.Marshal(info) + fmt.Println("ChainInfo: ", string(value)) + //return + //var chainId int64 = 1 + //var messageContract string = "0xb4a88c4086055b8f546911BaaED28b7CEE134EF9" + //var fromChainId int64 = 0 + //fromId := big.NewInt(1) + //var fromSender string = common.HexToAddress("0x0").Hex() + //var toChainId int64 = 1 + //var contractAddress string = "0xbf99D4875C47D07Db5381c5092D669D3A0eBfB72" + //var data string = "0xbee471d044748a02b1440b19e0e1b4caaccb14d3c9f6f20ec6c02a90445b34c700000000000000000000000000000000000000000000000000000000000000800000000000000000000000000b0c0149d5dbb9eec2c87cff703eadfe428df89100000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000002a746231716b707464737573786b73636176756473326175646663367036377a7533726c307a6d6e377a7500000000000000000000000000000000000000000000" + //var key *ecdsa.PrivateKey + //key, err := crypto.ToECDSA(common.FromHex("0x67f20dc3b0842117c049b292dd88794b3321c95a1b607e735be88c34327420ba")) + //signer := crypto.PubkeyToAddress(key.PublicKey).Hex() + //fmt.Println("signer:", signer) + // + //signature, err := message.SignMessageSend(chainId, messageContract, fromChainId, fromId, fromSender, toChainId, contractAddress, data, key) + //if err != nil { + // panic(err) + //} + //verify, err := message.VerifyMessageSend(chainId, messageContract, fromChainId, fromId, fromSender, toChainId, contractAddress, data, signer, signature) + //if err != nil { + // panic(err) + //} + //fmt.Println("verify:", verify) } diff --git a/listener/config/config.yaml b/listener/config/config.yaml index e3481328..ca71a03a 100644 --- a/listener/config/config.yaml +++ b/listener/config/config.yaml @@ -37,6 +37,7 @@ bitcoin: ToContractAddress: 0xAaF7f27EA526B29cF4dA3b957Ed0C388070FcCE5 BtcUser: test BtcPass: test + DisableTLS: false bsquared: name: bsquared diff --git a/listener/internal/initiates/rpc.go b/listener/internal/initiates/rpc.go index e7d230a4..ee925262 100644 --- a/listener/internal/initiates/rpc.go +++ b/listener/internal/initiates/rpc.go @@ -20,8 +20,8 @@ func InitBitcoinRpc(config config.Blockchain) *rpcclient.Client { Host: config.RpcUrl, User: config.BtcUser, Pass: config.BtcPass, - HTTPPostMode: true, // Bitcoin core only supports HTTP POST mode - DisableTLS: false, // Bitcoin core does not provide TLS by default + HTTPPostMode: true, // Bitcoin core only supports HTTP POST mode + DisableTLS: config.DisableTLS, // Bitcoin core does not provide TLS by default }, nil) if err != nil { log.Panicf("client dial error: %s\n", err)