diff --git a/Logic/Communications/Payload/NotificationPayload.cs b/Logic/Communications/Payload/NotificationPayload.cs
index e0cc42ab..5a1307f6 100644
--- a/Logic/Communications/Payload/NotificationPayload.cs
+++ b/Logic/Communications/Payload/NotificationPayload.cs
@@ -179,6 +179,7 @@ namespace Swarmops.Logic.Communications.Payload
Bitcoin_Shortage_Urgent,
Bitcoin_Shortage_Critical,
Bitcoin_Hotwallet_Outflow,
+ Bitcoin_PrivateKeyError,
BitcoinPayoutAddress_Set,
BitcoinPayoutAddress_Bad,
BitcoinPayoutAddress_PleaseSet,
diff --git a/Logic/Financial/Payouts.cs b/Logic/Financial/Payouts.cs
index 1c8ab9fd..c990d417 100644
--- a/Logic/Financial/Payouts.cs
+++ b/Logic/Financial/Payouts.cs
@@ -708,6 +708,14 @@ namespace Swarmops.Logic.Financial
if (!txBuilder.Verify (txReady))
{
+ // Transaction was not signed with the correct keys. This is a serious condition.
+
+ NotificationStrings primaryStrings = new NotificationStrings();
+ primaryStrings[NotificationString.OrganizationName] = organization.Name;
+
+ OutboundComm.CreateNotification (organization, NotificationResource.Bitcoin_PrivateKeyError,
+ primaryStrings);
+
throw new InvalidOperationException("Transaction is not signed enough");
}
@@ -715,10 +723,15 @@ namespace Swarmops.Logic.Financial
BitcoinUtility.BroadcastTransaction (txReady);
- // Delete inputs, adjust balance for addresses
+ // Delete all old inputs, adjust balance for addresses (re-register unused inputs)
inputs.AsUnspents.DeleteAll();
+ foreach (BitcoinTransactionInput input in inputs)
+ {
+ BitcoinUtility.TestUnspents (input.BitcoinAddress);
+ }
+
// Register new balance of change address, should have increased by (satoshisInput-satoshisUsed)
BitcoinUtility.TestUnspents (HotBitcoinAddress.OrganizationWalletZero (organization).Address);
@@ -745,7 +758,7 @@ namespace Swarmops.Logic.Financial
primaryStrings[NotificationString.EmbeddedPreformattedText] = spec;
secondaryStrings["AmountFloat"] = (nativeCentsPersonLookup[personId]/100.0).ToString ("N2");
secondaryStrings["BitcoinAmountFloat"] = (satoshiPersonLookup[personId]/100.0).ToString ("N2");
- secondaryStrings["BitcoinAddress"] = person.BitcoinPayoutAddress; // potential rare race condition
+ secondaryStrings["BitcoinAddress"] = person.BitcoinPayoutAddress; // warn: potential rare race condition here
OutboundComm.CreateNotification (organization, NotificationResource.Bitcoin_PaidOut, primaryStrings,
secondaryStrings, People.FromSingle(person));
@@ -766,7 +779,7 @@ namespace Swarmops.Logic.Financial
(new Swarmops.Logic.Financial.Money (satoshisUsed, Currency.Bitcoin).ToCurrency (
organization.Currency).Cents/100.0).ToString ("N2", CultureInfo.InvariantCulture);
masterSecondaryStrings["BitcoinAmountFloat"] = (satoshisUsed/100.0).ToString ("N2", CultureInfo.InvariantCulture);
- masterSecondaryStrings["PayoutCount"] = bitcoinPayouts.Count.ToString("N0", CultureInfo.InvariantCulture);
+ masterSecondaryStrings["PaymentCount"] = bitcoinPayouts.Count.ToString("N0", CultureInfo.InvariantCulture);
OutboundComm.CreateNotification (organization, NotificationResource.Bitcoin_Hotwallet_Outflow,
masterPrimaryStrings, masterSecondaryStrings);
@@ -774,6 +787,7 @@ namespace Swarmops.Logic.Financial
FinancialTransaction ledgerTransaction = FinancialTransaction.Create (organization, utcNow,
"Bitcoin automated payout");
ledgerTransaction.AddRow (organization.FinancialAccounts.AssetsBitcoinHot, -masterPayoutPrototype.AmountCents, null).NativeAmountCents = new Swarmops.Logic.Financial.Money(satoshisUsed, Currency.Bitcoin);
+ ledgerTransaction.BlockchainHash = txReady.GetHash().ToString(); // TODO: VERIFY THIS
masterPayout.BindToTransactionAndClose (ledgerTransaction, null);
}
diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
index f288b895..25a9e49c 100644
--- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
+++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
@@ -100,6 +100,24 @@ namespace Swarmops.Logic.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to When attempting an automated payment from the hotwallet, the private key used to sign does not match the public keys used to gather the funds necessary. This is a serious condition..
+ ///
+ internal static string Bitcoin_PrivateKeyError_Body {
+ get {
+ return ResourceManager.GetString("Bitcoin_PrivateKeyError_Body", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to [[OrganizationName] - URGENT] Bitcoin private key error; can't pay.
+ ///
+ internal static string Bitcoin_PrivateKeyError_Subject {
+ get {
+ return ResourceManager.GetString("Bitcoin_PrivateKeyError_Subject", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Swarmops is trying to make payments of [CurrencyCode] [AmountNeededFloat], but only [CurrencyCode] [AmountWalletFloat] is available in the bitcoin hotwallet. Swarmops is unable to make further payments at this time.
///
diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
index 170ecc78..760e33ac 100644
--- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
+++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
@@ -173,6 +173,12 @@ You should already see the transaction in your wallet and it should achieve spen
[[OrganizationName]] Funds paid to you: [CurrencyCode] [AmountFloat]
+
+ When attempting an automated payment from the hotwallet, the private key used to sign does not match the public keys used to gather the funds necessary. This is a serious condition.
+
+
+ [[OrganizationName] - URGENT] Bitcoin private key error; can't pay
+
Swarmops is trying to make payments of [CurrencyCode] [AmountNeededFloat], but only [CurrencyCode] [AmountWalletFloat] is available in the bitcoin hotwallet. Swarmops is unable to make further payments at this time.
diff --git a/Site5/Master-v5.master.cs b/Site5/Master-v5.master.cs
index 4beb121c..e09c6f5f 100644
--- a/Site5/Master-v5.master.cs
+++ b/Site5/Master-v5.master.cs
@@ -38,9 +38,7 @@ namespace Swarmops
// BEGIN TEST CODE
- /* string[] testStrings =
- BitcoinUtility.GetInputAddressesForTransaction (
- "206a3a272d96e9cef929f88ae690c5556cee0a1e8eaca2858f8d858ee2e2cc66");*/
+ // Payouts.PerformAutomated();
// END TEST CODE