@ -13,12 +13,12 @@ extension SnodeAPI {
// /
// /
// / * * N o t e : * * I f o m i t t e d w h e n s e n d i n g t h e r e q u e s t , m e s s a g e s a r e d e l e t e d f r o m t h e d e f a u l t n a m e s p a c e
// / * * N o t e : * * I f o m i t t e d w h e n s e n d i n g t h e r e q u e s t , m e s s a g e s a r e d e l e t e d f r o m t h e d e f a u l t n a m e s p a c e
// / o n l y ( n a m e s p a c e 0 )
// / o n l y ( n a m e s p a c e 0 )
let namespace : SnodeAPI . Namespace ?
let namespace : SnodeAPI . Namespace
// MARK: - I n i t
// MARK: - I n i t
public init (
public init (
namespace : SnodeAPI . Namespace ? ,
namespace : SnodeAPI . Namespace ,
pubkey : String ,
pubkey : String ,
timestampMs : UInt64 ,
timestampMs : UInt64 ,
ed25519PublicKey : [ UInt8 ] ,
ed25519PublicKey : [ UInt8 ] ,
@ -39,11 +39,10 @@ extension SnodeAPI {
override public func encode ( to encoder : Encoder ) throws {
override public func encode ( to encoder : Encoder ) throws {
var container : KeyedEncodingContainer < CodingKeys > = encoder . container ( keyedBy : CodingKeys . self )
var container : KeyedEncodingContainer < CodingKeys > = encoder . container ( keyedBy : CodingKeys . self )
// I f n o n a m e s p a c e i s s p e c i f i e d i t d e f a u l t s t o t h e d e f a u l t n a m e s p a c e o n l y ( n a m e s p a c e
// T h e ' a l l ' n a m e s p a c e s h o u l d b e s e n t t h r o u g h a s ` a l l ` i n s t e a d o f a n u m e r i c a l v a l u e
// 0 ) , s o i n s t e a d i n t h i s c a s e w e w a n t t o e x p l i c i t l y d e l e t e f r o m ` a l l ` n a m e s p a c e s
switch namespace {
switch namespace {
case . some( let namespace ) : try container . encode ( namespace , forKey : . namespace )
case . all : try container . encode ( namespace . verificationString , forKey : . namespace )
case . none : try container . encode ( " all " , forKey : . namespace )
default: try container . encode ( namespace , forKey : . namespace )
}
}
try super . encode ( to : encoder )
try super . encode ( to : encoder )
@ -58,12 +57,7 @@ extension SnodeAPI {
// / T h e s i g n a t u r e m u s t b e s i g n e d b y t h e e d 2 5 5 1 9 p u b k e y i n ` p u b k e y ` ( o m i t t i n g t h e l e a d i n g p r e f i x ) .
// / T h e s i g n a t u r e m u s t b e s i g n e d b y t h e e d 2 5 5 1 9 p u b k e y i n ` p u b k e y ` ( o m i t t i n g t h e l e a d i n g p r e f i x ) .
// / M u s t b e b a s e 6 4 e n c o d e d f o r j s o n r e q u e s t s ; b i n a r y f o r O M Q r e q u e s t s .
// / M u s t b e b a s e 6 4 e n c o d e d f o r j s o n r e q u e s t s ; b i n a r y f o r O M Q r e q u e s t s .
let verificationBytes : [ UInt8 ] = SnodeAPI . Endpoint . deleteAll . rawValue . bytes
let verificationBytes : [ UInt8 ] = SnodeAPI . Endpoint . deleteAll . rawValue . bytes
. appending (
. appending ( contentsOf : namespace . verificationString . bytes )
contentsOf : ( namespace = = nil ?
" all " :
namespace ? . verificationString
) ? . bytes
)
. appending ( contentsOf : timestampMs . map { " \( $0 ) " } ? . data ( using : . ascii ) ? . bytes )
. appending ( contentsOf : timestampMs . map { " \( $0 ) " } ? . data ( using : . ascii ) ? . bytes )
guard
guard