@@ -37,10 +37,7 @@ use spaces_client::{
37
37
} ;
38
38
use spaces_protocol:: bitcoin:: { Amount , FeeRate , OutPoint , Txid } ;
39
39
use 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 ,
44
41
} ;
45
42
46
43
#[ derive( Parser , Debug ) ]
@@ -268,10 +265,6 @@ enum Commands {
268
265
/// Path to a Nostr event json file (omit for stdin)
269
266
#[ arg( short, long) ]
270
267
input : Option < PathBuf > ,
271
-
272
- /// Include a space-tag and trust path data
273
- #[ arg( short, long) ]
274
- anchor : bool ,
275
268
} ,
276
269
/// Verify a signed Nostr event against the space's public key
277
270
#[ command( name = "verifyevent" ) ]
@@ -290,9 +283,6 @@ enum Commands {
290
283
space : String ,
291
284
/// The DNS zone file path (omit for stdin)
292
285
input : Option < PathBuf > ,
293
- /// Skip including bundled Merkle proof in the event.
294
- #[ arg( long) ]
295
- skip_anchor : bool ,
296
286
} ,
297
287
/// Updates the Merkle trust path for space-anchored Nostr events
298
288
#[ command( name = "refreshanchor" ) ]
@@ -439,62 +429,15 @@ impl SpaceCli {
439
429
& self ,
440
430
space : String ,
441
431
event : NostrEvent ,
442
- anchor : bool ,
443
432
most_recent : bool ,
444
433
) -> Result < NostrEvent , ClientError > {
445
- let mut result = self
434
+ let result = self
446
435
. client
447
- . wallet_sign_event ( & self . wallet , & space, event)
436
+ . wallet_sign_event ( & self . wallet , & space, event, Some ( most_recent ) )
448
437
. await ?;
449
438
450
- if anchor {
451
- result = self . add_anchor ( result, most_recent) . await ?
452
- }
453
-
454
439
Ok ( result)
455
440
}
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
- }
498
441
async fn send_request (
499
442
& self ,
500
443
req : Option < RpcWalletRequest > ,
@@ -893,42 +836,20 @@ async fn handle_commands(cli: &SpaceCli, command: Commands) -> Result<(), Client
893
836
cli. client . verify_listing ( listing) . await ?;
894
837
println ! ( "{} Listing verified" , "✓" . color( Color :: Green ) ) ;
895
838
}
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)
902
842
. map_err ( |e| ClientError :: Custom ( format ! ( "input error: {}" , e. to_string( ) ) ) ) ?;
903
843
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 ?;
921
845
println ! ( "{}" , serde_json:: to_string( & result) . expect( "result" ) ) ;
922
846
}
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)
929
850
. map_err ( |e| ClientError :: Custom ( format ! ( "Parse error: {}" , e) ) ) ?;
930
- let result = cli. sign_event ( space, update, !skip_anchor, false ) . await ?;
931
851
852
+ let result = cli. sign_event ( space, event, false ) . await ?;
932
853
println ! ( "{}" , serde_json:: to_string( & result) . expect( "result" ) ) ;
933
854
}
934
855
Commands :: RefreshAnchor {
@@ -937,34 +858,31 @@ async fn handle_commands(cli: &SpaceCli, command: Commands) -> Result<(), Client
937
858
} => {
938
859
let event = read_event ( input)
939
860
. 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 ( ) )
952
863
. await
953
864
. map_err ( |e| ClientError :: Custom ( e. to_string ( ) ) ) ?;
954
- event. proof = None ;
955
- event = cli. add_anchor ( event, prefer_recent) . await ?;
956
865
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" ) ) ;
958
873
}
959
874
Commands :: VerifyEvent { space, input } => {
960
875
let event = read_event ( input)
961
876
. 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 ( ) )
965
879
. await
966
880
. 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
+ }
968
886
println ! ( "{}" , serde_json:: to_string( & event) . expect( "result" ) ) ;
969
887
}
970
888
}
@@ -976,7 +894,7 @@ fn default_rpc_url(chain: &ExtendedNetwork) -> String {
976
894
format ! ( "http://127.0.0.1:{}" , default_spaces_rpc_port( chain) )
977
895
}
978
896
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 > {
980
898
// domain crate panics if zone doesn't end in a new line
981
899
let zone = get_input ( zone_file) ? + "\n " ;
982
900
@@ -1000,7 +918,7 @@ fn encode_dns_update(space: &str, zone_file: Option<PathBuf>) -> anyhow::Result<
1000
918
Ok ( NostrEvent :: new (
1001
919
871_222 ,
1002
920
& base64:: prelude:: BASE64_STANDARD . encode ( msg. as_slice ( ) ) ,
1003
- vec ! [ NostrTag ( vec! [ "space" . to_string ( ) , space . to_string ( ) ] ) ] ,
921
+ vec ! [ ] ,
1004
922
) )
1005
923
}
1006
924
0 commit comments