Adding DebugConsole; testing CashAddr
This commit is contained in:
@@ -97,6 +97,8 @@ namespace Swarmops.Backend
|
||||
OnNoon();
|
||||
Console.WriteLine("\r\nMidnight:");
|
||||
OnMidnight();
|
||||
Console.WriteLine("\r\nMonday Morning:");
|
||||
OnMondayMorning();
|
||||
|
||||
Console.WriteLine ("\r\nTesting database access...");
|
||||
|
||||
|
||||
@@ -138,9 +138,9 @@ namespace Swarmops.Database
|
||||
}
|
||||
else
|
||||
{
|
||||
// Dev console process.
|
||||
// Dev's debug console process.
|
||||
|
||||
string configLocation = "../Site5/database.config";
|
||||
string configLocation = "../Site/database.config";
|
||||
|
||||
// however, we don't know exactly how deep in the directory structure we are, so keep adding ../ until we
|
||||
// correct level. We may hit the root if the config doesn't exist and that'll throw us out.
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{22ABE11A-416C-4859-83A1-B3E32B4725C0}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DebugConsole</RootNamespace>
|
||||
<AssemblyName>DebugConsole</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Basic\Basic.csproj">
|
||||
<Project>{6608c2e6-f841-4cd1-8ab2-28dc3b1dddd1}</Project>
|
||||
<Name>Basic</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Common\Common.csproj">
|
||||
<Project>{bbf83512-8486-469e-9d7b-c3c1b78c3f4d}</Project>
|
||||
<Name>Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Database\Database.csproj">
|
||||
<Project>{3a5b5f19-51a5-48ce-a82e-97d5c189e5cb}</Project>
|
||||
<Name>Database</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Logic\Logic.csproj">
|
||||
<Project>{13e59551-34ac-43dc-9a03-ef5e4721dc61}</Project>
|
||||
<Name>Logic</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Swarm;
|
||||
using Swarmops.Logic.Structure;
|
||||
|
||||
|
||||
// This is a console environment for debugging the logic and database layers.
|
||||
// Nothing in this project is deployed to production environments.
|
||||
|
||||
|
||||
namespace Swarmops.DebugConsole
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(/*string[] args*/)
|
||||
{
|
||||
// Establish that we have a database connection
|
||||
|
||||
Person testPerson = Person.FromIdentity(1);
|
||||
testPerson.GetSecureAvatarLink(64); // suppress "is never used" warning
|
||||
|
||||
Organization organization = Organization.FromIdentity(7);
|
||||
|
||||
// TODO:
|
||||
|
||||
// 0) Check ForeignCurrency of hotwallet account
|
||||
|
||||
FinancialAccount hotWallet = organization.FinancialAccounts.AssetsBitcoinHot;
|
||||
|
||||
if (hotWallet != null)
|
||||
{
|
||||
Console.WriteLine("Organization has Hotwallet");
|
||||
|
||||
if (hotWallet.ForeignCurrency != null)
|
||||
{
|
||||
if (!hotWallet.ForeignCurrency.IsBitcoinCash)
|
||||
{
|
||||
Console.WriteLine(" - Foreign Currency was incorrect; setting to BCH");
|
||||
|
||||
hotWallet.ForeignCurrency = Currency.BitcoinCash;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ForeignCurrency of hotwallet was Null
|
||||
hotWallet.ForeignCurrency = Currency.BitcoinCash;
|
||||
|
||||
Console.WriteLine(" - Foreign Currency was not set; setting to BCH");
|
||||
}
|
||||
}
|
||||
|
||||
// 1) Check unspents on hotwallet addresses
|
||||
|
||||
HotBitcoinAddresses addresses = HotBitcoinAddresses.ForOrganization(organization);
|
||||
|
||||
foreach (HotBitcoinAddress address in addresses)
|
||||
{
|
||||
HotBitcoinAddressUnspents unspents1 = HotBitcoinAddressUnspents.ForAddress(address);
|
||||
int beforeCheckCount = unspents1.Count();
|
||||
|
||||
BitcoinUtility.TestUnspents(BitcoinChain.Core, address.ProtocolLevelAddress);
|
||||
BitcoinUtility.TestUnspents(BitcoinChain.Cash, address.ProtocolLevelAddress);
|
||||
|
||||
HotBitcoinAddressUnspents unspents2 = HotBitcoinAddressUnspents.ForAddress(address);
|
||||
int correctedCount = unspents2.Count();
|
||||
|
||||
if (beforeCheckCount != correctedCount)
|
||||
{
|
||||
Console.WriteLine(" - Unspent count was corrected: ");
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Shapeshift all Core into Cash
|
||||
|
||||
// 3) Adjust balances of foreign cents on hotwallet
|
||||
|
||||
// 4) Adjust value of hotwallet
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DebugConsole")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DebugConsole")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("22abe11a-416c-4859-83a1-b3e32b4725c0")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -139,6 +139,36 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
|
||||
|
||||
public static void CheckHotwalletAccountBalance(FinancialAccount hotWallet)
|
||||
{
|
||||
if (hotWallet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<BitcoinChain, Int64> satoshisPerChain = GetHotwalletSatoshisPerChain(hotWallet.Organization);
|
||||
|
||||
Int64 satoshisCash = 0;
|
||||
|
||||
if (satoshisPerChain.ContainsKey(BitcoinChain.Core))
|
||||
{
|
||||
// There should not be any. Use Shapeshift to convert to Cash.
|
||||
|
||||
// TODO
|
||||
|
||||
return; // do not repeat not process at this time
|
||||
}
|
||||
else
|
||||
{
|
||||
if (satoshisPerChain.ContainsKey(BitcoinChain.Cash))
|
||||
{
|
||||
satoshisCash = satoshisPerChain[BitcoinChain.Cash];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void CheckHotwalletForexProfitLoss(FinancialAccount hotWallet)
|
||||
{
|
||||
if (hotWallet != null)
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
{
|
||||
for (var outAddress in data.vout[index]) {
|
||||
|
||||
if (outAddress == addressUsed) {
|
||||
if (outAddress == addressUsedLegacy || outAddress == addressUsedCash) {
|
||||
|
||||
var donatedSatoshis = data.vout[index][outAddress];
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
var minerFees = -0.001; // negative, or the .1 cents will go wrong
|
||||
var returnedFunds = 0.001; // as above
|
||||
|
||||
var addressUsed = SwarmopsJS.unescape('<%=this.BitcoinCashAddressUsed %>');
|
||||
var addressUsedLegacy = SwarmopsJS.unescape('<%=this.BitcoinCashAddressLegacy %>');
|
||||
var addressUsedCash = SwarmopsJS.unescape('<%=this.BitcoinCashAddressCash %>');
|
||||
var verifyingText = SwarmopsJS.unescape('<%=this.Localized_Verifying%>');
|
||||
var guid = SwarmopsJS.unescape('<%=this.TransactionGuid%>');
|
||||
var conversionRateSatoshisToCents = <%= this.ConversionRateSatoshisToCents %>;
|
||||
|
||||
@@ -46,7 +46,8 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
HotBitcoinAddress address = HotBitcoinAddress.CreateUnique(this.CurrentOrganization, BitcoinChain.Cash,
|
||||
BitcoinUtility.BitcoinEchoTestIndex, this.CurrentUser.Identity, utcNow.Year, utcNow.Month, utcNow.Day);
|
||||
|
||||
this.BitcoinCashAddressUsed = address.ProtocolLevelAddress;
|
||||
this.BitcoinCashAddressLegacy = address.ProtocolLevelAddress;
|
||||
this.BitcoinCashAddressCash = address.HumanAddress;
|
||||
string guid = Guid.NewGuid().ToString("N");
|
||||
GuidCache.Set(guid, address.ProtocolLevelAddress);
|
||||
this.TransactionGuid = guid;
|
||||
@@ -76,7 +77,8 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
get { return BitcoinUtility.EchoFeeSatoshis; }
|
||||
}
|
||||
|
||||
public string BitcoinCashAddressUsed { get; private set; }
|
||||
public string BitcoinCashAddressLegacy { get; private set; }
|
||||
public string BitcoinCashAddressCash { get; private set; }
|
||||
public string TransactionGuid { get; private set; }
|
||||
public double ConversionRateSatoshisToCents { get; private set; }
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interface", "Interface\Inte
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Frontend-Socket", "FrontSocket\Frontend-Socket.csproj", "{8424E871-028B-4BFA-B956-E575A8F413E2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugConsole", "DebugConsole\DebugConsole.csproj", "{22ABE11A-416C-4859-83A1-B3E32B4725C0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Autobuild|.NET = Autobuild|.NET
|
||||
@@ -208,6 +210,24 @@ Global
|
||||
{8424E871-028B-4BFA-B956-E575A8F413E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8424E871-028B-4BFA-B956-E575A8F413E2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{8424E871-028B-4BFA-B956-E575A8F413E2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Autobuild|.NET.ActiveCfg = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Autobuild|.NET.Build.0 = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Autobuild|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Autobuild|Any CPU.Build.0 = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Autobuild|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Autobuild|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Debug|.NET.ActiveCfg = Debug|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Debug|.NET.Build.0 = Debug|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Release|.NET.ActiveCfg = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Release|.NET.Build.0 = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{22ABE11A-416C-4859-83A1-B3E32B4725C0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user