Commit 0191a5d6 authored by Pavel Pavlov's avatar Pavel Pavlov

The research of the problem of the lack of connection with the wallet "Electrum"

parent ecf81b95
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
......@@ -68,19 +69,22 @@ namespace DeStream.DeStreamD.ForTest
.AddRPC()
.Build();
(Wallet wallet, Block block, ChainedHeader chainedHeader) result = TestClassHelper.CreateFirstTransaction(nodeSettings, node.WalletManager(), node.NodeService<WalletSettings>(),
node.NodeService<IWalletFeePolicy>());
var walletManager = node.WalletManager();
walletManager.Wallets.Add(result.wallet);
//(Wallet wallet, Block block, ChainedHeader chainedHeader) result = TestClassHelper.CreateFirstTransaction(nodeSettings, node.WalletManager(), node.NodeService<WalletSettings>(),
// node.NodeService<IWalletFeePolicy>());
//var walletManager = node.WalletManager();
//walletManager.Wallets.Add(result.wallet);
HdAddress addr = result.wallet.AccountsRoot.ElementAt(0).Accounts.ElementAt(0).ExternalAddresses.ElementAt(0);
Key key = result.wallet.GetExtendedPrivateKeyForAddress("password", addr).PrivateKey;
TestClassHelper.CreateTestBlock(node, key);
//HdAddress addr = result.wallet.AccountsRoot.ElementAt(0).Accounts.ElementAt(0).ExternalAddresses.ElementAt(0);
//Key key = result.wallet.GetExtendedPrivateKeyForAddress("password", addr).PrivateKey;
//TestClassHelper.CreateTestBlock(node, key);
//walletManager.SaveWallets();
var test = node.WalletManager().GetSpendableTransactionsInWallet("myWallet1").Sum(s => s.Transaction.Amount);
//var test = node.WalletManager().GetSpendableTransactionsInWallet("myWallet1").Sum(s => s.Transaction.Amount);
Process currentProcess = Process.GetCurrentProcess();
Console.WriteLine("##############################: " + currentProcess.Id.ToString());
int qwe0 = 1;
if (node != null)
await node.RunAsync();
......
......@@ -49,7 +49,7 @@ namespace DeStream.DeStreamD.ForTest
var coinbase = new Transaction();
coinbase.AddInput(TxIn.CreateCoinbase(chain.Height + 1));
coinbase.AddOutput(new TxOut(Get9Billion(), address.ScriptPubKey));
coinbase.AddOutput(new TxOut(Get6Billion(), address.ScriptPubKey));
block.AddTransaction(coinbase);
block.Header.Nonce = 0;
......@@ -231,7 +231,7 @@ namespace DeStream.DeStreamD.ForTest
public static Block CreateTestBlock(FullNode fullNode, Key key)
{
//FullNode fullNode = (this.runner as StratisBitcoinPowRunner).FullNode;
BitcoinSecret dest = new BitcoinSecret(key, fullNode.Network);
var blocks = new List<Block>();
......@@ -244,7 +244,7 @@ namespace DeStream.DeStreamD.ForTest
block.Header.UpdateTime(DateTimeOffset.UtcNow, fullNode.Network, fullNode.Chain.Tip);
var coinbase = new Transaction();
//coinbase.AddInput(TxIn.CreateCoinbase(fullNode.Chain.Height + 1));
coinbase.AddOutput(new TxOut(Get9Billion(), dest.GetAddress()));
coinbase.AddOutput(new TxOut(Get6Billion(), dest.GetAddress()));
block.AddTransaction(coinbase);
if (passedTransactions?.Any() ?? false)
{
......
......@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Text;
using NBitcoin;
using Stratis.Bitcoin.Configuration.Settings;
using Stratis.Bitcoin.Consensus;
using Xunit;
namespace Stratis.Bitcoin.Features.Consensus.Tests
......
......@@ -150,7 +150,7 @@ namespace Stratis.Bitcoin.P2P.Peer
this.MessageProducer.PushMessage(incomingMessage);
}
}
catch (OperationCanceledException)
catch (OperationCanceledException ex)
{
this.logger.LogTrace("Receiving cancelled.");
this.peer.Disconnect("Receiving cancelled.");
......@@ -340,7 +340,7 @@ namespace Stratis.Bitcoin.P2P.Peer
/// <exception cref="ProtocolViolationException">Thrown if the incoming message is too big.</exception>
private async Task<byte[]> ReadMessageAsync(ProtocolVersion protocolVersion, CancellationToken cancellation = default(CancellationToken))
{
this.logger.LogTrace("({0}:{1})", nameof(protocolVersion), protocolVersion);
//this.logger.LogTrace("({0}:{1})", nameof(protocolVersion), protocolVersion);
// First find and read the magic.
await this.ReadMagicAsync(this.network.MagicBytes, cancellation).ConfigureAwait(false);
......@@ -411,7 +411,7 @@ namespace Stratis.Bitcoin.P2P.Peer
this.logger.LogTrace("(-)");
}
static int _offset=0;
/// <summary>
/// Reads a specific number of bytes from the connection stream into a buffer.
/// </summary>
......@@ -423,11 +423,20 @@ namespace Stratis.Bitcoin.P2P.Peer
/// <exception cref="OperationCanceledException">Thrown if the operation was cancelled or the end of the stream was reached.</exception>
private async Task ReadBytesAsync(byte[] buffer, int offset, int bytesToRead, CancellationToken cancellation = default(CancellationToken))
{
this.logger.LogTrace("({0}:{1},{2}:{3})", nameof(offset), offset, nameof(bytesToRead), bytesToRead);
//this.logger.LogTrace("({0}:{1},{2}:{3})", nameof(offset), offset, nameof(bytesToRead), bytesToRead);
while (bytesToRead > 0)
{
int chunkSize = await this.stream.ReadAsync(buffer, offset, bytesToRead, cancellation).ConfigureAwait(false);
int chunkSize = 0;
try
{
chunkSize = this.stream.Read(buffer, offset, bytesToRead);
//chunkSize = await this.stream.ReadAsync(buffer, offset, bytesToRead, cancellation).ConfigureAwait(false);
}catch(Exception ex)
{
int qwe = 1;
_offset = 0;
}
if (chunkSize == 0)
{
this.logger.LogTrace("(-)[STREAM_END]");
......@@ -435,10 +444,11 @@ namespace Stratis.Bitcoin.P2P.Peer
}
offset += chunkSize;
_offset += offset;
bytesToRead -= chunkSize;
}
this.logger.LogTrace("(-)");
//this.logger.LogTrace("(-)");
}
/// <summary>
......@@ -456,7 +466,7 @@ namespace Stratis.Bitcoin.P2P.Peer
/// </remarks>
private async Task<Message> ReadAndParseMessageAsync(ProtocolVersion protocolVersion, CancellationToken cancellation)
{
this.logger.LogTrace("({0}:{1})", nameof(protocolVersion), protocolVersion);
//this.logger.LogTrace("({0}:{1})", nameof(protocolVersion), protocolVersion);
Message message = null;
......
{
"profiles": {
"Stratis.StratisD": {
"commandName": "Project"
"commandName": "Project",
"commandLineArgs": "-testnode"
},
"Stratis.StratisD Test": {
"commandName": "Project",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment