Просмотр исходного кода

drk: update for changes to serial renamed to coin_blind

zero 2 лет назад
Родитель
Сommit
85cbf1f152
3 измененных файлов с 10 добавлено и 8 удалено
  1. 7 6
      bin/drk/src/money.rs
  2. 1 1
      bin/drk/src/swap.rs
  3. 2 1
      src/contract/money/wallet.sql

+ 7 - 6
bin/drk/src/money.rs

@@ -367,10 +367,11 @@ impl Drk {
             };
             };
             let is_spent = is_spent > 0;
             let is_spent = is_spent > 0;
 
 
-            let Value::Blob(ref serial_bytes) = row[2] else {
-                return Err(Error::ParseFailed("[get_coins] Serial bytes parsing failed"))
+            // 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 serial: pallas::Base = deserialize(serial_bytes)?;
+            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[3] else {
                 return Err(Error::ParseFailed("[get_coins] Value bytes parsing failed"))
                 return Err(Error::ParseFailed("[get_coins] Value bytes parsing failed"))
@@ -422,11 +423,11 @@ impl Drk {
             };
             };
 
 
             let note = MoneyNote {
             let note = MoneyNote {
-                serial,
                 value,
                 value,
                 token_id,
                 token_id,
                 spend_hook,
                 spend_hook,
                 user_data,
                 user_data,
+                coin_blind,
                 value_blind,
                 value_blind,
                 token_blind,
                 token_blind,
                 memo: memo.clone(),
                 memo: memo.clone(),
@@ -655,7 +656,7 @@ impl Drk {
                         coin,
                         coin,
                         note: note.clone(),
                         note: note.clone(),
                         secret: *secret,
                         secret: *secret,
-                        nullifier: Nullifier::from(poseidon_hash([secret.inner(), note.serial])),
+                        nullifier: Nullifier::from(poseidon_hash([secret.inner(), coin.inner()])),
                         leaf_position,
                         leaf_position,
                     };
                     };
 
 
@@ -699,7 +700,7 @@ impl Drk {
             let params = rusqlite::params![
             let params = rusqlite::params![
                 serialize(&owncoin.coin),
                 serialize(&owncoin.coin),
                 0, // <-- is_spent
                 0, // <-- is_spent
-                serialize(&owncoin.note.serial),
+                serialize(&owncoin.note.coin_blind),
                 serialize(&owncoin.note.value),
                 serialize(&owncoin.note.value),
                 serialize(&owncoin.note.token_id),
                 serialize(&owncoin.note.token_id),
                 serialize(&owncoin.note.spend_hook),
                 serialize(&owncoin.note.spend_hook),

+ 1 - 1
bin/drk/src/swap.rs

@@ -361,7 +361,7 @@ impl Drk {
                 pub_y,
                 pub_y,
                 pallas::Base::from(note.value),
                 pallas::Base::from(note.value),
                 note.token_id.inner(),
                 note.token_id.inner(),
-                note.serial,
+                note.coin_blind,
             ]));
             ]));
 
 
             if coin == params.outputs[output_idx].coin {
             if coin == params.outputs[output_idx].coin {

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

@@ -24,7 +24,8 @@ CREATE TABLE IF NOT EXISTS money_keys (
 CREATE TABLE IF NOT EXISTS money_coins (
 CREATE TABLE IF NOT EXISTS money_coins (
 	coin BLOB PRIMARY KEY NOT NULL,
 	coin BLOB PRIMARY KEY NOT NULL,
 	is_spent INTEGER NOT NULL,
 	is_spent INTEGER NOT NULL,
-	serial BLOB NOT NULL,
+    -- TODO: move this after user_data
+	coin_blind BLOB NOT NULL,
 	value BLOB NOT NULL,
 	value BLOB NOT NULL,
 	token_id BLOB NOT NULL,
 	token_id BLOB NOT NULL,
 	spend_hook BLOB NOT NULL,
 	spend_hook BLOB NOT NULL,