Make broadcast faster
MODIFY
HiddenWallet.FullSpvWallet/HiddenWallet.FullSpvWallet.csproj
HiddenWallet.FullSpvWallet/HiddenWallet.FullSpvWallet.csproj
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="DotNetTor" Version="2.3.1" />
+ <PackageReference Include="DotNetTor" Version="2.3.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.0.0-alpha2-final" /> </ItemGroup>
<ItemGroup>

MODIFY
HiddenWallet.FullSpvWallet/WalletJob.cs
HiddenWallet.FullSpvWallet/WalletJob.cs
@@ -1359,7 +1359,18 @@ namespace HiddenWallet.FullSpv
await Task.Delay(100);
- await TorSmartBitClient.PushTransactionAsync(tx, CancellationToken.None);
+ bool cancelled = false;
+ try
+ {
+ using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(21)))
+ {
+ await TorSmartBitClient.PushTransactionAsync(tx, cts.Token);
+ }
+ }
+ catch(OperationCanceledException)
+ {
+ cancelled = true;
+ }
for (int i = 0; i < 21; i++)
{
await Task.Delay(1000);
@@ -1370,6 +1381,11 @@ namespace HiddenWallet.FullSpv
return successfulResult;
}
}
+
+ if (cancelled)
+ {
+ failureResult.FailingReason += $" Details: Took too long to broadcast. The transaction might not have been successfully broadcasted. Check the Transaction ID in a block explorer. Transaction Id: {tx.GetHash()}";
+ }
}
catch (Exception ex)
{

MODIFY
HiddenWallet.Gui/app/js/broadcast-window.ts
HiddenWallet.Gui/app/js/broadcast-window.ts
@@ -373,21 +373,19 @@ function broadcastTransaction() {
var obj: BroadcastTransaction = { Hex: hex, QuickSend: false };
httpPostWalletAsync("send-transaction", obj, function (json) {
- let result: any = httpPostWallet("send-transaction", obj);
-
- if (result.Success) {
+ if (json.Success) {
alert("SUCCESS! Transaction is successfully broadcasted!");
window.parent.focus();
window.close();
}
else {
- let failText = "FAIL! " + result.Message;
+ let failText = "FAIL! " + json.Message;
- if (result.Details) {
+ if (json.Details) {
failText =
`${failText}
-Details: ${result.Details}`;
+Details: ${json.Details}`;
alert(failText);

MODIFY
HiddenWallet.Packager/Program.cs
HiddenWallet.Packager/Program.cs
@@ -74,7 +74,7 @@ namespace HiddenWallet.Packager
var psiPublish = new ProcessStartInfo
{
FileName = "dotnet",
- Arguments = $"publish -r {target} --output bin/dist/{target}",
+ Arguments = $"publish -c Release -r {target} --output bin/dist/{target}",
WorkingDirectory = daemonProjectDirectory
};
var pPublish = Process.Start(psiPublish);

MODIFY
HiddenWallet.Tests/SendTests.cs
HiddenWallet.Tests/SendTests.cs
@@ -97,7 +97,7 @@ namespace HiddenWallet.Tests
_currentWalletJob = walletJob;
(await walletJob.GetTrackerAsync()).TrackedTransactions.CollectionChanged += TrackedTransactions_CollectionChangedAsync;
- var sendRes = await walletJob.SendTransactionAsync(res.Transaction);
+ var sendRes = await walletJob.SendTransactionAsync(res.Transaction, CancellationToken.None);
Assert.True(sendRes.Success);
Assert.Empty(sendRes.FailingReason);
@@ -300,7 +300,7 @@ namespace HiddenWallet.Tests
_currentWalletJob = walletJob;
(await walletJob.GetTrackerAsync()).TrackedTransactions.CollectionChanged += TrackedTransactions_CollectionChangedAsync;
- sendRes = await walletJob.SendTransactionAsync(res.Transaction);
+ sendRes = await walletJob.SendTransactionAsync(res.Transaction, CancellationToken.None);
Assert.True(sendRes.Success);
Assert.Empty(sendRes.FailingReason);

Make broadcast faster