You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When accessing the ledger data using the get_utxos_by_stake function I'm getting inconsistent results. When investigation the issue we came to the realization that this has to do with the way that the indexes are created when extracting the stake part of the addresses.
This address (addr_test1xznnmfk43w5cag3m7e9nnfe0wcsg5lx8afv4u9utjk3zxv88r4lf2ucjd6gahe9xvre2pd6rq9jt38yve8fcjpz7g7gsxhngng) has the following stake address: stake_test17rn36l54wvfxaywmujnxpu4qkapsze9cnjxvn5ufq30y0yggrutfp.
The code used to extract the stake part of the address is the following:
fnsplit_address(utxo:&MultiEraOutput) -> Result<SplitAddressResult,Error>{// The third part of the result corresponds to the bytes used for the stake address index.use pallas::ledger::addresses::Address;match utxo.address(){Ok(address) => match&address {Address::Shelley(x) => {let a = x.to_vec();let b = x.payment().to_vec();let c = x.delegation().to_vec();Ok(SplitAddressResult(Some(a),Some(b),Some(c)))}Address::Stake(x) => {let a = x.to_vec();let c = x.to_vec();Ok(SplitAddressResult(Some(a),None,Some(c)))}Address::Byron(x) => {let a = x.to_vec();Ok(SplitAddressResult(Some(a),None,None))}},Err(err) => Err(err.into()),}}
Extracting the relevant part of this code into a snippet, we can check the following:
use pallas::ledger::addresses::Address;fnmain(){let address = "addr_test1xznnmfk43w5cag3m7e9nnfe0wcsg5lx8afv4u9utjk3zxv88r4lf2ucjd6gahe9xvre2pd6rq9jt38yve8fcjpz7g7gsxhngng";let stake = "stake_test17rn36l54wvfxaywmujnxpu4qkapsze9cnjxvn5ufq30y0yggrutfp";// The first one is a Shelley address, so I extract the delegation partlet address_bytes = matchAddress::from_bech32(address).unwrap(){Address::Shelley(x) => x.delegation().to_vec(),
_ => None.expect("Unexpected"),};// The second one is a stake address, so I just take the bytes.let stake_bytes = matchAddress::from_bech32(stake).unwrap(){Address::Stake(x) => x.to_vec(),
_ => None.expect("Unexpected"),};println!("Stake part extracted from shelley address: {:?}",
address_bytes
);println!("Stake part extracted from stake address: {:?}", stake_bytes);}
When accessing the ledger data using the
get_utxos_by_stake
function I'm getting inconsistent results. When investigation the issue we came to the realization that this has to do with the way that the indexes are created when extracting the stake part of the addresses.This address (
addr_test1xznnmfk43w5cag3m7e9nnfe0wcsg5lx8afv4u9utjk3zxv88r4lf2ucjd6gahe9xvre2pd6rq9jt38yve8fcjpz7g7gsxhngng
) has the following stake address:stake_test17rn36l54wvfxaywmujnxpu4qkapsze9cnjxvn5ufq30y0yggrutfp
.The code used to extract the stake part of the address is the following:
Extracting the relevant part of this code into a snippet, we can check the following:
Output:
Something to note is that they are the same, except for a leading byte in the case of the stake part as extracted from the stake address.
The text was updated successfully, but these errors were encountered: