44 "context"
55
66 "fiatjaf.com/nostr"
7+ "github.com/fatih/color"
78 "github.com/urfave/cli/v3"
89)
910
@@ -27,23 +28,35 @@ it outputs nothing if the verification is successful.`,
2728
2829 if err := json .Unmarshal ([]byte (stdinEvent ), & evt ); err != nil {
2930 ctx = lineProcessingError (ctx , "invalid event: %s" , err )
30- logverbose ("<>: invalid event.\n " , evt . ID . Hex ( ))
31+ logverbose ("%s \n " , color . RedString ( " <>: invalid event." ))
3132 continue
3233 }
3334
34- if evt .GetID () != evt .ID {
35- ctx = lineProcessingError (ctx , "invalid .id, expected %s, got %s" , evt .GetID (), evt .ID )
36- logverbose ("%s: invalid id.\n " , evt .ID .Hex ())
35+ impliedID := evt .GetID ()
36+ idsMatch := impliedID == evt .ID
37+ logverbose (
38+ "%s\n %s %s\n %s %s\n %s %s\n %s %s\n %s %s\n " ,
39+ color .CyanString ("verifying event:" ),
40+ color .BlueString (" event: " ), stdinEvent ,
41+ color .BlueString (" given id: " ), color .YellowString ("%s" , evt .ID ),
42+ color .BlueString (" serialized:" ), string (evt .Serialize ()),
43+ color .BlueString (" implied id:" ), color .YellowString ("%s" , impliedID ),
44+ color .BlueString (" ids match: " ), color .New (map [bool ]color.Attribute {true : color .FgGreen , false : color .FgRed }[idsMatch ]).Sprint (idsMatch ),
45+ )
46+
47+ if impliedID != evt .ID {
48+ ctx = lineProcessingError (ctx , "invalid .id, expected %s, got %s" , impliedID , evt .ID )
49+ logverbose ("%s\n " , color .RedString ("invalid id: %s" , evt .ID .Hex ()))
3750 continue
3851 }
3952
4053 if ! evt .VerifySignature () {
4154 ctx = lineProcessingError (ctx , "invalid signature" )
42- logverbose ("%s: invalid signature. \n " , evt .ID .Hex ())
55+ logverbose ("%s\n " , color . RedString ( " invalid signature: %s " , evt .ID .Hex () ))
4356 continue
4457 }
4558
46- logverbose ("%s: valid. \n " , evt .ID .Hex ())
59+ logverbose ("%s\n " , color . GreenString ( "valid: %s" , evt .ID .Hex () ))
4760 }
4861
4962 exitIfLineProcessingError (ctx )
0 commit comments