Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shielded-pool(ics20): process truncated addresses in packet data #4962

Merged
merged 8 commits into from
Dec 16, 2024
Merged
16 changes: 12 additions & 4 deletions crates/bin/pcli/src/command/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,18 @@ impl TxCmd {
} => {
let destination_chain_address = to;

let (ephemeral_return_address, _) = app
.config
.full_viewing_key
.ephemeral_address(OsRng, AddressIndex::from(*source));
let ephemeral_return_address = if *use_transparent_address {
let ivk = app.config.full_viewing_key.incoming();

ivk.transparent_address()
.parse::<Address>()
.expect("we round-trip from a valid transparent address")
} else {
app.config
.full_viewing_key
.ephemeral_address(OsRng, AddressIndex::from(*source))
.0
};

let timeout_height = match timeout_height {
Some(h) => h.clone(),
Expand Down
11 changes: 8 additions & 3 deletions crates/core/component/shielded-pool/src/ics20_withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,14 @@ impl TryFrom<pb::Ics20Withdrawal> for Ics20Withdrawal {

impl From<Ics20Withdrawal> for pb::FungibleTokenPacketData {
fn from(w: Ics20Withdrawal) -> Self {
let return_address = match w.use_compat_address {
true => w.return_address.compat_encoding(),
false => w.return_address.to_string(),
let ordinary_return_address = w.return_address.to_string();

let return_address = if w.use_transparent_address {
w.return_address
.encode_as_transparent_address()
.unwrap_or_else(|| ordinary_return_address)
} else {
ordinary_return_address
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this removed compat support in the protocol.

};

pb::FungibleTokenPacketData {
Expand Down
3 changes: 3 additions & 0 deletions crates/core/transaction/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,14 @@ mod test {

#[cfg(test)]
fn dummy_spend() -> spend::Spend {
use penumbra_shielded_pool::EncryptedBackref;

spend::Spend {
body: spend::Body {
balance_commitment: dummy_commitment(),
nullifier: Nullifier(Fq::default()),
rk: dummy_pk(),
encrypted_backref: EncryptedBackref::dummy(),
},
auth_sig: dummy_sig(),
proof: dummy_proof_spend(),
Expand Down
Loading