@@ -37,10 +37,7 @@ use spaces_client::{
3737} ;
3838use spaces_protocol:: bitcoin:: { Amount , FeeRate , OutPoint , Txid } ;
3939use spaces_wallet:: {
40- bitcoin:: secp256k1:: schnorr:: Signature ,
41- export:: WalletExport ,
42- nostr:: { NostrEvent , NostrTag } ,
43- Listing ,
40+ bitcoin:: secp256k1:: schnorr:: Signature , export:: WalletExport , nostr:: NostrEvent , Listing ,
4441} ;
4542
4643#[ derive( Parser , Debug ) ]
@@ -268,10 +265,6 @@ enum Commands {
268265 /// Path to a Nostr event json file (omit for stdin)
269266 #[ arg( short, long) ]
270267 input : Option < PathBuf > ,
271-
272- /// Include a space-tag and trust path data
273- #[ arg( short, long) ]
274- anchor : bool ,
275268 } ,
276269 /// Verify a signed Nostr event against the space's public key
277270 #[ command( name = "verifyevent" ) ]
@@ -290,9 +283,6 @@ enum Commands {
290283 space : String ,
291284 /// The DNS zone file path (omit for stdin)
292285 input : Option < PathBuf > ,
293- /// Skip including bundled Merkle proof in the event.
294- #[ arg( long) ]
295- skip_anchor : bool ,
296286 } ,
297287 /// Updates the Merkle trust path for space-anchored Nostr events
298288 #[ command( name = "refreshanchor" ) ]
@@ -439,62 +429,15 @@ impl SpaceCli {
439429 & self ,
440430 space : String ,
441431 event : NostrEvent ,
442- anchor : bool ,
443432 most_recent : bool ,
444433 ) -> Result < NostrEvent , ClientError > {
445- let mut result = self
434+ let result = self
446435 . client
447- . wallet_sign_event ( & self . wallet , & space, event)
436+ . wallet_sign_event ( & self . wallet , & space, event, Some ( most_recent ) )
448437 . await ?;
449438
450- if anchor {
451- result = self . add_anchor ( result, most_recent) . await ?
452- }
453-
454439 Ok ( result)
455440 }
456- async fn add_anchor (
457- & self ,
458- mut event : NostrEvent ,
459- most_recent : bool ,
460- ) -> Result < NostrEvent , ClientError > {
461- let space = match event. space ( ) {
462- None => {
463- return Err ( ClientError :: Custom (
464- "A space tag is required to add an anchor" . to_string ( ) ,
465- ) )
466- }
467- Some ( space) => space,
468- } ;
469-
470- let spaceout = self
471- . client
472- . get_space ( & space)
473- . await
474- . map_err ( |e| ClientError :: Custom ( e. to_string ( ) ) ) ?
475- . ok_or ( ClientError :: Custom ( format ! (
476- "Space not found \" {}\" " ,
477- space
478- ) ) ) ?;
479-
480- event. proof = Some (
481- base64:: prelude:: BASE64_STANDARD . encode (
482- self . client
483- . prove_spaceout (
484- OutPoint {
485- txid : spaceout. txid ,
486- vout : spaceout. spaceout . n as _ ,
487- } ,
488- Some ( most_recent) ,
489- )
490- . await
491- . map_err ( |e| ClientError :: Custom ( e. to_string ( ) ) ) ?
492- . proof ,
493- ) ,
494- ) ;
495-
496- Ok ( event)
497- }
498441 async fn send_request (
499442 & self ,
500443 req : Option < RpcWalletRequest > ,
@@ -893,42 +836,20 @@ async fn handle_commands(cli: &SpaceCli, command: Commands) -> Result<(), Client
893836 cli. client . verify_listing ( listing) . await ?;
894837 println ! ( "{} Listing verified" , "✓" . color( Color :: Green ) ) ;
895838 }
896- Commands :: SignEvent {
897- mut space,
898- input,
899- anchor,
900- } => {
901- let mut event = read_event ( input)
839+ Commands :: SignEvent { space, input } => {
840+ let space = normalize_space ( & space) ;
841+ let event = read_event ( input)
902842 . map_err ( |e| ClientError :: Custom ( format ! ( "input error: {}" , e. to_string( ) ) ) ) ?;
903843
904- space = normalize_space ( & space) ;
905- match event. space ( ) {
906- None if anchor => event
907- . tags
908- . insert ( 0 , NostrTag ( vec ! [ "space" . to_string( ) , space. clone( ) ] ) ) ,
909- Some ( tag) => {
910- if tag != space {
911- return Err ( ClientError :: Custom ( format ! (
912- "Expected a space tag with value '{}', got '{}'" ,
913- space, tag
914- ) ) ) ;
915- }
916- }
917- _ => { }
918- } ;
919-
920- let result = cli. sign_event ( space, event, anchor, false ) . await ?;
844+ let result = cli. sign_event ( space, event, false ) . await ?;
921845 println ! ( "{}" , serde_json:: to_string( & result) . expect( "result" ) ) ;
922846 }
923- Commands :: SignZone {
924- space,
925- input,
926- skip_anchor,
927- } => {
928- let update = encode_dns_update ( & space, input)
847+ Commands :: SignZone { space, input } => {
848+ let space = normalize_space ( & space) ;
849+ let event = encode_dns_update ( input)
929850 . map_err ( |e| ClientError :: Custom ( format ! ( "Parse error: {}" , e) ) ) ?;
930- let result = cli. sign_event ( space, update, !skip_anchor, false ) . await ?;
931851
852+ let result = cli. sign_event ( space, event, false ) . await ?;
932853 println ! ( "{}" , serde_json:: to_string( & result) . expect( "result" ) ) ;
933854 }
934855 Commands :: RefreshAnchor {
@@ -937,34 +858,31 @@ async fn handle_commands(cli: &SpaceCli, command: Commands) -> Result<(), Client
937858 } => {
938859 let event = read_event ( input)
939860 . map_err ( |e| ClientError :: Custom ( format ! ( "input error: {}" , e. to_string( ) ) ) ) ?;
940- let space = match event. space ( ) {
941- None => {
942- return Err ( ClientError :: Custom (
943- "Not a space-anchored event (no space tag)" . to_string ( ) ,
944- ) )
945- }
946- Some ( space) => space,
947- } ;
948-
949- let mut event = cli
950- . client
951- . verify_event ( & space, event)
861+ cli. client
862+ . verify_event ( event. clone ( ) )
952863 . await
953864 . map_err ( |e| ClientError :: Custom ( e. to_string ( ) ) ) ?;
954- event. proof = None ;
955- event = cli. add_anchor ( event, prefer_recent) . await ?;
956865
957- println ! ( "{}" , serde_json:: to_string( & event) . expect( "result" ) ) ;
866+ let e = event. clone ( ) ;
867+ let space = e. get_space_tag ( ) . expect ( "space tag" ) . 0 ;
868+ let result = cli
869+ . client
870+ . wallet_sign_event ( & cli. wallet , space, event, Some ( prefer_recent) )
871+ . await ?;
872+ println ! ( "{}" , serde_json:: to_string( & result) . expect( "result" ) ) ;
958873 }
959874 Commands :: VerifyEvent { space, input } => {
960875 let event = read_event ( input)
961876 . map_err ( |e| ClientError :: Custom ( format ! ( "input error: {}" , e. to_string( ) ) ) ) ?;
962- let event = cli
963- . client
964- . verify_event ( & space, event)
877+ cli. client
878+ . verify_event ( event. clone ( ) )
965879 . await
966880 . map_err ( |e| ClientError :: Custom ( e. to_string ( ) ) ) ?;
967-
881+ if event. get_space_tag ( ) . expect ( "space tag" ) . 0 != & space {
882+ return Err ( ClientError :: Custom (
883+ "Space tag does not match specified space" . to_string ( ) ,
884+ ) ) ;
885+ }
968886 println ! ( "{}" , serde_json:: to_string( & event) . expect( "result" ) ) ;
969887 }
970888 }
@@ -976,7 +894,7 @@ fn default_rpc_url(chain: &ExtendedNetwork) -> String {
976894 format ! ( "http://127.0.0.1:{}" , default_spaces_rpc_port( chain) )
977895}
978896
979- fn encode_dns_update ( space : & str , zone_file : Option < PathBuf > ) -> anyhow:: Result < NostrEvent > {
897+ fn encode_dns_update ( zone_file : Option < PathBuf > ) -> anyhow:: Result < NostrEvent > {
980898 // domain crate panics if zone doesn't end in a new line
981899 let zone = get_input ( zone_file) ? + "\n " ;
982900
@@ -1000,7 +918,7 @@ fn encode_dns_update(space: &str, zone_file: Option<PathBuf>) -> anyhow::Result<
1000918 Ok ( NostrEvent :: new (
1001919 871_222 ,
1002920 & base64:: prelude:: BASE64_STANDARD . encode ( msg. as_slice ( ) ) ,
1003- vec ! [ NostrTag ( vec! [ "space" . to_string ( ) , space . to_string ( ) ] ) ] ,
921+ vec ! [ ] ,
1004922 ) )
1005923}
1006924
0 commit comments