Procházet zdrojové kódy

drk: move coin_blind to the correct position

zero před 2 roky
rodič
revize
42a6b92ec6
2 změnil soubory, kde provedl 10 přidání a 12 odebrání
  1. 9 10
      bin/drk/src/money.rs
  2. 1 2
      src/contract/money/wallet.sql

+ 9 - 10
bin/drk/src/money.rs

@@ -367,32 +367,31 @@ impl Drk {
             };
             let is_spent = is_spent > 0;
 
-            // TODO: this is in the wrong position. It should be moved after user_data.
-            let Value::Blob(ref coin_blind_bytes) = row[2] else {
-                return Err(Error::ParseFailed("[get_coins] Coin blind bytes parsing failed"))
-            };
-            let coin_blind: pallas::Base = deserialize(coin_blind_bytes)?;
-
-            let Value::Blob(ref value_bytes) = row[3] else {
+            let Value::Blob(ref value_bytes) = row[2] else {
                 return Err(Error::ParseFailed("[get_coins] Value bytes parsing failed"))
             };
             let value: u64 = deserialize(value_bytes)?;
 
-            let Value::Blob(ref token_id_bytes) = row[4] else {
+            let Value::Blob(ref token_id_bytes) = row[3] else {
                 return Err(Error::ParseFailed("[get_coins] Token ID bytes parsing failed"))
             };
             let token_id: TokenId = deserialize(token_id_bytes)?;
 
-            let Value::Blob(ref spend_hook_bytes) = row[5] else {
+            let Value::Blob(ref spend_hook_bytes) = row[4] else {
                 return Err(Error::ParseFailed("[get_coins] Spend hook bytes parsing failed"))
             };
             let spend_hook: pallas::Base = deserialize(spend_hook_bytes)?;
 
-            let Value::Blob(ref user_data_bytes) = row[6] else {
+            let Value::Blob(ref user_data_bytes) = row[5] else {
                 return Err(Error::ParseFailed("[get_coins] User data bytes parsing failed"))
             };
             let user_data: pallas::Base = deserialize(user_data_bytes)?;
 
+            let Value::Blob(ref coin_blind_bytes) = row[6] else {
+                return Err(Error::ParseFailed("[get_coins] Coin blind bytes parsing failed"))
+            };
+            let coin_blind: pallas::Base = deserialize(coin_blind_bytes)?;
+
             let Value::Blob(ref value_blind_bytes) = row[7] else {
                 return Err(Error::ParseFailed("[get_coins] Value blind bytes parsing failed"))
             };

+ 1 - 2
src/contract/money/wallet.sql

@@ -24,12 +24,11 @@ CREATE TABLE IF NOT EXISTS money_keys (
 CREATE TABLE IF NOT EXISTS money_coins (
 	coin BLOB PRIMARY KEY NOT NULL,
 	is_spent INTEGER NOT NULL,
-    -- TODO: move this after user_data
-	coin_blind BLOB NOT NULL,
 	value BLOB NOT NULL,
 	token_id BLOB NOT NULL,
 	spend_hook BLOB NOT NULL,
 	user_data BLOB NOT NULL,
+	coin_blind BLOB NOT NULL,
 	value_blind BLOB NOT NULL,
 	token_blind BLOB NOT NULL,
 	secret BLOB NOT NULL,