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

drk: fixed fee not using the correct output pubkey

skoupidi 2 лет назад
Родитель
Сommit
d12e49d6d6
4 измененных файлов с 9 добавлено и 20 удалено
  1. 1 3
      bin/drk/src/dao.rs
  2. 4 8
      bin/drk/src/money.rs
  3. 2 6
      bin/drk/src/token.rs
  4. 2 3
      bin/drk/src/transfer.rs

+ 1 - 3
bin/drk/src/dao.rs

@@ -1307,10 +1307,8 @@ impl Drk {
         tx.signatures.push(sigs);
 
         let tree = self.get_money_tree().await?;
-        let secret = self.default_secret().await?;
-        let fee_public = PublicKey::from_secret(secret);
         let (fee_call, fee_proofs, fee_secrets) =
-            self.append_fee_call(&tx, fee_public, &tree, &fee_pk, &fee_zkbin, None).await?;
+            self.append_fee_call(&tx, &tree, &fee_pk, &fee_zkbin, None).await?;
 
         // Append the fee call to the transaction
         tx_builder.append(ContractCallLeaf { call: fee_call, proofs: fee_proofs }, vec![])?;

+ 4 - 8
bin/drk/src/money.rs

@@ -435,7 +435,7 @@ impl Drk {
             Ok(r) => r,
             Err(e) => {
                 return Err(Error::RusqliteError(format!(
-                    "[get_coins] Coins retrieval failed: {e:?}"
+                    "[get_token_coins] Coins retrieval failed: {e:?}"
                 )))
             }
         };
@@ -1014,7 +1014,6 @@ impl Drk {
     pub async fn append_fee_call(
         &self,
         tx: &Transaction,
-        public_key: PublicKey,
         money_merkle_tree: &MerkleTree,
         fee_pk: &ProvingKey,
         fee_zkbin: &ZkBinary,
@@ -1046,7 +1045,7 @@ impl Drk {
         };
 
         let output = FeeCallOutput {
-            public_key,
+            public_key: PublicKey::from_secret(coin.secret),
             value: change_value,
             token_id: coin.note.token_id,
             blind: BaseBlind::random(&mut OsRng),
@@ -1169,11 +1168,8 @@ impl Drk {
         // We first have to execute the fee-less tx to gather its used gas, and then we feed
         // it into the fee-creating function.
         let tree = self.get_money_tree().await?;
-        let secret = self.default_secret().await?;
-        let fee_public = PublicKey::from_secret(secret);
-        let (fee_call, fee_proofs, fee_secrets) = self
-            .append_fee_call(tx, fee_public, &tree, &fee_pk, &fee_zkbin, Some(&spent_coins))
-            .await?;
+        let (fee_call, fee_proofs, fee_secrets) =
+            self.append_fee_call(tx, &tree, &fee_pk, &fee_zkbin, Some(&spent_coins)).await?;
 
         // Append the fee call to the transaction
         tx.calls.push(DarkLeaf { data: fee_call, parent_index: None, children_indexes: vec![] });

+ 2 - 6
bin/drk/src/token.rs

@@ -307,10 +307,8 @@ impl Drk {
         tx.signatures = vec![auth_sigs, mint_sigs];
 
         let tree = self.get_money_tree().await?;
-        let secret = self.default_secret().await?;
-        let fee_public = PublicKey::from_secret(secret);
         let (fee_call, fee_proofs, fee_secrets) =
-            self.append_fee_call(&tx, fee_public, &tree, &fee_pk, &fee_zkbin, None).await?;
+            self.append_fee_call(&tx, &tree, &fee_pk, &fee_zkbin, None).await?;
 
         // Append the fee call to the transaction
         tx_builder.append(ContractCallLeaf { call: fee_call, proofs: fee_proofs }, vec![])?;
@@ -390,10 +388,8 @@ impl Drk {
         tx.signatures.push(sigs);
 
         let tree = self.get_money_tree().await?;
-        let secret = self.default_secret().await?;
-        let fee_public = PublicKey::from_secret(secret);
         let (fee_call, fee_proofs, fee_secrets) =
-            self.append_fee_call(&tx, fee_public, &tree, &fee_pk, &fee_zkbin, None).await?;
+            self.append_fee_call(&tx, &tree, &fee_pk, &fee_zkbin, None).await?;
 
         // Append the fee call to the transaction
         tx_builder.append(ContractCallLeaf { call: fee_call, proofs: fee_proofs }, vec![])?;

+ 2 - 3
bin/drk/src/transfer.rs

@@ -143,9 +143,8 @@ impl Drk {
         let sigs = tx.create_sigs(&secrets.signature_secrets)?;
         tx.signatures.push(sigs);
 
-        let (fee_call, fee_proofs, fee_secrets) = self
-            .append_fee_call(&tx, keypair.public, &tree, &fee_pk, &fee_zkbin, Some(&spent_coins))
-            .await?;
+        let (fee_call, fee_proofs, fee_secrets) =
+            self.append_fee_call(&tx, &tree, &fee_pk, &fee_zkbin, Some(&spent_coins)).await?;
 
         // Append the fee call to the transaction
         tx_builder.append(ContractCallLeaf { call: fee_call, proofs: fee_proofs }, vec![])?;