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

Check transfer covenant when buying/selling #61

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use protocol::{bitcoin::{
opcodes,
taproot::{ControlBlock, TaprootBuilder},
Address, ScriptBuf, XOnlyPublicKey,
}, prepare::{is_magic_lock_time, TrackableOutput}, FullSpaceOut, Space};
}, prepare::{is_magic_lock_time, TrackableOutput}, Covenant, FullSpaceOut, Space};
use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer};
use protocol::constants::{BID_PSBT_INPUT_SEQUENCE, BID_PSBT_TX_LOCK_TIME};
use protocol::hasher::{KeyHasher, SpaceKey};
Expand Down Expand Up @@ -645,6 +645,9 @@ impl SpacesWallet {
if spaceout.space.is_none() {
return Err(anyhow!("No associated space"));
}
if !matches!(spaceout.space.as_ref().unwrap().covenant, Covenant::Transfer { ..}) {
return Err(anyhow::anyhow!("Space not registered"))
}

let recipient = Self::verify_listing_signature(&listing, outpoint, TxOut {
value: spaceout.value,
Expand Down Expand Up @@ -706,6 +709,14 @@ impl SpacesWallet {
None => return Err(anyhow::anyhow!("Space not found")),
Some(outpoint) => outpoint,
};
let spaceout = match src.get_spaceout(&space_outpoint)? {
None => return Err(anyhow::anyhow!("Space not found")),
Some(spaceout) => spaceout,
};
if !matches!(spaceout.space.as_ref().unwrap().covenant, Covenant::Transfer { ..}) {
return Err(anyhow::anyhow!("Space not registered"))
}

let utxo = match self.internal.get_utxo(space_outpoint) {
None => return Err(anyhow::anyhow!("Wallet does not own a space with outpoint {}", space_outpoint)),
Some(utxo) => utxo
Expand Down
Loading