Browse Source

drk: fixed erroneous eprintlns

skoupidi 2 years ago
parent
commit
4d74247c9f
7 changed files with 139 additions and 142 deletions
  1. 27 30
      bin/drk/src/dao.rs
  2. 52 52
      bin/drk/src/main.rs
  3. 21 21
      bin/drk/src/money.rs
  4. 14 14
      bin/drk/src/rpc.rs
  5. 17 17
      bin/drk/src/swap.rs
  6. 5 5
      bin/drk/src/token.rs
  7. 3 3
      bin/drk/src/transfer.rs

+ 27 - 30
bin/drk/src/dao.rs

@@ -375,10 +375,10 @@ impl Drk {
             .await
             .is_err()
         {
-            eprintln!("Initializing DAO Merkle trees");
+            println!("Initializing DAO Merkle trees");
             let tree = MerkleTree::new(100);
             self.put_dao_trees(&tree, &tree).await?;
-            eprintln!("Successfully initialized Merkle trees for the DAO contract");
+            println!("Successfully initialized Merkle trees for the DAO contract");
         }
 
         Ok(())
@@ -708,7 +708,7 @@ impl Drk {
         // Run through the transaction and see what we got:
         for (i, call) in tx.calls.iter().enumerate() {
             if call.data.contract_id == cid && call.data.data[0] == DaoFunction::Mint as u8 {
-                eprintln!("Found Dao::Mint in call {i}");
+                println!("Found Dao::Mint in call {i}");
                 let params: DaoMintParams = deserialize(&call.data.data[1..])?;
                 let tx_hash = if confirm { Some(blake3::hash(&serialize(tx))) } else { None };
                 new_dao_bullas.push((params.dao_bulla, tx_hash, i as u32));
@@ -716,7 +716,7 @@ impl Drk {
             }
 
             if call.data.contract_id == cid && call.data.data[0] == DaoFunction::Propose as u8 {
-                eprintln!("Found Dao::Propose in call {i}");
+                println!("Found Dao::Propose in call {i}");
                 let params: DaoProposeParams = deserialize(&call.data.data[1..])?;
                 let tx_hash = if confirm { Some(blake3::hash(&serialize(tx))) } else { None };
                 // We need to clone the tree here for reproducing the snapshot Merkle root
@@ -726,7 +726,7 @@ impl Drk {
             }
 
             if call.data.contract_id == cid && call.data.data[0] == DaoFunction::Vote as u8 {
-                eprintln!("Found Dao::Vote in call {i}");
+                println!("Found Dao::Vote in call {i}");
                 let params: DaoVoteParams = deserialize(&call.data.data[1..])?;
                 let tx_hash = if confirm { Some(blake3::hash(&serialize(tx))) } else { None };
                 new_dao_votes.push((params, tx_hash, i as u32));
@@ -735,7 +735,7 @@ impl Drk {
 
             if call.data.contract_id == cid && call.data.data[0] == DaoFunction::Exec as u8 {
                 // This seems to not need any special action
-                eprintln!("Found Dao::Exec in call {i}");
+                println!("Found Dao::Exec in call {i}");
                 continue
             }
         }
@@ -748,10 +748,7 @@ impl Drk {
                 daos_tree.append(MerkleNode::from(new_bulla.0.inner()));
                 for dao in daos.iter_mut() {
                     if dao.bulla() == new_bulla.0 {
-                        eprintln!(
-                            "Found minted DAO {}, noting down for wallet update",
-                            new_bulla.0
-                        );
+                        println!("Found minted DAO {}, noting down for wallet update", new_bulla.0);
                         // We have this DAO imported in our wallet. Add the metadata:
                         dao.leaf_position = daos_tree.mark();
                         dao.tx_hash = new_bulla.1;
@@ -773,7 +770,7 @@ impl Drk {
                         // ID by looking at how many proposals we already have.
                         // We also assume we don't mantain duplicate DAOs in the
                         // wallet.
-                        eprintln!("Managed to decrypt DAO proposal note");
+                        println!("Managed to decrypt DAO proposal note");
                         let daos_proposals = self.get_dao_proposals(dao.id).await?;
                         let our_prop = DaoProposal {
                             // This ID stuff is flaky.
@@ -800,7 +797,7 @@ impl Drk {
                 for dao in &daos {
                     // TODO: we shouldn't decrypt with all DAOs here
                     let note = vote.0.note.decrypt_unsafe(&dao.secret_key)?;
-                    eprintln!("Managed to decrypt DAO proposal vote note");
+                    println!("Managed to decrypt DAO proposal vote note");
                     let daos_proposals = self.get_dao_proposals(dao.id).await?;
                     let mut proposal_id = None;
 
@@ -812,7 +809,7 @@ impl Drk {
                     }
 
                     if proposal_id.is_none() {
-                        eprintln!("Warning: Decrypted DaoVoteNote but did not find proposal");
+                        println!("Warning: Decrypted DaoVoteNote but did not find proposal");
                         break
                     }
 
@@ -994,7 +991,7 @@ impl Drk {
                 )
                 .await?;
 
-            eprintln!("DAO vote added to wallet");
+            println!("DAO vote added to wallet");
         }
 
         Ok(())
@@ -1002,40 +999,40 @@ impl Drk {
 
     /// Reset the DAO Merkle trees in the wallet.
     pub async fn reset_dao_trees(&self) -> WalletDbResult<()> {
-        eprintln!("Resetting DAO Merkle trees");
+        println!("Resetting DAO Merkle trees");
         let tree = MerkleTree::new(100);
         self.put_dao_trees(&tree, &tree).await?;
-        eprintln!("Successfully reset DAO Merkle trees");
+        println!("Successfully reset DAO Merkle trees");
 
         Ok(())
     }
 
     /// Reset confirmed DAOs in the wallet.
     pub async fn reset_daos(&self) -> WalletDbResult<()> {
-        eprintln!("Resetting DAO confirmations");
+        println!("Resetting DAO confirmations");
         let daos = match self.get_daos().await {
             Ok(d) => d,
             Err(e) => {
-                eprintln!("[reset_daos] DAOs retrieval failed: {e:?}");
+                println!("[reset_daos] DAOs retrieval failed: {e:?}");
                 return Err(WalletDbError::GenericError);
             }
         };
         self.unconfirm_daos(&daos).await?;
-        eprintln!("Successfully unconfirmed DAOs");
+        println!("Successfully unconfirmed DAOs");
 
         Ok(())
     }
 
     /// Reset all DAO proposals in the wallet.
     pub async fn reset_dao_proposals(&self) -> WalletDbResult<()> {
-        eprintln!("Resetting DAO proposals");
+        println!("Resetting DAO proposals");
         let query = format!("DELETE FROM {};", *DAO_PROPOSALS_TABLE);
         self.wallet.exec_sql(&query, &[]).await
     }
 
     /// Reset all DAO votes in the wallet.
     pub async fn reset_dao_votes(&self) -> WalletDbResult<()> {
-        eprintln!("Resetting DAO votes");
+        println!("Resetting DAO votes");
         let query = format!("DELETE FROM {};", *DAO_VOTES_TABLE);
         self.wallet.exec_sql(&query, &[]).await
     }
@@ -1053,7 +1050,7 @@ impl Drk {
             ))
         }
 
-        eprintln!("Importing \"{dao_name}\" DAO into the wallet");
+        println!("Importing \"{dao_name}\" DAO into the wallet");
 
         let query = format!(
             "INSERT INTO {} ({}, {}, {}, {}, {}, {}, {}, {}) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8);",
@@ -1150,7 +1147,7 @@ impl Drk {
 
         let daos = self.get_daos().await?;
         for dao in daos {
-            eprintln!("[{}] {}", dao.id, dao.name);
+            println!("[{}] {}", dao.id, dao.name);
         }
 
         Ok(())
@@ -1160,7 +1157,7 @@ impl Drk {
     async fn dao_list_single(&self, dao_id: u64) -> Result<()> {
         let dao = self.get_dao_by_id(dao_id).await?;
 
-        eprintln!("{dao}");
+        println!("{dao}");
 
         Ok(())
     }
@@ -1367,7 +1364,7 @@ impl Drk {
 
         let dao_mint_zkbin = ZkBinary::decode(&dao_mint_zkbin.1)?;
         let dao_mint_circuit = ZkCircuit::new(empty_witnesses(&dao_mint_zkbin)?, &dao_mint_zkbin);
-        eprintln!("Creating DAO Mint proving key");
+        println!("Creating DAO Mint proving key");
         let dao_mint_pk = ProvingKey::build(dao_mint_zkbin.k, &dao_mint_circuit);
 
         let (params, proofs) =
@@ -1479,9 +1476,9 @@ impl Drk {
         let propose_main_circuit =
             ZkCircuit::new(empty_witnesses(&propose_main_zkbin)?, &propose_main_zkbin);
 
-        eprintln!("Creating Propose Burn circuit proving key");
+        println!("Creating Propose Burn circuit proving key");
         let propose_burn_pk = ProvingKey::build(propose_burn_zkbin.k, &propose_burn_circuit);
-        eprintln!("Creating Propose Main circuit proving key");
+        println!("Creating Propose Main circuit proving key");
         let propose_main_pk = ProvingKey::build(propose_main_zkbin.k, &propose_main_circuit);
 
         // Now create the parameters for the proposal tx
@@ -1569,7 +1566,7 @@ impl Drk {
             dao_merkle_root,
         };
 
-        eprintln!("Creating ZK proofs...");
+        println!("Creating ZK proofs...");
         let (params, proofs) = call.make(
             &propose_burn_zkbin,
             &propose_burn_pk,
@@ -1705,9 +1702,9 @@ impl Drk {
         let dao_vote_main_circuit =
             ZkCircuit::new(empty_witnesses(&dao_vote_main_zkbin)?, &dao_vote_main_zkbin);
 
-        eprintln!("Creating DAO Vote Burn proving key");
+        println!("Creating DAO Vote Burn proving key");
         let dao_vote_burn_pk = ProvingKey::build(dao_vote_burn_zkbin.k, &dao_vote_burn_circuit);
-        eprintln!("Creating DAO Vote Main proving key");
+        println!("Creating DAO Vote Main proving key");
         let dao_vote_main_pk = ProvingKey::build(dao_vote_main_zkbin.k, &dao_vote_main_circuit);
 
         let (params, proofs) = call.make(

+ 52 - 52
bin/drk/src/main.rs

@@ -526,13 +526,13 @@ impl Drk {
 
     /// Auxiliary function to ping configured darkfid daemon for liveness.
     async fn ping(&self) -> Result<()> {
-        eprintln!("Executing ping request to darkfid...");
+        println!("Executing ping request to darkfid...");
         let latency = Instant::now();
         let req = JsonRequest::new("ping", JsonValue::Array(vec![]));
         let rep = self.rpc_client.oneshot_request(req).await?;
         let latency = latency.elapsed();
-        eprintln!("Got reply: {rep:?}");
-        eprintln!("Latency: {latency:?}");
+        println!("Got reply: {rep:?}");
+        println!("Latency: {latency:?}");
         Ok(())
     }
 }
@@ -626,9 +626,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 }
 
                 if table.is_empty() {
-                    eprintln!("No unspent balances found");
+                    println!("No unspent balances found");
                 } else {
-                    eprintln!("{table}");
+                    println!("{table}");
                 }
 
                 return Ok(())
@@ -643,7 +643,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                     }
                 };
 
-                eprintln!("{address}");
+                println!("{address}");
 
                 return Ok(())
             }
@@ -664,9 +664,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 }
 
                 if table.is_empty() {
-                    eprintln!("No addresses found");
+                    println!("No addresses found");
                 } else {
-                    eprintln!("{table}");
+                    println!("{table}");
                 }
 
                 return Ok(())
@@ -684,7 +684,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 let v = drk.get_money_secrets().await?;
 
                 for i in v {
-                    eprintln!("{i}");
+                    println!("{i}");
                 }
 
                 return Ok(())
@@ -697,7 +697,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                     if let Ok(line) = line {
                         let bytes = bs58::decode(&line.trim()).into_vec()?;
                         let Ok(secret) = deserialize(&bytes) else {
-                            eprintln!("Warning: Failed to deserialize secret on line {i}");
+                            println!("Warning: Failed to deserialize secret on line {i}");
                             continue
                         };
                         secrets.push(secret);
@@ -713,7 +713,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 };
 
                 for key in pubkeys {
-                    eprintln!("{key}");
+                    println!("{key}");
                 }
 
                 return Ok(())
@@ -722,7 +722,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
             if tree {
                 let tree = drk.get_money_tree().await?;
 
-                eprintln!("{tree:#?}");
+                println!("{tree:#?}");
 
                 return Ok(())
             }
@@ -782,7 +782,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                     ]);
                 }
 
-                eprintln!("{table}");
+                println!("{table}");
 
                 return Ok(())
             }
@@ -967,7 +967,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 };
 
                 let encoded = bs58::encode(&serialize(&dao_params)).into_string();
-                eprintln!("{encoded}");
+                println!("{encoded}");
 
                 Ok(())
             }
@@ -977,7 +977,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 stdin().read_to_string(&mut buf)?;
                 let bytes = bs58::decode(&buf.trim()).into_vec()?;
                 let dao_params: DaoParams = deserialize(&bytes)?;
-                eprintln!("{dao_params}");
+                println!("{dao_params}");
 
                 Ok(())
             }
@@ -1052,9 +1052,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 }
 
                 if table.is_empty() {
-                    eprintln!("No unspent balances found");
+                    println!("No unspent balances found");
                 } else {
-                    eprintln!("{table}");
+                    println!("{table}");
                 }
 
                 Ok(())
@@ -1071,7 +1071,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                         exit(2);
                     }
                 };
-                eprintln!("{}", bs58::encode(&serialize(&tx)).into_string());
+                println!("{}", bs58::encode(&serialize(&tx)).into_string());
                 Ok(())
             }
 
@@ -1106,7 +1106,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                         exit(2);
                     }
                 };
-                eprintln!("{}", bs58::encode(&serialize(&tx)).into_string());
+                println!("{}", bs58::encode(&serialize(&tx)).into_string());
                 Ok(())
             }
 
@@ -1117,7 +1117,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 let proposals = drk.get_dao_proposals(dao_id).await?;
 
                 for proposal in proposals {
-                    eprintln!("[{}] {:?}", proposal.id, proposal.bulla());
+                    println!("[{}] {:?}", proposal.id, proposal.bulla());
                 }
 
                 Ok(())
@@ -1133,10 +1133,10 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                     exit(2);
                 };
 
-                eprintln!("{proposal}");
+                println!("{proposal}");
 
                 let votes = drk.get_dao_proposal_votes(proposal_id).await?;
-                eprintln!("votes:");
+                println!("votes:");
                 for vote in votes {
                     let option = if vote.vote_option { "yes" } else { "no " };
                     eprintln!("  {option} {}", vote.all_vote_value);
@@ -1171,7 +1171,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
 
                 // TODO: Write our_vote in the proposal sql.
 
-                eprintln!("{}", bs58::encode(&serialize(&tx)).into_string());
+                println!("{}", bs58::encode(&serialize(&tx)).into_string());
 
                 Ok(())
             }
@@ -1190,7 +1190,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                         exit(2);
                     }
                 };
-                eprintln!("{}", bs58::encode(&serialize(&tx)).into_string());
+                println!("{}", bs58::encode(&serialize(&tx)).into_string());
 
                 Ok(())
             }
@@ -1201,12 +1201,12 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
             stdin().read_to_string(&mut buf)?;
             let bytes = bs58::decode(&buf.trim()).into_vec()?;
             let tx: Transaction = deserialize(&bytes)?;
-            eprintln!("{tx:#?}");
+            println!("{tx:#?}");
             Ok(())
         }
 
         Subcmd::Broadcast => {
-            eprintln!("Reading transaction from stdin...");
+            println!("Reading transaction from stdin...");
             let mut buf = String::new();
             stdin().read_to_string(&mut buf)?;
             let bytes = bs58::decode(&buf.trim()).into_vec()?;
@@ -1222,7 +1222,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 }
             };
 
-            eprintln!("Transaction ID: {txid}");
+            println!("Transaction ID: {txid}");
 
             Ok(())
         }
@@ -1246,24 +1246,24 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                     .await?;
 
             if reset {
-                eprintln!("Reset requested.");
+                println!("Reset requested.");
                 if let Err(e) = drk.scan_blocks(true).await {
                     eprintln!("Failed during scanning: {e:?}");
                     exit(2);
                 }
-                eprintln!("Finished scanning blockchain");
+                println!("Finished scanning blockchain");
 
                 return Ok(())
             }
 
             if list {
-                eprintln!("List requested.");
+                println!("List requested.");
                 // TODO: implement
                 unimplemented!()
             }
 
             if let Some(c) = checkpoint {
-                eprintln!("Checkpoint requested: {c}");
+                println!("Checkpoint requested: {c}");
                 // TODO: implement
                 unimplemented!()
             }
@@ -1272,7 +1272,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 eprintln!("Failed during scanning: {e:?}");
                 exit(2);
             }
-            eprintln!("Finished scanning blockchain");
+            println!("Finished scanning blockchain");
 
             Ok(())
         }
@@ -1294,7 +1294,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 };
 
                 let Some(tx) = tx else {
-                    eprintln!("Transaction was not found");
+                    println!("Transaction was not found");
                     exit(1);
                 };
 
@@ -1302,20 +1302,20 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 assert_eq!(tx.hash()?, tx_hash);
 
                 if encode {
-                    eprintln!("{}", bs58::encode(&serialize(&tx)).into_string());
+                    println!("{}", bs58::encode(&serialize(&tx)).into_string());
                     exit(1)
                 }
 
-                eprintln!("Transaction ID: {tx_hash}");
+                println!("Transaction ID: {tx_hash}");
                 if full {
-                    eprintln!("{tx:?}");
+                    println!("{tx:?}");
                 }
 
                 Ok(())
             }
 
             ExplorerSubcmd::SimulateTx => {
-                eprintln!("Reading transaction from stdin...");
+                println!("Reading transaction from stdin...");
                 let mut buf = String::new();
                 stdin().read_to_string(&mut buf)?;
                 let bytes = bs58::decode(&buf.trim()).into_vec()?;
@@ -1333,8 +1333,8 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                     }
                 };
 
-                eprintln!("Transaction ID: {}", tx.hash()?);
-                eprintln!("State: {}", if is_valid { "valid" } else { "invalid" });
+                println!("Transaction ID: {}", tx.hash()?);
+                println!("State: {}", if is_valid { "valid" } else { "invalid" });
 
                 Ok(())
             }
@@ -1352,9 +1352,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                         exit(1)
                     }
 
-                    eprintln!("Transaction ID: {tx_hash}");
-                    eprintln!("Status: {status}");
-                    eprintln!("{tx:?}");
+                    println!("Transaction ID: {tx_hash}");
+                    println!("Status: {status}");
+                    println!("{tx:?}");
 
                     return Ok(())
                 }
@@ -1376,9 +1376,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 }
 
                 if table.is_empty() {
-                    eprintln!("No transactions found");
+                    println!("No transactions found");
                 } else {
-                    eprintln!("{table}");
+                    println!("{table}");
                 }
 
                 Ok(())
@@ -1433,9 +1433,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 }
 
                 if table.is_empty() {
-                    eprintln!("No aliases found");
+                    println!("No aliases found");
                 } else {
-                    eprintln!("{table}");
+                    println!("{table}");
                 }
 
                 Ok(())
@@ -1471,7 +1471,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 };
 
                 let token_id = TokenId::derive(mint_authority);
-                eprintln!("Successfully imported mint authority for token ID: {token_id}");
+                println!("Successfully imported mint authority for token ID: {token_id}");
 
                 Ok(())
             }
@@ -1488,7 +1488,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
 
                 // TODO: see TokenAttributes struct. I'm not sure how to restructure this rn.
                 let token_id = TokenId::derive(mint_authority);
-                eprintln!("Successfully imported mint authority for token ID: {token_id}");
+                println!("Successfully imported mint authority for token ID: {token_id}");
 
                 Ok(())
             }
@@ -1518,9 +1518,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 }
 
                 if table.is_empty() {
-                    eprintln!("No tokens found");
+                    println!("No tokens found");
                 } else {
-                    eprintln!("{table}");
+                    println!("{table}");
                 }
 
                 Ok(())
@@ -1560,7 +1560,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 //    }
                 //};
 
-                //eprintln!("{}", bs58::encode(&serialize(&tx)).into_string());
+                //println!("{}", bs58::encode(&serialize(&tx)).into_string());
 
                 //Ok(())
             }
@@ -1584,7 +1584,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 //    }
                 //};
 
-                //eprintln!("{}", bs58::encode(&serialize(&tx)).into_string());
+                //println!("{}", bs58::encode(&serialize(&tx)).into_string());
 
                 //Ok(())
             }

+ 21 - 21
bin/drk/src/money.rs

@@ -115,12 +115,12 @@ impl Drk {
         // For now, on success, we don't care what's returned, but in the future
         // we should actually check it.
         if self.get_money_tree().await.is_err() {
-            eprintln!("Initializing Money Merkle tree");
+            println!("Initializing Money Merkle tree");
             let mut tree = MerkleTree::new(100);
             tree.append(MerkleNode::from(pallas::Base::ZERO));
             let _ = tree.mark().unwrap();
             self.put_money_tree(&tree).await?;
-            eprintln!("Successfully initialized Merkle tree for the Money contract");
+            println!("Successfully initialized Merkle tree for the Money contract");
         }
 
         // We maintain the last scanned block as part of the Money contract,
@@ -141,7 +141,7 @@ impl Drk {
 
     /// Generate a new keypair and place it into the wallet.
     pub async fn money_keygen(&self) -> WalletDbResult<()> {
-        eprintln!("Generating a new keypair");
+        println!("Generating a new keypair");
 
         // TODO: We might want to have hierarchical deterministic key derivation.
         let keypair = Keypair::random(&mut OsRng);
@@ -165,8 +165,8 @@ impl Drk {
             )
             .await?;
 
-        eprintln!("New address:");
-        eprintln!("{}", keypair.public);
+        println!("New address:");
+        println!("{}", keypair.public);
 
         Ok(())
     }
@@ -326,7 +326,7 @@ impl Drk {
         for secret in secrets {
             // Check if secret already exists
             if existing_secrets.contains(&secret) {
-                eprintln!("Existing key found: {secret}");
+                println!("Existing key found: {secret}");
                 continue
             }
 
@@ -491,7 +491,7 @@ impl Drk {
 
     /// Create an alias record for provided Token ID.
     pub async fn add_alias(&self, alias: String, token_id: TokenId) -> WalletDbResult<()> {
-        eprintln!("Generating alias {alias} for Token: {token_id}");
+        println!("Generating alias {alias} for Token: {token_id}");
         let query = format!(
             "INSERT OR REPLACE INTO {} ({}, {}) VALUES (?1, ?2);",
             *MONEY_ALIASES_TABLE, MONEY_ALIASES_COL_ALIAS, MONEY_ALIASES_COL_TOKEN_ID,
@@ -561,7 +561,7 @@ impl Drk {
 
     /// Remove provided alias record from the wallet database.
     pub async fn remove_alias(&self, alias: String) -> WalletDbResult<()> {
-        eprintln!("Removing alias: {alias}");
+        println!("Removing alias: {alias}");
         let query = format!(
             "DELETE FROM {} WHERE {} = ?1;",
             *MONEY_ALIASES_TABLE, MONEY_ALIASES_COL_ALIAS,
@@ -638,7 +638,7 @@ impl Drk {
         for (i, call) in tx.calls.iter().enumerate() {
             if call.data.contract_id == cid && call.data.data[0] == MoneyFunction::PoWRewardV1 as u8
             {
-                eprintln!("Found Money::PoWRewardV1 in call {i}");
+                println!("Found Money::PoWRewardV1 in call {i}");
                 let params: MoneyPoWRewardParamsV1 = deserialize(&call.data.data[1..])?;
 
                 coins.push(params.output.coin);
@@ -649,7 +649,7 @@ impl Drk {
 
             if call.data.contract_id == cid && call.data.data[0] == MoneyFunction::TransferV1 as u8
             {
-                eprintln!("Found Money::TransferV1 in call {i}");
+                println!("Found Money::TransferV1 in call {i}");
                 let params: MoneyTransferParamsV1 = deserialize(&call.data.data[1..])?;
 
                 for input in params.inputs {
@@ -665,7 +665,7 @@ impl Drk {
             }
 
             if call.data.contract_id == cid && call.data.data[0] == MoneyFunction::OtcSwapV1 as u8 {
-                eprintln!("Found Money::OtcSwapV1 in call {i}");
+                println!("Found Money::OtcSwapV1 in call {i}");
                 let params: MoneyTransferParamsV1 = deserialize(&call.data.data[1..])?;
 
                 for input in params.inputs {
@@ -682,7 +682,7 @@ impl Drk {
 
             if call.data.contract_id == cid && call.data.data[0] == MoneyFunction::TokenMintV1 as u8
             {
-                eprintln!("Found Money::MintV1 in call {i}");
+                println!("Found Money::MintV1 in call {i}");
                 let params: MoneyTokenMintParamsV1 = deserialize(&call.data.data[1..])?;
                 coins.push(params.coin);
                 //notes.push(output.note);
@@ -692,7 +692,7 @@ impl Drk {
             if call.data.contract_id == cid &&
                 call.data.data[0] == MoneyFunction::TokenFreezeV1 as u8
             {
-                eprintln!("Found Money::FreezeV1 in call {i}");
+                println!("Found Money::FreezeV1 in call {i}");
                 let params: MoneyTokenFreezeParamsV1 = deserialize(&call.data.data[1..])?;
                 let token_id = TokenId::derive_public(params.mint_public);
                 freezes.push(token_id);
@@ -712,8 +712,8 @@ impl Drk {
             // Attempt to decrypt the note
             for secret in secrets.iter().chain(dao_secrets.iter()) {
                 if let Ok(note) = note.decrypt::<MoneyNote>(secret) {
-                    eprintln!("Successfully decrypted a Money Note");
-                    eprintln!("Witnessing coin in Merkle tree");
+                    println!("Successfully decrypted a Money Note");
+                    println!("Witnessing coin in Merkle tree");
                     let leaf_position = tree.mark().unwrap();
 
                     let owncoin =
@@ -753,9 +753,9 @@ impl Drk {
             MONEY_COINS_COL_MEMO,
         );
 
-        eprintln!("Found {} OwnCoin(s) in transaction", owncoins.len());
+        println!("Found {} OwnCoin(s) in transaction", owncoins.len());
         for owncoin in &owncoins {
-            eprintln!("OwnCoin: {:?}", owncoin.coin);
+            println!("OwnCoin: {:?}", owncoin.coin);
             let params = rusqlite::params![
                 serialize(&owncoin.coin),
                 0, // <-- is_spent
@@ -832,22 +832,22 @@ impl Drk {
 
     /// Reset the Money Merkle tree in the wallet
     pub async fn reset_money_tree(&self) -> WalletDbResult<()> {
-        eprintln!("Resetting Money Merkle tree");
+        println!("Resetting Money Merkle tree");
         let mut tree = MerkleTree::new(100);
         tree.append(MerkleNode::from(pallas::Base::ZERO));
         let _ = tree.mark().unwrap();
         self.put_money_tree(&tree).await?;
-        eprintln!("Successfully reset Money Merkle tree");
+        println!("Successfully reset Money Merkle tree");
 
         Ok(())
     }
 
     /// Reset the Money coins in the wallet
     pub async fn reset_money_coins(&self) -> WalletDbResult<()> {
-        eprintln!("Resetting coins");
+        println!("Resetting coins");
         let query = format!("DELETE FROM {};", *MONEY_COINS_TABLE);
         self.wallet.exec_sql(&query, &[]).await?;
-        eprintln!("Successfully reset coins");
+        println!("Successfully reset coins");
 
         Ok(())
     }

+ 14 - 14
bin/drk/src/rpc.rs

@@ -72,7 +72,7 @@ impl Drk {
             ))
         }
 
-        eprintln!("Subscribing to receive notifications of incoming blocks");
+        println!("Subscribing to receive notifications of incoming blocks");
         let subscriber = Subscriber::new();
         let subscription = subscriber.clone().subscribe().await;
         let _ex = ex.clone();
@@ -95,13 +95,13 @@ impl Drk {
             Error::RpcServerStopped,
             ex,
         );
-        eprintln!("Detached subscription to background");
-        eprintln!("All is good. Waiting for block notifications...");
+        println!("Detached subscription to background");
+        println!("All is good. Waiting for block notifications...");
 
         let e = loop {
             match subscription.receive().await {
                 JsonResult::Notification(n) => {
-                    eprintln!("Got Block notification from darkfid subscription");
+                    println!("Got Block notification from darkfid subscription");
                     if n.method != "blockchain.subscribe_blocks" {
                         break Error::UnexpectedJsonRpc(format!(
                             "Got foreign notification from darkfid: {}",
@@ -127,11 +127,11 @@ impl Drk {
                         let bytes = base64::decode(param).unwrap();
 
                         let block_data: BlockInfo = deserialize(&bytes)?;
-                        eprintln!("=======================================");
-                        eprintln!("Block header:\n{:#?}", block_data.header);
-                        eprintln!("=======================================");
+                        println!("=======================================");
+                        println!("Block header:\n{:#?}", block_data.header);
+                        println!("=======================================");
 
-                        eprintln!("Deserialized successfully. Scanning block...");
+                        println!("Deserialized successfully. Scanning block...");
                         if let Err(e) = self.scan_block_money(&block_data).await {
                             return Err(Error::RusqliteError(format!(
                                 "[subscribe_blocks] Scaning blocks for Money failed: {e:?}"
@@ -171,7 +171,7 @@ impl Drk {
     /// to us. If any are found, the metadata is extracted and placed into the wallet
     /// for future use.
     async fn scan_block_money(&self, block: &BlockInfo) -> Result<()> {
-        eprintln!("[Money] Iterating over {} transactions", block.txs.len());
+        println!("[Money] Iterating over {} transactions", block.txs.len());
 
         for tx in block.txs.iter() {
             self.apply_tx_money_data(tx, true).await?;
@@ -194,7 +194,7 @@ impl Drk {
     /// to us. If any are found, the metadata is extracted and placed into the wallet
     /// for future use.
     async fn scan_block_dao(&self, block: &BlockInfo) -> Result<()> {
-        eprintln!("[DAO] Iterating over {} transactions", block.txs.len());
+        println!("[DAO] Iterating over {} transactions", block.txs.len());
         for tx in block.txs.iter() {
             self.apply_tx_dao_data(tx, true).await?;
         }
@@ -236,8 +236,8 @@ impl Drk {
             };
             let last = *rep.get::<f64>().unwrap() as u64;
 
-            eprintln!("Requested to scan from block number: {height}");
-            eprintln!("Last known block number reported by darkfid: {last}");
+            println!("Requested to scan from block number: {height}");
+            println!("Last known block number reported by darkfid: {last}");
 
             // Already scanned last known block
             if height >= last {
@@ -284,7 +284,7 @@ impl Drk {
     /// Broadcast a given transaction to darkfid and forward onto the network.
     /// Returns the transaction ID upon success
     pub async fn broadcast_tx(&self, tx: &Transaction) -> Result<String> {
-        eprintln!("Broadcasting transaction...");
+        println!("Broadcasting transaction...");
 
         let params =
             JsonValue::Array(vec![JsonValue::String(bs58::encode(&serialize(tx)).into_string())]);
@@ -335,7 +335,7 @@ impl Drk {
 
     /// Try to fetch zkas bincodes for the given `ContractId`.
     pub async fn lookup_zkas(&self, contract_id: &ContractId) -> Result<Vec<(String, Vec<u8>)>> {
-        eprintln!("Querying zkas bincode for {contract_id}");
+        println!("Querying zkas bincode for {contract_id}");
 
         let params = JsonValue::Array(vec![JsonValue::String(format!("{contract_id}"))]);
         let req = JsonRequest::new("blockchain.lookup_zkas", params);

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

@@ -129,7 +129,7 @@ impl Drk {
         let token_blinds = [Blind::random(&mut OsRng), Blind::random(&mut OsRng)];
 
         // Now we should have everything we need to build the swap half
-        eprintln!("Creating Mint and Burn circuit proving keys");
+        println!("Creating Mint and Burn circuit proving keys");
         let mint_pk = ProvingKey::build(mint_zkbin.k, &mint_circuit);
         let burn_pk = ProvingKey::build(burn_zkbin.k, &burn_circuit);
         let builder = SwapCallBuilder {
@@ -151,7 +151,7 @@ impl Drk {
             burn_pk,
         };
 
-        eprintln!("Building first half of the swap transaction");
+        println!("Building first half of the swap transaction");
         let debris = builder.build()?;
 
         // Now we have the half, so we can build `PartialSwapData` and return it.
@@ -219,7 +219,7 @@ impl Drk {
         // TODO: Maybe some kind of verification at this point
 
         // Now we should have everything we need to build the swap half
-        eprintln!("Creating Mint and Burn circuit proving keys");
+        println!("Creating Mint and Burn circuit proving keys");
         let mint_pk = ProvingKey::build(mint_zkbin.k, &mint_circuit);
         let burn_pk = ProvingKey::build(burn_zkbin.k, &burn_circuit);
         let builder = SwapCallBuilder {
@@ -241,7 +241,7 @@ impl Drk {
             burn_pk,
         };
 
-        eprintln!("Building second half of the swap transaction");
+        println!("Building second half of the swap transaction");
         let debris = builder.build()?;
 
         let full_params = MoneyTransferParamsV1 {
@@ -262,7 +262,7 @@ impl Drk {
         let mut tx_builder =
             TransactionBuilder::new(ContractCallLeaf { call, proofs: full_proofs }, vec![])?;
         let mut tx = tx_builder.build()?;
-        eprintln!("Signing swap transaction");
+        println!("Signing swap transaction");
         let sigs = tx.create_sigs(&[debris.signature_secret])?;
         tx.signatures = vec![sigs];
 
@@ -303,7 +303,7 @@ impl Drk {
             }
 
             let params: MoneyTransferParamsV1 = deserialize(&tx.calls[0].data.data[1..])?;
-            eprintln!("Parameters:\n{:#?}", params);
+            println!("Parameters:\n{:#?}", params);
 
             if params.inputs.len() != 2 {
                 eprintln!("Found {} inputs, there should be 2", params.inputs.len());
@@ -322,14 +322,14 @@ impl Drk {
             let mut output_idx = 0;
 
             for output in &params.outputs {
-                eprintln!("Trying to decrypt note in output {output_idx}");
+                println!("Trying to decrypt note in output {output_idx}");
 
                 for secret in &secret_keys {
                     if let Ok(d_note) = output.note.decrypt::<MoneyNote>(secret) {
                         let s: SecretKey = deserialize(&d_note.memo)?;
                         skey = Some(s);
                         note = Some(d_note);
-                        eprintln!("Successfully decrypted and found an ephemeral secret");
+                        println!("Successfully decrypted and found an ephemeral secret");
                         break
                     }
                 }
@@ -346,12 +346,12 @@ impl Drk {
                 return insection_error
             };
 
-            eprintln!(
+            println!(
                 "Output[{output_idx}] value: {} ({})",
                 note.value,
                 encode_base10(note.value, BALANCE_BASE10_DECIMALS)
             );
-            eprintln!("Output[{output_idx}] token ID: {}", note.token_id);
+            println!("Output[{output_idx}] token ID: {}", note.token_id);
 
             let skey = skey.unwrap();
             let (pub_x, pub_y) = PublicKey::from_secret(skey).xy();
@@ -364,7 +364,7 @@ impl Drk {
             ]));
 
             if coin == params.outputs[output_idx].coin {
-                eprintln!("Output[{output_idx}] coin matches decrypted note metadata");
+                println!("Output[{output_idx}] coin matches decrypted note metadata");
             } else {
                 eprintln!("Error: Output[{output_idx}] coin does not match note metadata");
                 return insection_error
@@ -387,7 +387,7 @@ impl Drk {
                 return insection_error
             }
 
-            eprintln!("Value and token commitments match decrypted note metadata");
+            println!("Value and token commitments match decrypted note metadata");
 
             // Verify that the output commitments match the other input commitments
             match output_idx {
@@ -410,7 +410,7 @@ impl Drk {
                 _ => unreachable!(),
             }
 
-            eprintln!("Found matching pedersen commitments for outputs and inputs");
+            println!("Found matching pedersen commitments for outputs and inputs");
 
             // TODO: Verify signature
             // TODO: Verify ZK proofs
@@ -419,7 +419,7 @@ impl Drk {
 
         // Inspect PartialSwapData
         let partial = half.unwrap();
-        eprintln!("{partial}");
+        println!("{partial}");
 
         Ok(())
     }
@@ -434,13 +434,13 @@ impl Drk {
         // Our output should be outputs[0] so we try to decrypt that.
         let encrypted_note = &params.outputs[0].note;
 
-        eprintln!("Trying to decrypt note in outputs[0]");
+        println!("Trying to decrypt note in outputs[0]");
         let mut skey = None;
 
         for secret in &secret_keys {
             if let Ok(note) = encrypted_note.decrypt::<MoneyNote>(secret) {
                 let s: SecretKey = deserialize(&note.memo)?;
-                eprintln!("Successfully decrypted and found an ephemeral secret");
+                println!("Successfully decrypted and found an ephemeral secret");
                 skey = Some(s);
                 break
             }
@@ -453,7 +453,7 @@ impl Drk {
             ))
         };
 
-        eprintln!("Signing swap transaction");
+        println!("Signing swap transaction");
         let sigs = tx.create_sigs(&[skey])?;
         tx.signatures[0].insert(0, sigs[0]);
 

+ 5 - 5
bin/drk/src/token.rs

@@ -157,7 +157,7 @@ impl Drk {
             let mint_zkbin = ZkBinary::decode(&token_mint_zkbin.1)?;
             let token_mint_circuit = ZkCircuit::new(empty_witnesses(&mint_zkbin)?, &mint_zkbin);
 
-            eprintln!("Creating token mint circuit proving keys");
+            println!("Creating token mint circuit proving keys");
             let mint_pk = ProvingKey::build(mint_zkbin.k, &token_mint_circuit);
 
             (mint_zkbin, mint_pk)
@@ -174,7 +174,7 @@ impl Drk {
             let token_auth_mint_circuit =
                 ZkCircuit::new(empty_witnesses(&auth_mint_zkbin)?, &auth_mint_zkbin);
 
-            eprintln!("Creating token mint circuit proving keys");
+            println!("Creating token mint circuit proving keys");
             let auth_mint_pk = ProvingKey::build(auth_mint_zkbin.k, &token_auth_mint_circuit);
 
             (auth_mint_zkbin, auth_mint_pk)
@@ -191,7 +191,7 @@ impl Drk {
             token_mint_pk,
         };
 
-        eprintln!("Building transaction parameters");
+        println!("Building transaction parameters");
         let debris = mint_builder.build()?;
 
         // Encode and sign the transaction
@@ -295,7 +295,7 @@ impl Drk {
         let freeze_zkbin = ZkBinary::decode(&token_freeze_zkbin.1)?;
         let token_freeze_circuit = ZkCircuit::new(empty_witnesses(&freeze_zkbin)?, &freeze_zkbin);
 
-        eprintln!("Creating token freeze circuit proving keys");
+        println!("Creating token freeze circuit proving keys");
         let freeze_pk = ProvingKey::build(freeze_zkbin.k, &token_freeze_circuit);
         let freeze_builder = TokenFreezeCallBuilder {
             mint_keypair: mint_authority,
@@ -304,7 +304,7 @@ impl Drk {
             freeze_pk,
         };
 
-        eprintln!("Building transaction parameters");
+        println!("Building transaction parameters");
         let debris = freeze_builder.build()?;
 
         // Encode and sign the transaction

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

@@ -45,7 +45,7 @@ impl Drk {
         recipient: PublicKey,
     ) -> Result<Transaction> {
         // First get all unspent OwnCoins to see what our balance is.
-        eprintln!("Fetching OwnCoins");
+        println!("Fetching OwnCoins");
         let owncoins = self.get_coins(false).await?;
         let mut owncoins: Vec<OwnCoin> = owncoins.iter().map(|x| x.0.clone()).collect();
         // We're only interested in the ones for the token_id we're sending
@@ -98,11 +98,11 @@ impl Drk {
         let mint_circuit = ZkCircuit::new(empty_witnesses(&mint_zkbin)?, &mint_zkbin);
         let burn_circuit = ZkCircuit::new(empty_witnesses(&burn_zkbin)?, &burn_zkbin);
 
-        eprintln!("Creating Mint and Burn circuit proving keys");
+        println!("Creating Mint and Burn circuit proving keys");
         let mint_pk = ProvingKey::build(mint_zkbin.k, &mint_circuit);
         let burn_pk = ProvingKey::build(burn_zkbin.k, &burn_circuit);
 
-        eprintln!("Building transaction parameters");
+        println!("Building transaction parameters");
         let (params, secrets, spent_coins) = make_transfer_call(
             keypair, recipient, amount, token_id, owncoins, tree, mint_zkbin, mint_pk, burn_zkbin,
             burn_pk,