Skip to content

Commit

Permalink
fix: wrong vault address paid for in vault payments
Browse files Browse the repository at this point in the history
  • Loading branch information
grumbach committed Jan 2, 2025
1 parent 6d57f27 commit 63ccf06
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
8 changes: 6 additions & 2 deletions ant-evm/src/data_payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ impl ProofOfPayment {
pub fn verify_for(&self, peer_id: PeerId) -> bool {
// make sure I am in the list of payees
if !self.payees().contains(&peer_id) {
warn!("Payment does not contain node peer id");
debug!("Payment contains peer ids: {:?}", self.payees());
debug!("Node peer id: {:?}", peer_id);
return false;
}

Expand All @@ -102,6 +105,7 @@ impl ProofOfPayment {
}
};
if !quote.check_is_signed_by_claimed_peer(peer_id) {
warn!("Payment is not signed by claimed peer");
return false;
}
}
Expand Down Expand Up @@ -186,7 +190,7 @@ impl PaymentQuote {
if let Ok(pub_key) = libp2p::identity::PublicKey::try_decode_protobuf(&self.pub_key) {
Ok(PeerId::from(pub_key.clone()))
} else {
error!("Cann't parse PublicKey from protobuf");
error!("Can't parse PublicKey from protobuf");
Err(EvmError::InvalidQuotePublicKey)
}
}
Expand All @@ -196,7 +200,7 @@ impl PaymentQuote {
let pub_key = if let Ok(pub_key) = PublicKey::try_decode_protobuf(&self.pub_key) {
pub_key
} else {
error!("Cann't parse PublicKey from protobuf");
error!("Can't parse PublicKey from protobuf");
return false;
};

Expand Down
12 changes: 2 additions & 10 deletions ant-protocol/src/storage/scratchpad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,8 @@ impl Scratchpad {
NetworkAddress::ScratchpadAddress(self.address)
}

/// Returns a VEC with the XOR name.
pub fn to_xor_name_vec(&self) -> Vec<XorName> {
[self.network_address()]
.iter()
.map(|f| XorName::from_content(f.as_bytes().as_ref()))
.collect::<Vec<XorName>>()
}

/// Returns the name.
pub fn name(&self) -> XorName {
/// Returns the xorname.
pub fn xorname(&self) -> XorName {
self.address.xorname()
}

Expand Down
2 changes: 1 addition & 1 deletion autonomi/src/client/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl Client {

let record = if is_new {
let receipt = self
.pay_for_content_addrs(scratch.to_xor_name_vec().into_iter(), payment_option)
.pay_for_content_addrs(std::iter::once(scratch.xorname()), payment_option)
.await
.inspect_err(|err| {
error!("Failed to pay for new vault at addr: {scratch_address:?} : {err}");
Expand Down
2 changes: 1 addition & 1 deletion autonomi/tests/external_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async fn external_signer_put() -> eyre::Result<()> {
assert!(is_new, "Scratchpad is not new");

let scratch_addresses = if is_new {
scratch.to_xor_name_vec()
vec![scratch.xorname()]
} else {
vec![]
};
Expand Down

0 comments on commit 63ccf06

Please sign in to comment.