Skip to content

Commit

Permalink
Generate addresses using the extfvk
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Nov 2, 2023
1 parent 513db09 commit 84ab73f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/pivx_shield.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export class PIVXShield {
async getNewAddress() {
const { address, diversifier_index } = await this.callWorker(
"generate_next_shielding_payment_address",
this.extsk,
this.extfvk,
this.diversifierIndex,
this.isTestNet,
);
Expand Down
7 changes: 4 additions & 3 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ pub fn generate_default_payment_address(
// Generate the n_address-th valid payment address given the encoded extended full viewing key and a starting index
#[wasm_bindgen]
pub fn generate_next_shielding_payment_address(
enc_extsk: String,
enc_extfvk: String,
diversifier_index: &[u8],
is_testnet: bool,
) -> Result<JsValue, JsValue> {
let extsk = decode_extsk(&enc_extsk, is_testnet).map_err(|e| e.to_string())?;
let extfvk =
decode_extended_full_viewing_key(&enc_extfvk, is_testnet).map_err(|e| e.to_string())?;
let mut diversifier_index = DiversifierIndex(
diversifier_index
.try_into()
Expand All @@ -155,7 +156,7 @@ pub fn generate_next_shielding_payment_address(
diversifier_index
.increment()
.map_err(|_| "No valid indeces left")?;
let (new_index, address) = extsk
let (new_index, address) = extfvk
.to_diversifiable_full_viewing_key()
.find_address(diversifier_index)
.ok_or("No valid indeces left")?; // There are so many valid addresses this should never happen
Expand Down

0 comments on commit 84ab73f

Please sign in to comment.