diff --git a/Database/Configuration.cs b/Database/Configuration.cs index 1678e3d2..4b3cc64f 100644 --- a/Database/Configuration.cs +++ b/Database/Configuration.cs @@ -14,7 +14,7 @@ namespace Swarmops.Database /// public static int DbVersionExpected { - get { return 56; } + get { return 57; } } diff --git a/Database/Schemata/revisions.txt b/Database/Schemata/revisions.txt index 86936f4e..31cb62d9 100644 --- a/Database/Schemata/revisions.txt +++ b/Database/Schemata/revisions.txt @@ -53,4 +53,5 @@ 0053 - Bugfix for 0052 [RF] 0054 - Fix for Conditional-CreateUTXO procedure with fork in effect [RF] 0055 - Fix for bug introduced with 0054, hash collisions in index [RF] -0056 - Splitting a storedproc into two; debugging a weird multi-row select return [RF] \ No newline at end of file +0056 - Splitting a storedproc into two; debugging a weird multi-row select return [RF] +0057 - Bugfix for 0056: case insensitivity caused always-true comparison w/o qualifier [RF] diff --git a/Database/Schemata/upgrade-0057.sql b/Database/Schemata/upgrade-0057.sql new file mode 100644 index 00000000..d00b224e --- /dev/null +++ b/Database/Schemata/upgrade-0057.sql @@ -0,0 +1,47 @@ +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 + AND HotBitcoinAddressUnspents.HotBitcoinAddressId=hotBitcoinAddressId) = 0) + THEN + + INSERT INTO HotBitcoinAddressUnspents + (HotBitcoinAddressId,AmountSatoshis,TransactionHash,TransactionOutputIndex,ConfirmationCount) + VALUES + (hotBitcoinAddressId,amountSatoshis,transactionHash,transactionOutputIndex,confirmationCount); + + SELECT LAST_INSERT_ID() AS Identity; + + ELSE + + SELECT HotBitcoinAddressUnspents.HotBitcoinAddressUnspentId INTO unspentId + FROM HotBitcoinAddressUnspents + WHERE HotBitcoinAddressUnspents.TransactionHash=transactionHash + AND HotBitcoinAddressUnspents.TransactionOutputIndex=transactionOutputIndex + AND HotBitcoinAddressUnspents.HotBitcoinAddressId=hotBitcoinAddressId; + + UPDATE HotBitcoinAddressUnspents + SET HotBitcoinAddressUnspents.ConfirmationCount=confirmationCount + WHERE HotBitcoinAddressUnspents.HotBitcoinAddressUnspentId=unspentId; + + SELECT -unspentId AS Identity; + + END IF; + +END + diff --git a/Site/Pages/v5/Ledgers/Json-BitcoinHotwalletData.aspx.cs b/Site/Pages/v5/Ledgers/Json-BitcoinHotwalletData.aspx.cs index abe71399..8d0cd02d 100644 --- a/Site/Pages/v5/Ledgers/Json-BitcoinHotwalletData.aspx.cs +++ b/Site/Pages/v5/Ledgers/Json-BitcoinHotwalletData.aspx.cs @@ -26,8 +26,6 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers if (address.Chain == BitcoinChain.Core) { // These shouldn't exist much, so make sure that we have the equivalent Cash address registered - BitcoinUtility.TestUnspents(BitcoinChain.Cash, address.Address); - try { HotBitcoinAddress.FromAddress(BitcoinChain.Cash, address.Address);