Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
destream-blockchain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
destream-blockchain
Commits
0191a5d6
Commit
0191a5d6
authored
Aug 09, 2018
by
Pavel Pavlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The research of the problem of the lack of connection with the wallet "Electrum"
parent
ecf81b95
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
19 deletions
+36
-19
Program.cs
Sources/DeStream.DeStreamD.ForTest/Program.cs
+12
-8
TestClassHelper.cs
Sources/DeStream.DeStreamD.ForTest/TestClassHelper.cs
+3
-3
CheckpointsTest.cs
...ratis.Bitcoin.Features.Consensus.Tests/CheckpointsTest.cs
+2
-0
NetworkPeerConnection.cs
Sources/Stratis.Bitcoin/P2P/Peer/NetworkPeerConnection.cs
+17
-7
launchSettings.json
Sources/Stratis.StratisD/Properties/launchSettings.json
+2
-1
No files found.
Sources/DeStream.DeStreamD.ForTest/Program.cs
View file @
0191a5d6
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
();
...
...
Sources/DeStream.DeStreamD.ForTest/TestClassHelper.cs
View file @
0191a5d6
...
...
@@ -49,7 +49,7 @@ namespace DeStream.DeStreamD.ForTest
var
coinbase
=
new
Transaction
();
coinbase
.
AddInput
(
TxIn
.
CreateCoinbase
(
chain
.
Height
+
1
));
coinbase
.
AddOutput
(
new
TxOut
(
Get
9
Billion
(),
address
.
ScriptPubKey
));
coinbase
.
AddOutput
(
new
TxOut
(
Get
6
Billion
(),
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
(
Get
9
Billion
(),
dest
.
GetAddress
()));
coinbase
.
AddOutput
(
new
TxOut
(
Get
6
Billion
(),
dest
.
GetAddress
()));
block
.
AddTransaction
(
coinbase
);
if
(
passedTransactions
?.
Any
()
??
false
)
{
...
...
Sources/Stratis.Bitcoin.Features.Consensus.Tests/CheckpointsTest.cs
View file @
0191a5d6
...
...
@@ -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
...
...
Sources/Stratis.Bitcoin/P2P/Peer/NetworkPeerConnection.cs
View file @
0191a5d6
...
...
@@ -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
;
...
...
Sources/Stratis.StratisD/Properties/launchSettings.json
View file @
0191a5d6
{
"profiles"
:
{
"Stratis.StratisD"
:
{
"commandName"
:
"Project"
"commandName"
:
"Project"
,
"commandLineArgs"
:
"-testnode"
},
"Stratis.StratisD Test"
:
{
"commandName"
:
"Project"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment