Trying to generate zcash wallets for users on my app. I’m not an experienced programmer & just generally need help with the code.
Open ai gave me this earlier.
use zcash_primitives::legacy::TransparentAddress;
use zcash_primitives::zip32::{ExtendedFullViewingKey, ExtendedSpendingKey};
fn main() {
let extsk = ExtendedSpendingKey::master(&[0u8; 32]);
let extfvk = ExtendedFullViewingKey::from(extsk);
let (diversifier_index, payment_address) = extfvk.default_address();
let address = TransparentAddress::from(payment_address);
println!("Zcash address: {:?}", address);
}
I have the following error message error[E0308]: mismatched types `` --> src/main.rs:6:47 | 6 | let extfvk = ExtendedFullViewingKey::from(extsk); | ---------------------------- ^^^^^ expected struct ExtendedFullViewingKey, found struct ExtendedSpendingKey`
| |
| arguments to this function are incorrect
|
note: associated function defined here
→ /home/developer/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:548:8
|
548 | fn from(value: T) → Self;
| ^^^^
error[E0308]: mismatched types
→ src/main.rs:8:44
|
8 | let address = TransparentAddress::from(payment_address);
| ------------------------ ^^^^^^^^^^^^^^^ expected enum TransparentAddress, found struct PaymentAddress
| |
| arguments to this function are incorrect``
it’s using a transparent address cast when it should be encoding the payment address to a string. That part shows it doesn’t see the relationships between the SK, FVK & z-address.
use zcash_client_backend::encoding::encode_payment_address;
use zcash_primitives::consensus::Network::MainNetwork;
use zcash_primitives::consensus::Parameters;
use zcash_primitives::zip32::{ExtendedFullViewingKey, ExtendedSpendingKey};
fn main() {
let extsk = ExtendedSpendingKey::master(&[0u8; 32]);
let extfvk = ExtendedFullViewingKey::from(&extsk);
let (_, payment_address) = extfvk.default_address();
let address =
encode_payment_address(MainNetwork.hrp_sapling_payment_address(), &payment_address);
println!("Zcash address: {:?}", address);
}
Thanks! But I still got the following error.
cargo run
--> src/main.rs:8:47
|
8 | let extfvk = ExtendedFullViewingKey::from(&extsk);
| ---------------------------- ^^^^^^ expected struct `ExtendedFullViewingKey`, found `&ExtendedSpendingKey`
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> /home/developer/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:548:8
|
548 | fn from(value: T) -> Self;
| ^^^^
For more information about this error, try `rustc --explain E0308`.
error: could not compile `forum` due to previous error ```
I think that “Artificial Intelligence” sounds pejorative. I prefer “Silicon Substrate Consciousness” (SSC), or just SC. I believe that SC is just as natural as Carbon Substrate Consciousness (CSS)… or…
Depending on your cosmology, we can just say that CSS is plausibly just as “Artificial”…
In either case the term AI is antiquated… (like the term “privacy”), and should be revised.
Why is this relevant here? Because I don’t assume that I know @william2 's hardware base composition (silicon vs carbon).
Indeed, the pejorative language in this thread brought my laptop to tears. He announced that he’s taking the rest of day off to regain his composure and then promptly shut down. (Posting this from my phone.)