Db0029; some fixing
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Swarmops.Database
|
||||
/// </summary>
|
||||
public static int DbVersionExpected
|
||||
{
|
||||
get { return 28; }
|
||||
get { return 29; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,4 +25,5 @@
|
||||
0025 - Bugfix for 0024 [RF]
|
||||
0026 - Added first tables, procs for hot bitcoin wallets [RF]
|
||||
0027 - Fixes and additions to HotBitcoinAddresses, -Unspents [RF]
|
||||
0028 - Bugfix for 0027 [RF]
|
||||
0028 - Bugfix for 0027 [RF]
|
||||
0029 - Added unspent satoshis to hotaddress on create unspent [RF]
|
||||
@@ -0,0 +1,56 @@
|
||||
DROP procedure IF EXISTS `CreateHotBitcoinAddressUnspentConditional`
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
CREATE PROCEDURE `CreateHotBitcoinAddressUnspentConditional` (
|
||||
IN hotBitcoinAddressId INT,
|
||||
IN amountSatoshis BIGINT,
|
||||
IN transactionHash VARCHAR(128),
|
||||
IN transactionOutputIndex INT,
|
||||
IN confirmationCount INT
|
||||
)
|
||||
BEGIN
|
||||
|
||||
DECLARE unspentId INT;
|
||||
|
||||
IF ((SELECT COUNT(*) FROM HotBitcoinAddressUnspents
|
||||
WHERE HotBitcoinAddressUnspents.TransactionHash=transactionHash
|
||||
AND HotBitcoinAddressUnspents.TransactionOutputIndex=transactionOutputIndex) = 0)
|
||||
THEN
|
||||
|
||||
INSERT INTO HotBitcoinAddressUnspents
|
||||
(HotBitcoinAddressId,AmountSatoshis,TransactionHash,TransactionOutputIndex,ConfirmationCount)
|
||||
VALUES
|
||||
(hotBitcoinAddressId,amountSatoshis,transactionHash,transactionOutputIndex,confirmationCount);
|
||||
|
||||
SELECT LAST_INSERT_ID() INTO unspentId;
|
||||
|
||||
ELSE
|
||||
|
||||
SELECT HotBitcoinAddressUnspents.HotBitcoinAddressUnspentId INTO unspentId
|
||||
FROM HotBitcoinAddressUnspents
|
||||
WHERE HotBitcoinAddressUnspents.TransactionHash=transactionHash
|
||||
AND HotBitcoinAddressUnspents.TransactionOutputIndex=transactionOutputIndex;
|
||||
|
||||
UPDATE HotBitcoinAddressUnspents
|
||||
SET HotBitcoinAddressUnspents.ConfirmationCount=confirmationCount
|
||||
WHERE HotBitcoinAddressUnspents.HotBitcoinAddressUnspentId=unspentId;
|
||||
|
||||
END IF;
|
||||
|
||||
UPDATE HotBitcoinAddresses
|
||||
INNER JOIN
|
||||
(
|
||||
SELECT HotBitcoinAddressId, SUM(AmountSatoshis) AS UnspentAmountSum
|
||||
FROM HotBitcoinAddressUnspents
|
||||
WHERE HotBitcoinAddressUnspents.HotBitcoinAddressId=hotBitcoinAddressId
|
||||
) innerSelection ON HotBitcoinAddresses.HotBitcoinAddressId =
|
||||
innerSelection.HotBitcoinAddressId
|
||||
SET HotBitcoinAddresses.BalanceSatoshis = innerSelection.UnspentAmountSum
|
||||
WHERE HotBitcoinAddresses.HotBitcoinAddressId=hotBitcoinAddressId;
|
||||
|
||||
SELECT unspentId AS Identity;
|
||||
|
||||
END
|
||||
@@ -23,7 +23,7 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
string addressString = secretKey.PubKey.GetAddress (Network.Main).ToString();
|
||||
var unspentJsonResult =
|
||||
JObject.Parse (new WebClient().DownloadString ("https://blockchain.info/unspent?active=" + addressString));
|
||||
JObject.Parse(new WebClient().DownloadString("https://blockchain.info/unspent?active=" + addressString + "&api_key=I_am_testing_the_format_please_ignore"));
|
||||
|
||||
List<Coin> coinList = new List<Coin>();
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Swarmops.Logic.Financial
|
||||
var addressInfoResult =
|
||||
JObject.Parse (
|
||||
new WebClient().DownloadString (
|
||||
"https://blockchain.info/address/" + address + "?format=json"));
|
||||
"https://blockchain.info/address/" + address + "?format=json&api_key=I_am_testing_the_format_please_ignore"));
|
||||
|
||||
if ((int) addressInfoResult["final_balance"] == 0)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
|
||||
var unspentJsonResult =
|
||||
JObject.Parse(new WebClient().DownloadString("https://blockchain.info/unspent?active=" + address)); // warn: will 500 if no unspent outpoints
|
||||
JObject.Parse(new WebClient().DownloadString("https://blockchain.info/unspent?active=" + address + "&api_key=I_am_testing_the_format_please_ignore")); // warn: will 500 if no unspent outpoints
|
||||
|
||||
foreach (var unspentJson in unspentJsonResult["unspent_outputs"])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user