From 8c61a8d2ff49ad2acb3443393e68376d397bd358 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 8 Oct 2015 13:56:30 +0200 Subject: [PATCH] Enabled Donations; Work on bitcoin payouts --- Backend/Program.cs | 2 +- Logic/Financial/BitcoinUtility.cs | 34 ++++++++++ Logic/Financial/FinancialAccounts.cs | 30 --------- Logic/Financial/HotBitcoinAddress.cs | 34 +++++++++- Logic/Financial/Payout.cs | 2 + Logic/Financial/Payouts.cs | 3 + Site5/App_GlobalResources/Menu5.resx | 3 + .../Images/PageIcons/iconshock-gift-40px.png | Bin 0 -> 2878 bytes .../Images/PageIcons/iconshock-gift-96px.png | Bin 0 -> 9526 bytes Site5/MainMenu-v5.xml | 40 ++++++++---- Site5/Pages/v5/Financial/Donate.aspx | 26 ++++++-- Site5/Pages/v5/Financial/Donate.aspx.cs | 35 +++++++--- .../v5/Financial/Json-PayableCosts.aspx.cs | 8 +++ Site5/web.config | 60 ++++++++++-------- 14 files changed, 188 insertions(+), 89 deletions(-) create mode 100644 Site5/Images/PageIcons/iconshock-gift-40px.png create mode 100644 Site5/Images/PageIcons/iconshock-gift-96px.png diff --git a/Backend/Program.cs b/Backend/Program.cs index c43f8279..b2ac823f 100644 --- a/Backend/Program.cs +++ b/Backend/Program.cs @@ -170,7 +170,7 @@ namespace Swarmops.Backend // Check for existence of bitcoin hotwallet root - FinancialAccounts.VerifyBitcoinHotWallet(); + BitcoinUtility.VerifyBitcoinHotWallet(); // Begin maintenance loop diff --git a/Logic/Financial/BitcoinUtility.cs b/Logic/Financial/BitcoinUtility.cs index 379f231a..711f81de 100644 --- a/Logic/Financial/BitcoinUtility.cs +++ b/Logic/Financial/BitcoinUtility.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; +using System.IO; using System.Linq; using System.Net; using System.Text; @@ -12,11 +13,42 @@ using NBitcoin; using NBitcoin.BouncyCastle.Asn1.Ocsp; using Newtonsoft.Json.Linq; using Swarmops.Database; +using Swarmops.Logic.Support; namespace Swarmops.Logic.Financial { public class BitcoinUtility { + public static void VerifyBitcoinHotWallet() + { + // Make sure there's always a private hotwallet root, regardless of whether it's used or not + + if (!File.Exists(SystemSettings.EtcFolder + Path.DirectorySeparatorChar + "hotwallet")) + { + ExtKey privateRoot = new ExtKey(); + File.WriteAllText(SystemSettings.EtcFolder + Path.DirectorySeparatorChar + "hotwallet", privateRoot.GetWif(Network.Main).ToWif(), Encoding.ASCII); + File.WriteAllText(SystemSettings.EtcFolder + Path.DirectorySeparatorChar + "hotwallet-created-" + DateTime.UtcNow.ToString("yyyy-MM-dd--HH-mm-ss--fff.backup"), privateRoot.GetWif(Network.Main).ToWif(), Encoding.ASCII); // an extra backup + Persistence.Key["BitcoinHotPublicRoot"] = privateRoot.Neuter().GetWif(Network.Main).ToWif(); + } + } + + public static ExtKey BitcoinHotPrivateRoot + { + get + { + return + ExtKey.Parse(File.ReadAllText(SystemSettings.EtcFolder + Path.DirectorySeparatorChar + "hotwallet")); // will throw if hotwallet file does not exist - intentional + } + } + + public static ExtPubKey BitcoinHotPublicRoot + { + get + { + return ExtPubKey.Parse((string)Persistence.Key["BitcoinHotPublicRoot"]); + } + } + static public Coin[] GetSpendableCoin (BitcoinSecret secretKey) // we're using BitcoinSecret as arg just to reinforce caller must have privkey to spend funds { // This function queries the Blockchain API for the unspent coin. @@ -115,6 +147,8 @@ namespace Swarmops.Logic.Financial public const int BitcoinAccountsReceivableIndex = 4; public const string BitcoinTestAddress = "1JMpU3D6c5sruunMwzkt6p6PQzLcUYcL26"; + + public const long FeeSatoshisPerThousandBytes = 10000; } internal class BitcoinUnspentTransactionOutput diff --git a/Logic/Financial/FinancialAccounts.cs b/Logic/Financial/FinancialAccounts.cs index 8a5b1c28..76c9ba0d 100644 --- a/Logic/Financial/FinancialAccounts.cs +++ b/Logic/Financial/FinancialAccounts.cs @@ -217,37 +217,7 @@ namespace Swarmops.Logic.Financial } - public static void VerifyBitcoinHotWallet() - { - // Make sure there's always a private hotwallet root, regardless of whether it's used or not - if (!File.Exists (SystemSettings.EtcFolder + Path.DirectorySeparatorChar + "hotwallet")) - { - ExtKey privateRoot = new ExtKey(); - File.WriteAllText(SystemSettings.EtcFolder + Path.DirectorySeparatorChar + "hotwallet", privateRoot.GetWif(Network.Main).ToWif(), Encoding.ASCII); - File.WriteAllText(SystemSettings.EtcFolder + Path.DirectorySeparatorChar + "hotwallet-created-" + DateTime.UtcNow.ToString("yyyy-MM-dd--HH-mm-ss--fff.backup"), privateRoot.GetWif(Network.Main).ToWif(), Encoding.ASCII); // an extra backup - Persistence.Key["BitcoinHotPublicRoot"] = privateRoot.Neuter().GetWif(Network.Main).ToWif(); - } - } - - public static ExtKey BitcoinHotPrivateRoot - { - get - { - VerifyBitcoinHotWallet(); - - return - ExtKey.Parse (File.ReadAllText (SystemSettings.EtcFolder + Path.DirectorySeparatorChar + "hotwallet")); - } - } - - public static ExtPubKey BitcoinHotPublicRoot - { - get - { - return ExtPubKey.Parse ((string) Persistence.Key["BitcoinHotPublicRoot"]); - } - } } } \ No newline at end of file diff --git a/Logic/Financial/HotBitcoinAddress.cs b/Logic/Financial/HotBitcoinAddress.cs index 81de1cd8..866fd1ba 100644 --- a/Logic/Financial/HotBitcoinAddress.cs +++ b/Logic/Financial/HotBitcoinAddress.cs @@ -51,7 +51,7 @@ namespace Swarmops.Logic.Financial public static HotBitcoinAddress Create (Organization organization, params int[] derivationPath) { - ExtPubKey extPubKey = FinancialAccounts.BitcoinHotPublicRoot; + ExtPubKey extPubKey = BitcoinUtility.BitcoinHotPublicRoot; extPubKey = extPubKey.Derive ((uint) organization.Identity); string derivationPathString = string.Empty; @@ -76,9 +76,41 @@ namespace Swarmops.Logic.Financial return FromBasic(SwarmDb.GetDatabaseForReading().GetHotBitcoinAddress(bitcoinAddress)); } + public BitcoinSecret PrivateKey + { + get + { + // This will throw if the private root key is not available to the running code, and that's as designed + + ExtKey secretExtKey = BitcoinUtility.BitcoinHotPrivateRoot.Derive ((uint) base.OrganizationId); + + foreach (string derivationString in DerivationPath.Split (' ')) + { + secretExtKey = secretExtKey.Derive (UInt32.Parse (derivationString)); + } + + return secretExtKey.PrivateKey.GetBitcoinSecret (Network.Main); + } + } + + public Organization Organization + { + get { return Organization.FromIdentity (base.OrganizationId); } + } + public HotBitcoinAddressUnspents Unspents { get { return HotBitcoinAddressUnspents.ForAddress (this); } } + + public Int64 UnspentSatoshis + { + get + { + HotBitcoinAddressUnspents unspents = Unspents; + + return unspents.Sum (unspent => unspent.AmountSatoshis); + } + } } } diff --git a/Logic/Financial/Payout.cs b/Logic/Financial/Payout.cs index 8cff08f8..6c9fc24b 100644 --- a/Logic/Financial/Payout.cs +++ b/Logic/Financial/Payout.cs @@ -117,6 +117,8 @@ namespace Swarmops.Logic.Financial public Salaries DependentSalariesNet; public Salaries DependentSalariesTax; + public Person RecipientPerson { get; set; } + public decimal Amount { set diff --git a/Logic/Financial/Payouts.cs b/Logic/Financial/Payouts.cs index fba816f1..3522a847 100644 --- a/Logic/Financial/Payouts.cs +++ b/Logic/Financial/Payouts.cs @@ -102,6 +102,7 @@ namespace Swarmops.Logic.Financial claim.Claimer.BankClearing + " / " + claim.Claimer.BankAccount, string.Empty, 0, DateTime.MinValue, false, DateTime.Now, 0); Payout payout = Payout.FromBasic (basicPayout); + payout.RecipientPerson = claim.Claimer; payout.DependentExpenseClaims.Add (claim); @@ -206,6 +207,7 @@ namespace Swarmops.Logic.Financial advance.Person.BankClearing + " / " + advance.Person.BankAccount, string.Empty, 0, DateTime.MinValue, false, DateTime.Now, 0); Payout payout = Payout.FromBasic (basicPayout); + payout.RecipientPerson = advance.Person; payout.DependentCashAdvancesPayout.Add (advance); @@ -297,6 +299,7 @@ namespace Swarmops.Logic.Financial salary.PayoutDate.ToString (CultureInfo.InvariantCulture), salary.NetSalaryCents, salary.PayoutDate, false, DateTime.Now, 0); Payout payout = Payout.FromBasic (basicPayout); + payout.RecipientPerson = employee; payout.DependentSalariesNet.Add (salary); diff --git a/Site5/App_GlobalResources/Menu5.resx b/Site5/App_GlobalResources/Menu5.resx index c8f5cfb8..1fc6b9bb 100644 --- a/Site5/App_GlobalResources/Menu5.resx +++ b/Site5/App_GlobalResources/Menu5.resx @@ -414,4 +414,7 @@ My Local Organization + + Donate Funds + \ No newline at end of file diff --git a/Site5/Images/PageIcons/iconshock-gift-40px.png b/Site5/Images/PageIcons/iconshock-gift-40px.png new file mode 100644 index 0000000000000000000000000000000000000000..c3cdacc183d732858f05362e9c5e6e679da7a138 GIT binary patch literal 2878 zcmV-E3&He>P)o3d>1E zK~z}7?U;FtUDbWZKj)l#?^|cy?Bf}aXFRqsE;t68Eyc#QQb?eUn*LFuHW8^w6E#iJ zrYfnLKdMyfN=X!{B@}4WLed2hL#RYUn~0PWN>K^Zl*oz&qoe@&A0d4_B+gnzbL-&$oAAxU5H4^YZ&(PD37k(tGn6Hr$&CC zr^}CVl%oLR^Zj2OZtuL~=W_+`AH1B|A!P$8HNpW}LZ<{zA|eCj1ct7Mj;%le3T;rx zL1_-E0W1hubddNhhwAot{%d=FmTK;f&TP-fyEC_DZua-8E#Zhh!jW)^0f0~P8*6+p z_>-ag_iY~C`P2Da$9r;_&Rw}|K?eRAGQmM|nHR~Yze}#`JaTh8PJ&1ha0>di!03{K zaS>kqF1&IICK^yPEwGFa+t$G@#evU%km(CM$&;fQ)rjN9*(8aNMsfIZy}5XFu6ge8 zBRo2{5+wKbKK!mNo3Fip-G-s713%N_dufCK=Kv(mNrb4O^JF31qchqYK+lDQHU`~ zu@P3^Xhzk$zZm`D2?@~d_YY*t>uwQ~g&wK_IENDsaDYJwjk5(*kRm@ahTnY}Tn+j* zBewOS@-ZeVA)b1H#;MmRP5Z3?*_b8X(8q~maB%^mOd8eSPT$5EI@iBKq$A>3pmht- zT0@e=UC!F=N~qjQkO(Bg2~6FgYmU%^pjQy|N`#aI*>m)b-beS)*AOa!l7K62f#G5J z!P7`zlJP8}X&5k$>SP3aM<87%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#l-|o^%AUc~0;v>!Pzx3FX$usTM{9?+JzVJjwN|klxc@|5%ab#N77t3DX zO1v_VBn`dd70Oi@$~;Tft1@59)m}U^c<3|V-1NtPG5zubAqJ%63NYGiopw&5L{uG@Xp z(2hH=xbmt|PiJY&HgM7)GfBi#4k= z+7ET~ArSaV5*s6zGC<11EA$om`)+K1_wL(wzyGeC*WGwSKHG_j49$9tvGIR9@z>8j z{P2nT@t0y7PXa}td0E1FTh3;d6OR-^rkt}`plvf-c7F7IpZL(m4Wrwi`q!`j;}d5e z|7T!EAm$yec3B+1y@yAa&7%aucepf=1u{#8t-h2tVlMU4{I~&E&nK7sRIc=&EyWz~ cjQ@l2UzLdI3F-QP+yDRo07*qoM6N<$g7xrehyVZp literal 0 HcmV?d00001 diff --git a/Site5/Images/PageIcons/iconshock-gift-96px.png b/Site5/Images/PageIcons/iconshock-gift-96px.png new file mode 100644 index 0000000000000000000000000000000000000000..57e6b1bb30424688139d16ddea96389ad4f84a29 GIT binary patch literal 9526 zcmV-6CCS=}P)x^cRMw(5t^z6NFx9|2Y&yx?&dzbE>rF$em z;CZWV-R_>dy!ZUi`Jew;?mKY(xPDwet{>Nr>&Nxu`f>fZeq2AUAJ>oT$Mxg-as8No zn2&(@@WQ`cKYrH0{Oh0Z^LO8fo{k3j{Jg)vn;U53KDxOFksOoe3-TqthgtZ1`HP<) z0OXBk{F?Dh2A5yqUh=$$UU@SEvXVZPr-dvcidW(p4(X4{7x=RI9gxpm;dOr-@ZOlf z$Q#Z0=EE!_&A+Eh-p^{)L%%rW#HpWY^ZiqCg(Ldi@+BTOzmAaSO(=d7mm5(MQZ~<0 zgys*J<^pZF1Zb+n@;B(F_XYLSkCHbU1v$VMF#IcG;C2^wq#=$WjxPPAGVp^a zByBu8tr2k(a8{&Ya|@i0U{7(B@n|EZ`>*-~wqEwzS)a z$G~_1Q3SIZhGUq}TT?F$Bk|EhaULX_(ee zFr>f0N%KwlE(P<@LM8TdDMPCtbs>P%=cBsuOTXn0I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?9Gz>Yr)P(A+dH?d zzvaER|I*!ko8Plow>01j zs_o6(d*6`|r7J``d5r=vlQa<)1W|_*W!&htF;WRr|6H0k;IRc!ov8~$erKy!87 z3`A`;ZaxsHQWl1Qke+w+Z|G!4ikrG z0Yj?8Bh~FNJw48WAMYD_^pWp9_eivBSCz{7#MsSrQ@Mn!e9b)nMg(B~p_=Yh6A+ee2F! z*RS8WeeF%_(#zH@XL@9kL(d+J_UwJ`nIF8e>*<5M^b$~0HM8^RCYVPz=2{kUe%=AN zRKk{d344B2q?4a>-Ee*Y$6_e|&0m@W~@T+_kr|`$&=ESYqtrWxAEo zB|P5zQw88s=ceZ63g;4eA`PT-NrH_-9_0sjR- UhqZ(oA^-pY07*qoM6N<$f)fUUTL1t6 literal 0 HcmV?d00001 diff --git a/Site5/MainMenu-v5.xml b/Site5/MainMenu-v5.xml index ca8561dc..eeaf7199 100644 --- a/Site5/MainMenu-v5.xml +++ b/Site5/MainMenu-v5.xml @@ -154,21 +154,37 @@ Link - + - Financial_RequestCashAdvance - 1 - - iconshock-walletmoney - /Pages/v5/Financial/RequestCashAdvance.aspx - Link - + Financial_RequestCashAdvance + 1 + + iconshock-walletmoney + /Pages/v5/Financial/RequestCashAdvance.aspx + Link + - + - 2 - Separator - + 1 + Separator + + + + + Financial_DonateFunds + 1 + + iconshock-gift + /Pages/v5/Financial/Donate.aspx + Link + + + + + 2 + Separator + diff --git a/Site5/Pages/v5/Financial/Donate.aspx b/Site5/Pages/v5/Financial/Donate.aspx index 2fbd7e70..8bbf7364 100644 --- a/Site5/Pages/v5/Financial/Donate.aspx +++ b/Site5/Pages/v5/Financial/Donate.aspx @@ -6,8 +6,10 @@ // Initialize socket to wait for transaction - initializeSocket(); - + if (enable) { + initializeSocket(); + } + // TODO: Also poll regularly in case socket fails }); @@ -40,7 +42,7 @@ // transaction received at address // call page to check if funds received server side - alertify.log("Tx received on socket, checking..."); + alertify.log("Detected transaction, verifying..."); checkTransactionReceived(message.x.hash); } }; @@ -70,15 +72,25 @@ var guid = ''; var socket = null; var completed = false; + var enable = true; -

-

-

-
+ +

+

+

+
+
+ +

Bitcoin hotwallet is not enabled

+ Fail symbol
+

This organization has not enabled its bitcoin hotwallet in Swarmops. Therefore, direct donations are not available.

+

Contact the administrator for <%=this.CurrentOrganization.Name %> and ask them to enable the bitcoin hotwallet.

+
+
diff --git a/Site5/Pages/v5/Financial/Donate.aspx.cs b/Site5/Pages/v5/Financial/Donate.aspx.cs index db127e2e..9e85c3e8 100644 --- a/Site5/Pages/v5/Financial/Donate.aspx.cs +++ b/Site5/Pages/v5/Financial/Donate.aspx.cs @@ -12,6 +12,8 @@ using NBitcoin; using Swarmops.Logic.Cache; using Swarmops.Logic.Financial; using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; +using Satoshis = NBitcoin.Money; // Sets it apart from Swarmops' Money class namespace Swarmops.Frontend.Pages.v5.Financial { @@ -21,13 +23,32 @@ namespace Swarmops.Frontend.Pages.v5.Financial { this.PageAccessRequired = new Access (this.CurrentOrganization, AccessAspect.Participant); - // TODO: This page needs a check on whether currentorganization.financialaccounts.assetbitcoinhot is null + /* TEMP TEMP TEMP - REMOVE THIS CODE */ + /* + Organization fwn = Organization.FromIdentity (2); + Salaries salaries = Salaries.ForOrganization (fwn); + foreach (Salary salary in salaries) + { + if (salary.PayrollItem.Person.BitcoinPayoutAddress.Length > 0 && salary.Attested == false) + { + salary.Attest (salary.PayrollItem.Person); // null for system apparently isn't allowed here + } + }*/ + + // TODO: This page needs a check on whether currentorganization.financialaccounts.assetbitcoinhot is null this.PageTitle = Resources.Pages.Financial.Donate_PageTitle; this.InfoBoxLiteral = Resources.Pages.Financial.Donate_Info; this.LabelStatus.Text = Resources.Pages.Financial.Donate_StatusInitial; + if (this.CurrentOrganization.FinancialAccounts.AssetsBitcoinHot == null) + { + this.PanelDisabled.Visible = true; + this.PanelEnabled.Visible = false; + this.LiteralEnable.Text = @"false"; + } + HotBitcoinAddress address = HotBitcoinAddress.Create (this.CurrentOrganization, BitcoinUtility.BitcoinDonationsIndex, this.CurrentUser.Identity); @@ -38,20 +59,14 @@ namespace Swarmops.Frontend.Pages.v5.Financial // TEST TEST TEST /* - BitcoinSecret secretKey = - FinancialAccounts.BitcoinHotPrivateRoot.Derive ((uint) this.CurrentOrganization.Identity) - .Derive (BitcoinUtility.BitcoinDonationsIndex) - .Derive ((uint) this.CurrentUser.Identity) - .PrivateKey - .GetBitcoinSecret (Network.Main); - + BitcoinSecret secretKey = address.PrivateKey; Coin[] spendableCoin = BitcoinUtility.GetSpendableCoin (secretKey); TransactionBuilder txBuild = new TransactionBuilder(); Transaction tx = txBuild.AddCoins (spendableCoin) .AddKeys (secretKey) - .Send (new BitcoinAddress (BitcoinUtility.BitcoinTestAddress), "0.001") - .SendFees ("0.0001") + .Send (new BitcoinAddress (BitcoinUtility.BitcoinTestAddress), new Satoshis (address.UnspentSatoshis - BitcoinUtility.FeeSatoshisPerThousandBytes)) + .SendFees (new Satoshis(BitcoinUtility.FeeSatoshisPerThousandBytes)) .SetChange (secretKey.GetAddress()) .BuildTransaction (true); diff --git a/Site5/Pages/v5/Financial/Json-PayableCosts.aspx.cs b/Site5/Pages/v5/Financial/Json-PayableCosts.aspx.cs index a911c906..730d6711 100644 --- a/Site5/Pages/v5/Financial/Json-PayableCosts.aspx.cs +++ b/Site5/Pages/v5/Financial/Json-PayableCosts.aspx.cs @@ -39,9 +39,17 @@ namespace Swarmops.Frontend.Pages.Financial StringBuilder result = new StringBuilder (16384); DateTime today = DateTime.Today; + bool bitcoinHotWalletActive = (this.CurrentOrganization.FinancialAccounts.AssetsBitcoinHot != null + ? true + : false); foreach (Payout payout in payouts) { + if (bitcoinHotWalletActive && payout.RecipientPerson != null && payout.RecipientPerson.BitcoinPayoutAddress.Length > 0 && payout.Account.Length < 2) + { + continue; + } + result.Append ("{"); result.AppendFormat ( "\"itemId\":\"{0}\"," + diff --git a/Site5/web.config b/Site5/web.config index 36c3118f..204dfa3c 100644 --- a/Site5/web.config +++ b/Site5/web.config @@ -1,4 +1,4 @@ - + - - - - + + + + + + + + - + - + - - - - - - - - + + + + + + + + - + - + - - - - + + + + - + - + - + - - + + - + - +