Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

Commit 455f168

Browse files
authored
Merge pull request #14 from chaincase-cash/send
Send it!
2 parents 5d705a8 + a4b70ab commit 455f168

13 files changed

+390
-70
lines changed

Chaincase.macOS/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="xamarinmac20" />
2626
<package id="Xam.Plugins.Settings" version="4.1.0-beta" targetFramework="xamarinmac20" />
2727
<package id="Xamarin.Forms" version="4.2.0.848062" targetFramework="xamarinmac20" />
28-
</packages>
28+
</packages>

Chaincase/Chaincase.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
<Compile Remove="BlockCypher\Models\BlockCypherGeneralInformation.cs" />
5757
<Compile Remove="UiConfig.cs" />
5858
</ItemGroup>
59-
<ItemGroup>
60-
<ProjectReference Include="..\WalletWasabi\WalletWasabi.Standard\WalletWasabi.Standard.csproj" />
61-
</ItemGroup>
6259
<ItemGroup>
6360
<Folder Include="Navigation\" />
6461
<Folder Include="Views\" />
@@ -80,4 +77,7 @@
8077
<ItemGroup>
8178
<EmbeddedResource Remove="Views\Templates\CoinViewTemplate %28copy%29.xaml" />
8279
</ItemGroup>
83-
</Project>
80+
<ItemGroup>
81+
<ProjectReference Include="..\WalletWasabi\WalletWasabi.Standard\WalletWasabi.Standard.csproj" />
82+
</ItemGroup>
83+
</Project>

Chaincase/Chaincase.csproj.orig

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<ProduceAssemblyReference>true</ProduceAssemblyReference>
6+
</PropertyGroup>
7+
8+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
9+
<DebugType>pdbonly</DebugType>
10+
<DebugSymbols>true</DebugSymbols>
11+
<LangVersion>7.3</LangVersion>
12+
</PropertyGroup>
13+
14+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
15+
<LangVersion>7.3</LangVersion>
16+
</PropertyGroup>
17+
<ItemGroup>
18+
<PackageReference Include="Xamarin.Forms" Version="4.3.0.851321-pre3" />
19+
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
20+
<PackageReference Include="Xam.Plugins.Settings" Version="4.0.0.10-beta" />
21+
<PackageReference Include="ReactiveUI" Version="10.5.7" />
22+
<PackageReference Include="NBitcoin" Version="4.2.15" />
23+
<PackageReference Include="ReactiveUI.XamForms" Version="10.5.7" />
24+
</ItemGroup>
25+
<ItemGroup>
26+
<Compile Remove="Crypto\StringCipher.cs" />
27+
<Compile Remove="Crypto\TokenGenerator.cs" />
28+
<Compile Remove="Helpers\ByteArrayBuilder.cs" />
29+
<Compile Remove="Helpers\ByteHelpers.cs" />
30+
<Compile Remove="Helpers\Constants.cs" />
31+
<Compile Remove="JsonConverters\BigIntegerJsonConverter.cs" />
32+
<Compile Remove="JsonConverters\BitcoinAddressJsonConverter.cs" />
33+
<Compile Remove="JsonConverters\OutPointJsonConverter.cs" />
34+
<Compile Remove="JsonConverters\PubKeyJsonConverter.cs" />
35+
<Compile Remove="JsonConverters\ScriptJsonConverter.cs" />
36+
<Compile Remove="JsonConverters\TransactionJsonConverter.cs" />
37+
<Compile Remove="JsonConverters\Uint256JsonConverter.cs" />
38+
<Compile Remove="JsonConverters\UnblindedSignatureJsonConverter.cs" />
39+
<Compile Remove="Logging\LogLevel.cs" />
40+
<Compile Remove="Logging\LogMode.cs" />
41+
<Compile Remove="Logging\Logger.cs" />
42+
<Compile Remove="Nito\AsyncEx\AsyncLock.cs" />
43+
<Compile Remove="Nito\AsyncEx\AsyncMutex.cs" />
44+
<Compile Remove="Nito\AsyncEx\AsyncWaitQueueExtensions.cs" />
45+
<Compile Remove="Nito\AsyncEx\AwaitableDisposable.cs" />
46+
<Compile Remove="Nito\AsyncEx\DefaultAsyncWaitQueue.cs" />
47+
<Compile Remove="Nito\AsyncEx\ExceptionHelpers.cs" />
48+
<Compile Remove="Nito\AsyncEx\IAsyncWaitQueue.cs" />
49+
<Compile Remove="Nito\AsyncEx\IdManager.cs" />
50+
<Compile Remove="Nito\AsyncEx\TaskCompletionSourceExtensions.cs" />
51+
<Compile Remove="Nito\AsyncEx\Synchronous\SynchronousTaskExtensions.cs" />
52+
<Compile Remove="Nito\Collections\CollectionHelpers.cs" />
53+
<Compile Remove="Nito\Collections\Deque.cs" />
54+
<Compile Remove="Nito\Disposables\SingleDisposable.cs" />
55+
<Compile Remove="Nito\Disposables\Internals\BoundAction.cs" />
56+
<Compile Remove="BlockCypher\Models\BlockCypherGeneralInformation.cs" />
57+
<Compile Remove="UiConfig.cs" />
58+
</ItemGroup>
59+
<ItemGroup>
60+
<Folder Include="Navigation\" />
61+
<Folder Include="Views\" />
62+
<Folder Include="Controllers\" />
63+
<Folder Include="ViewModels\" />
64+
<Folder Include="Models\" />
65+
</ItemGroup>
66+
<ItemGroup>
67+
<Compile Update="Views\MainPage.xaml.cs">
68+
<DependentUpon>MainPage.xaml</DependentUpon>
69+
</Compile>
70+
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="Views\Templates\CoinViewTemplate.xaml.cs">
71+
<DependentUpon>CoinViewTemplate.xaml</DependentUpon>
72+
</Compile>
73+
</ItemGroup>
74+
<ItemGroup>
75+
<None Remove="CustomBuildActions.targets" />
76+
</ItemGroup>
77+
<ItemGroup>
78+
<EmbeddedResource Remove="Views\Templates\CoinViewTemplate %28copy%29.xaml" />
79+
</ItemGroup>
80+
<ItemGroup>
81+
<ProjectReference Include="..\WalletWasabi\WalletWasabi.Standard\WalletWasabi.Standard.csproj" />
82+
</ItemGroup>
83+
</Project>

Chaincase/Controllers/WalletController.cs

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using NBitcoin;
66
using WalletWasabi.KeyManagement;
77
using WalletWasabi.Logging;
8+
using WalletWasabi.Models;
89

910
namespace Chaincase.Controllers
1011
{
@@ -67,5 +68,20 @@ public static Money GetBalance()
6768
c => c.Unspent && !c.SpentAccordingToBackend
6869
).Sum(c => (long?)c.Amount) ?? 0;
6970
}
71+
72+
public static Boolean SendTransaction (string addressString, FeeRate rate)
73+
{
74+
BitcoinAddress address;
75+
try
76+
{
77+
address = BitcoinAddress.Create(addressString.Trim(), Global.Network);
78+
}
79+
catch (FormatException e)
80+
{
81+
return false;
82+
}
83+
84+
return true;
85+
}
7086
}
7187
}

Chaincase/ViewModels/CoinListViewModel.cs

+30-4
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,43 @@
1616
using Chaincase.Models;
1717
using Chaincase.Navigation;
1818
using Xamarin.Forms;
19+
using NBitcoin;
1920

2021
namespace Chaincase.ViewModels
2122
{
2223
public class CoinListViewModel : ViewModelBase
2324
{
24-
private CompositeDisposable Disposables { get; set; }
2525

26-
public SourceList<CoinViewModel> RootList { get; private set; }
26+
private Money _selectedAmount;
2727

28-
private ReadOnlyObservableCollection<CoinViewModel> _coinViewModels;
28+
public Money SelectedAmount
29+
{
30+
get => _selectedAmount;
31+
set => this.RaiseAndSetIfChanged(ref _selectedAmount, value);
32+
}
2933

30-
public ReactiveCommand<Unit, Unit> BackCommand { get; }
34+
private string _selectedAmountText;
35+
public String SelectedAmountText
36+
{
37+
get => _selectedAmountText;
38+
set => this.RaiseAndSetIfChanged(ref _selectedAmountText, $"{value} BTC Selected");
39+
}
3140

3241
public event EventHandler<CoinViewModel> SelectionChanged;
3342

43+
private CompositeDisposable Disposables { get; set; }
44+
45+
public SourceList<CoinViewModel> RootList { get; private set; }
46+
47+
private ReadOnlyObservableCollection<CoinViewModel> _coinViewModels;
48+
3449
public ReadOnlyObservableCollection<CoinViewModel> Coins => _coinViewModels;
3550

51+
public ReactiveCommand<Unit, Unit> BackCommand { get; }
52+
3653
public CoinListViewModel(IScreen hostScreen) : base(hostScreen)
3754
{
55+
SelectedAmountText = "0";
3856
RootList = new SourceList<CoinViewModel>();
3957
RootList.Connect()
4058
.OnItemRemoved(x => x.UnsubscribeEvents())
@@ -45,6 +63,7 @@ public CoinListViewModel(IScreen hostScreen) : base(hostScreen)
4563

4664
BackCommand = hostScreen.Router.NavigateBack;
4765
OnOpen();
66+
4867
}
4968

5069
public void OnOpen()
@@ -109,5 +128,12 @@ public void OnClose()
109128
Disposables?.Dispose();
110129
}
111130

131+
public void OnCoinIsSelectedChanged(CoinViewModel cvm)
132+
{
133+
SelectionChanged?.Invoke(this, cvm);
134+
SelectedAmount = Coins.Where(x => x.IsSelected).Sum(x => x.Amount);
135+
SelectedAmountText = SelectedAmount.ToString();
136+
}
137+
112138
}
113139
}

Chaincase/ViewModels/CoinViewModel.cs

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public void SubscribeEvents()
5656
_unavailable = Model.WhenAnyValue(x => x.Unavailable).ToProperty(this, x => x.Unavailable, scheduler: RxApp.MainThreadScheduler)
5757
.DisposeWith(Disposables);
5858

59+
this.WhenAnyValue(x => x.IsSelected)
60+
.ObserveOn(RxApp.MainThreadScheduler)
61+
.Subscribe(_ => _owner.OnCoinIsSelectedChanged(this));
62+
5963
this.WhenAnyValue(x => x.Status)
6064
.Subscribe(_ => this.RaisePropertyChanged(nameof(ToolTip)));
6165

0 commit comments

Comments
 (0)