Exemple #1
0
        public NeoInterop(TokenSwapper swapper, string wif, BigInteger blockHeight, NeoScanAPI neoscanAPI, Logger logger) : base(swapper, wif, "neo")
        {
            this._blockHeight = blockHeight;

            this.neoscanAPI = neoscanAPI;

            this.logger = logger;
        }
Exemple #2
0
        public static void Balance(NexusAPI api, int phantasmaRestPort, NeoScanAPI neoScanAPI, string[] args)
        {
            if (phantasmaRestPort <= 0)
            {
                throw new CommandException("Please enable REST API on this node to use this feature");
            }

            Address address;

            if (args.Length == 1)
            {
                address = Address.FromText(args[0]);
            }
            else
            {
                address = Keys.Address;
            }

            logger.Message("Fetching balances...");
            var wallets = new List <CryptoWallet>();

            wallets.Add(new PhantasmaWallet(Keys, $"http://*****:*****@ {entry.Chain}");
                        }
                        if (empty)
                        {
                            logger.Message("Empty wallet.");
                        }
                    }
                    else
                    {
                        logger.Message("Failed to fetch balances!");
                    }
                });
            }
        }
Exemple #3
0
        private void SetupOracleApis()
        {
            var neoPlatform = Settings.Oracle.SwapPlatforms.FirstOrDefault(x => x.Chain == SwapPlatformChain.Neo);

            if (neoPlatform != null && neoPlatform.Enabled)
            {
                var neoScanURL = Settings.Oracle.NeoscanUrl;

                this._neoAPI = new Neo.Core.RemoteRPCNode(neoScanURL, neoPlatform.RpcNodes);
                this._neoAPI.SetLogger((s) => Logger.Message(s));

                this._neoScanAPI = new NeoScanAPI(neoScanURL, Logger, _nexus, _nodeKeys);
            }

            var bscPlatform = Settings.Oracle.SwapPlatforms.FirstOrDefault(x => x.Chain == SwapPlatformChain.BSC);

            if (bscPlatform != null && bscPlatform.Enabled)
            {
                var bscWIF  = Settings.GetInteropWif(Nexus, _nodeKeys, BSCWallet.BSCPlatform);
                var bscKeys = PhantasmaKeys.FromWIF(bscWIF);

                this._bscAPI = new EthAPI(SwapPlatformChain.BSC, this.Nexus, this.Settings, new EthAccount(bscKeys.PrivateKey.ToHex()), Logger);
            }

            var ethPlatform = Settings.Oracle.SwapPlatforms.FirstOrDefault(x => x.Chain == SwapPlatformChain.Ethereum);

            if (ethPlatform != null && ethPlatform.Enabled)
            {
                var ethWIF  = Settings.GetInteropWif(Nexus, _nodeKeys, EthereumWallet.EthereumPlatform);
                var ethKeys = PhantasmaKeys.FromWIF(ethWIF);

                this._ethAPI = new EthAPI(SwapPlatformChain.Ethereum, this.Nexus, this.Settings, new EthAccount(ethKeys.PrivateKey.ToHex()), Logger);
            }

            this._cryptoCompareAPIKey = Settings.Oracle.CryptoCompareAPIKey;
            if (!string.IsNullOrEmpty(this._cryptoCompareAPIKey))
            {
                Logger.Message($"CryptoCompare API enabled.");
            }
            else
            {
                throw new Exception($"CryptoCompare API key missing, oracles won't work properly and oracles are no longer optional...");
            }
        }
Exemple #4
0
        private void SetupOracleApis()
        {
            var neoScanURL = Settings.Oracle.NeoscanUrl;

            var neoRpcList = Settings.Oracle.NeoRpcNodes;

            this._neoAPI = new Neo.Core.RemoteRPCNode(neoScanURL, neoRpcList.ToArray());
            this._neoAPI.SetLogger((s) => Logger.Message(s));

            var ethRpcList = Settings.Oracle.EthRpcNodes;

            var ethWIF  = Settings.GetInteropWif(Nexus, _nodeKeys, EthereumWallet.EthereumPlatform);
            var ethKeys = PhantasmaKeys.FromWIF(ethWIF);

            this._ethAPI = new EthAPI(this.Nexus, this.Settings, new EthAccount(ethKeys.PrivateKey.ToHex()), Logger);

            this._neoScanAPI = new NeoScanAPI(neoScanURL, Logger, _nexus, _nodeKeys);

            this._cryptoCompareAPIKey = Settings.Oracle.CryptoCompareAPIKey;
            if (!string.IsNullOrEmpty(this._cryptoCompareAPIKey))
            {
                Logger.Message($"CryptoCompare API enabled...");
            }
        }
        public TokenSwapper(PhantasmaKeys swapKey, NexusAPI nexusAPI, NeoScanAPI neoscanAPI, NeoAPI neoAPI, BigInteger minFee, Logger logger, Arguments arguments)
        {
            this.SwapKeys   = swapKey;
            this.NexusAPI   = nexusAPI;
            this.MinimumFee = minFee;

            this.neoAPI     = neoAPI;
            this.neoscanAPI = neoscanAPI;
            this.logger     = logger;

            this.Storage = new KeyStoreStorage(Nexus.CreateKeyStoreAdapter("swaps"));

            this.interopBlocks = new Dictionary <string, BigInteger>();

            interopBlocks["phantasma"] = BigInteger.Parse(arguments.GetString("interop.phantasma.height", "0"));
            interopBlocks["neo"]       = BigInteger.Parse(arguments.GetString("interop.neo.height", "4261049"));
            //interopBlocks["ethereum"] = BigInteger.Parse(arguments.GetString("interop.ethereum.height", "4261049"));

            InitWIF("neo", arguments);

            /*
             * foreach (var entry in interopBlocks)
             * {
             *  BigInteger blockHeight = entry.Value;
             *
             *  ChainInterop interop;
             *
             *  switch (entry.Key)
             *  {
             *      case "phantasma":
             *          interop = new PhantasmaInterop(this, swapKey, blockHeight, nexusAPI);
             *          break;
             *
             *      case "neo":
             *          interop = new NeoInterop(this, swapKey, blockHeight, neoAPI, neoscanAPI);
             *          break;
             *
             *      case "ethereum":
             *          interop = new EthereumInterop(this, swapKey, blockHeight);
             *          break;
             *
             *      default:
             *          interop = null;
             *          break;
             *  }
             *
             *  if (interop != null)
             *  {
             *      bool shouldAdd = true;
             *
             *      if (!(interop is PhantasmaInterop))
             *      {
             *          logger.Message($"{interop.Name}.Swap.Private: {interop.PrivateKey}");
             *          logger.Message($"{interop.Name}.Swap.{interop.Name}: {interop.LocalAddress}");
             *          logger.Message($"{interop.Name}.Swap.Phantasma: {interop.ExternalAddress}");
             *
             *          for (int i = 0; i < platforms.Length; i++)
             *          {
             *              var temp = platforms[i];
             *              if (temp.platform == interop.Name)
             *              {
             *                  if (temp.address != interop.LocalAddress)
             *                  {
             *                      logger.Error($"{interop.Name} address mismatch, should be {temp.address}. Make sure you are using the proper swap seed.");
             *                      shouldAdd = false;
             *                  }
             *              }
             *          }
             *      }
             *
             *      if (shouldAdd)
             *      {
             *          AddInterop(interop);
             *      }
             *  }
             * }*/
        }