Adding DebugConsole; testing CashAddr

This commit is contained in:
Rick Falkvinge
2018-05-18 18:02:12 +02:00
parent 10cb9b3a2f
commit b7d17644be
10 changed files with 267 additions and 6 deletions
+6
View File
@@ -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>
+78
View File
@@ -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>
+86
View File
@@ -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
}
}
}
+36
View File
@@ -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")]