/// <summary> /// Constructor /// </summary> public TxFlood() : base() { _rand = new Random(); // This is used for relay directly without enter in our mempool _sendDirectlyType = typeof(LocalNode).GetMembers(BindingFlags.NonPublic) .Where(u => u.Name == "SendDirectly") .Cast <Type>() .FirstOrDefault(); _sendDirectlyField = _sendDirectlyType.GetFields(BindingFlags.Public | BindingFlags.Instance) .Where(u => u.Name == "Inventory") .FirstOrDefault(); // Open wallet Wallet = WalletHelper.OpenWallet(WALLET_FILE, WALLET_PASS); _sources = Wallet.GetAccounts().Skip(1).ToArray(); _destinations = _sources.Skip(1).Concat(_sources.Take(1)).ToArray(); // Warm up Parallel.ForEach(_sources, (a) => a.GetKey()); }
public ActionResult GetTTLBalance(string privateKeyHex) { var wallet = WalletHelper.GetWallet(privateKeyHex); Contract contract = new Contract(CurrentNetwork, privateKeyHex); return(Json(contract.GetTokenBalance())); }
public void TestGetPrivateKeyFromWIFInvalidPrivateKey() { var invalidWif = Crypto.Default.Base58CheckEncode(new byte[] { 127, 33, 68, 4, 111, 111, 43, 161, 201, 123, 240, 182, 240, 48, 97, 165, 233, 223, 133, 20, 106, 12, 245, 240, 46, 69, 25, 1, 34, 115, 30, 37, 224, 1 }); var testee = new WalletHelper(); testee.GetPrivateKeyFromWIF(invalidWif); }
public void TestGetPrivateKeyFromWIF() { var wif = "KxLNhtdXXqaYUW1DKBc1XYQLxhouxXPLgQhR8kk7SYG3ajjR8M8a"; var testee = new WalletHelper(); var result = testee.GetPrivateKeyFromWIF(wif); var expected = new byte[] { 33, 68, 4, 111, 111, 43, 161, 201, 123, 240, 182, 240, 48, 97, 165, 233, 223, 133, 20, 106, 12, 245, 240, 46, 69, 25, 1, 34, 115, 30, 37, 224 }; CollectionAssert.AreEqual(expected, result); }
/// <summary> /// Facilitates the invoking of the Treatail Smart Contract /// </summary> /// <param name="networkType">Network to use</param> /// <param name="contextWallet">Wallet to use for signing context</param> public Contract(NetworkType networkType, string privateKeyHex) { _api = NetworkHelper.GetNeoRPCForType(networkType); _token = new NEP5(_api, _contractScriptHash); if (privateKeyHex != null) { _contextWallet = WalletHelper.GetWallet(privateKeyHex); } }
public bool Create() { var wallet = WalletHelper.CreateWallet(); if (wallet == null || String.IsNullOrEmpty(wallet.Address) || String.IsNullOrEmpty(wallet.PrivateKey)) { return(false); } return(true); }
public async void ArchiveAddress_NullAddress_ArgumentNullException() { await Assert.ThrowsAsync <ArgumentNullException>(async() => { using (BlockchainApiHelper apiHelper = UnitTestUtil.GetFakeHelper()) { WalletHelper walletHelper = this.GetWalletHelper(apiHelper); await walletHelper.ArchiveAddress(null); } }); }
public async void ListAddresses_NegativeConfirmations_ArgumentOutOfRangeException() { await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => { using (BlockchainApiHelper apiHelper = UnitTestUtil.GetFakeHelper()) { WalletHelper walletHelper = this.GetWalletHelper(apiHelper); await walletHelper.ListAddressesAsync(-1); } }); }
public async void SendPayment_SendBtc_NoFreeOutputs() { ServerApiException apiException = await Assert.ThrowsAsync <ServerApiException>(async() => { using (BlockchainApiHelper apiHelper = new BlockchainApiHelper()) { WalletHelper walletHelper = apiHelper.CreateWalletHelper(WalletTests.WALLET_ID, WalletTests.WALLET_PASSWORD, WalletTests.WALLET_PASSWORD2); await walletHelper.SendAsync(WalletTests.FIRST_ADDRESS, BitcoinValue.FromBtc(1)); } }); Assert.Contains("No free", apiException.Message); }
public async void GetAddresses_Valid() { using (BlockchainApiHelper apiHelper = new BlockchainApiHelper()) { WalletHelper walletHelper = apiHelper.CreateWalletHelper(WalletTests.WALLET_ID, WalletTests.WALLET_PASSWORD, WalletTests.WALLET_PASSWORD2); List <Address> addresses = await walletHelper.ListAddressesAsync(); Assert.NotNull(addresses); Assert.NotEmpty(addresses); Assert.True(addresses.Any(a => string.Equals(a.AddressStr, WalletTests.FIRST_ADDRESS))); } }
public async void Unarchive_BadAddress_ServerApiException() { ServerApiException apiException = await Assert.ThrowsAsync <ServerApiException>(async() => { using (BlockchainApiHelper apiHelper = new BlockchainApiHelper()) { WalletHelper walletHelper = apiHelper.CreateWalletHelper(WalletTests.WALLET_ID, WalletTests.WALLET_PASSWORD, WalletTests.WALLET_PASSWORD2); await walletHelper.UnarchiveAddress("BadAddress"); } }); Assert.Contains("Checksum", apiException.Message); }
protected WalletCore(NodeServices nodeServices, string walletPath) { this.nodeServices = nodeServices; this.WalletPath = walletPath; this.x1WalletFile = WalletHelper.LoadX1WalletFile(walletPath); this.x1WalletFile.CurrentPath = walletPath; this.WalletName = this.x1WalletFile.WalletName; this.metadataPath = this.x1WalletFile.WalletName.GetX1WalletMetaDataFilepath(C.Network, nodeServices.DataFolder); this.metadata = WalletHelper.LoadOrCreateX1WalletMetadataFile(this.metadataPath, this.x1WalletFile, C.Network.GenesisHash); ScheduleSyncing(); }
public async void SendPayment_SendMultiBtc_NoFreeOutputs() { ServerApiException apiException = await Assert.ThrowsAsync <ServerApiException>(async() => { using (BlockchainApiHelper apiHelper = new BlockchainApiHelper()) { WalletHelper walletHelper = apiHelper.CreateWalletHelper(WalletTests.WALLET_ID, WalletTests.WALLET_PASSWORD, WalletTests.WALLET_PASSWORD2); Dictionary <string, BitcoinValue> recipients = new Dictionary <string, BitcoinValue>() { { "17VYDFsDxBMovM1cKGEytgeqdijNcr4L5", BitcoinValue.FromBtc(1) } }; await walletHelper.SendManyAsync(recipients); } }); Assert.Contains("No free", apiException.Message); }
public async void NewAddress_ArchiveThenConsolidate_Valid() { using (BlockchainApiHelper apiHelper = new BlockchainApiHelper()) { WalletHelper walletHelper = apiHelper.CreateWalletHelper(WalletTests.WALLET_ID, WalletTests.WALLET_PASSWORD, WalletTests.WALLET_PASSWORD2); Address address = await walletHelper.NewAddress("Test"); Assert.NotNull(address); string archivedAddress = await walletHelper.ArchiveAddress(address.AddressStr); Assert.NotNull(archivedAddress); string unarchivedAddress = await walletHelper.UnarchiveAddress(archivedAddress); Assert.NotNull(unarchivedAddress); } }
public async void SendMany_NullReeipients_ArgumentNUllException() { await Assert.ThrowsAsync <ArgumentException>(async() => { using (BlockchainApiHelper apiHelper = UnitTestUtil.GetFakeHelper()) { WalletHelper walletHelper = this.GetWalletHelper(apiHelper); await walletHelper.SendManyAsync(null); } }); await Assert.ThrowsAsync <ArgumentException>(async() => { using (BlockchainApiHelper apiHelper = UnitTestUtil.GetFakeHelper()) { WalletHelper walletHelper = this.GetWalletHelper(apiHelper); await walletHelper.SendManyAsync(new Dictionary <string, BitcoinValue>()); } }); }
public async void Send_BadParameters_ArgumentExceptions() { await Assert.ThrowsAsync <ArgumentNullException>(async() => { using (BlockchainApiHelper apiHelper = UnitTestUtil.GetFakeHelper()) { WalletHelper walletHelper = this.GetWalletHelper(apiHelper); await walletHelper.SendAsync(null, BitcoinValue.Zero); } }); await Assert.ThrowsAsync <ArgumentException>(async() => { using (BlockchainApiHelper apiHelper = UnitTestUtil.GetFakeHelper()) { WalletHelper walletHelper = this.GetWalletHelper(apiHelper); await walletHelper.SendAsync("Test", BitcoinValue.FromBtc(-1)); } }); }
public async void GetAddress_BadParameters_ArgumentExceptions() { await Assert.ThrowsAsync <ArgumentNullException>(async() => { using (BlockchainApiHelper apiHelper = UnitTestUtil.GetFakeHelper()) { WalletHelper walletHelper = this.GetWalletHelper(apiHelper); await walletHelper.GetAddressAsync(null); } }); await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => { using (BlockchainApiHelper apiHelper = UnitTestUtil.GetFakeHelper()) { WalletHelper walletHelper = this.GetWalletHelper(apiHelper); await walletHelper.GetAddressAsync("Test", -1); } }); }
private bool TryUnlockWalletForStakingOnly(out string errorMessage) { WalletHelper helper = new WalletHelper(m_dataConnector); // Attempt 2 unlocks to work around a wallet bug where the first unlock for staking only seems to unlock the whole wallet. if (!helper.TryUnlockWallet( m_walletPassphrase, m_config.RunFrequencyInMilliSeconds * 3, true, out errorMessage)) { return(false); } return(helper.TryUnlockWallet( m_walletPassphrase, m_config.RunFrequencyInMilliSeconds * 3, true, out errorMessage)); }
public Nep6WalletManager(IFileWrapper fileWrapper, IJsonConverter jsonConverter) { _walletHelper = new WalletHelper(); _fileWrapper = fileWrapper; _jsonConverter = jsonConverter; }
private bool TryCheckWalletCompaitibility(out string errorMessage) { WalletHelper helper = new WalletHelper(m_dataConnector); return(helper.TryCheckWalletCompaitibility(MessageService, out errorMessage)); }
private bool TryUnlockWallet(out string errorMessage) { WalletHelper helper = new WalletHelper(m_dataConnector); return(helper.TryUnlockWallet(m_walletPassphrase, 5, false, out errorMessage)); }
public decimal GetGASBalance(NetworkType network, string privateKeyHex) { var wallet = WalletHelper.GetWallet(privateKeyHex); return(wallet.GetBalance(network, WalletBalanceType.GAS)); }
/// <summary> /// Creates the wallet and user account for the hosted user wallet /// </summary> /// <returns>The created wallet info</returns> public ActionResult Create() { return(Json(WalletHelper.CreateWallet(), JsonRequestBehavior.AllowGet)); }
public ActionResult GetGASBalance(string privateKeyHex) { return(Json(WalletHelper.GetWallet(privateKeyHex).GetBalance(CurrentNetwork, WalletBalanceType.GAS))); }
public void TestGetPrivateKeyFromWIFNull() { var testee = new WalletHelper(); testee.GetPrivateKeyFromWIF(null); }