Skip to content

Commit e5f9727

Browse files
committed
Check transfer covenant when buying/selling
1 parent ce6fdef commit e5f9727

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

wallet/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use protocol::{bitcoin::{
2222
opcodes,
2323
taproot::{ControlBlock, TaprootBuilder},
2424
Address, ScriptBuf, XOnlyPublicKey,
25-
}, prepare::{is_magic_lock_time, TrackableOutput}, FullSpaceOut, Space};
25+
}, prepare::{is_magic_lock_time, TrackableOutput}, Covenant, FullSpaceOut, Space};
2626
use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer};
2727
use protocol::constants::{BID_PSBT_INPUT_SEQUENCE, BID_PSBT_TX_LOCK_TIME};
2828
use protocol::hasher::{KeyHasher, SpaceKey};
@@ -645,6 +645,9 @@ impl SpacesWallet {
645645
if spaceout.space.is_none() {
646646
return Err(anyhow!("No associated space"));
647647
}
648+
if !matches!(spaceout.space.as_ref().unwrap().covenant, Covenant::Transfer { ..}) {
649+
return Err(anyhow::anyhow!("Space not registered"))
650+
}
648651

649652
let recipient = Self::verify_listing_signature(&listing, outpoint, TxOut {
650653
value: spaceout.value,
@@ -706,6 +709,14 @@ impl SpacesWallet {
706709
None => return Err(anyhow::anyhow!("Space not found")),
707710
Some(outpoint) => outpoint,
708711
};
712+
let spaceout = match src.get_spaceout(&space_outpoint)? {
713+
None => return Err(anyhow::anyhow!("Space not found")),
714+
Some(spaceout) => spaceout,
715+
};
716+
if !matches!(spaceout.space.as_ref().unwrap().covenant, Covenant::Transfer { ..}) {
717+
return Err(anyhow::anyhow!("Space not registered"))
718+
}
719+
709720
let utxo = match self.internal.get_utxo(space_outpoint) {
710721
None => return Err(anyhow::anyhow!("Wallet does not own a space with outpoint {}", space_outpoint)),
711722
Some(utxo) => utxo

0 commit comments

Comments
 (0)