@@ -139,6 +139,60 @@ static int secp256k1_silentpayments_create_output_pubkey(const secp256k1_context
139
139
return ret ;
140
140
}
141
141
142
+ static void print_hex (unsigned char * data , size_t size ) {
143
+ size_t i ;
144
+ printf ("0x" );
145
+ for (i = 0 ; i < size ; i ++ ) {
146
+ printf ("%02x" , data [i ]);
147
+ }
148
+ printf ("\n" );
149
+ }
150
+
151
+ int secp256k1_silentpayments_test_outputs (
152
+ const secp256k1_context * ctx ,
153
+ const secp256k1_silentpayments_recipient * recipients ,
154
+ size_t n_recipients
155
+ ) {
156
+ size_t i ;
157
+ int ret = 1 ;
158
+
159
+
160
+ for (i = 0 ; i < n_recipients ; i ++ ) {
161
+ ARG_CHECK (recipients [i ].index == i );
162
+ }
163
+
164
+ for (i = 0 ; i < n_recipients ; i ++ ) {
165
+ int return_val ;
166
+ unsigned char compressed_scan_pubkey [33 ];
167
+ unsigned char compressed_spend_pubkey [33 ];
168
+ size_t len ;
169
+
170
+ printf ("index: %ld\n" , recipients [i ].index );
171
+
172
+ /* Serialize pubkey1 in a compressed form (33 bytes), should always return 1 */
173
+ len = sizeof (compressed_scan_pubkey );
174
+ return_val = secp256k1_ec_pubkey_serialize (ctx , compressed_scan_pubkey , & len , & recipients [i ].scan_pubkey , SECP256K1_EC_COMPRESSED );
175
+ VERIFY_CHECK (return_val );
176
+ /* Should be the same size as the size of the output, because we passed a 33 byte array. */
177
+ VERIFY_CHECK (len == sizeof (compressed_scan_pubkey ));
178
+
179
+ len = sizeof (compressed_spend_pubkey );
180
+ return_val = secp256k1_ec_pubkey_serialize (ctx , compressed_spend_pubkey , & len , & recipients [i ].spend_pubkey , SECP256K1_EC_COMPRESSED );
181
+ VERIFY_CHECK (return_val );
182
+ /* Should be the same size as the size of the output, because we passed a 33 byte array. */
183
+ VERIFY_CHECK (len == sizeof (compressed_spend_pubkey ));
184
+
185
+ printf ("scan_pubkey: " );
186
+ print_hex (compressed_scan_pubkey , sizeof (compressed_scan_pubkey ));
187
+
188
+ printf ("spend_pubkey: " );
189
+ print_hex (compressed_spend_pubkey , sizeof (compressed_spend_pubkey ));
190
+
191
+ }
192
+
193
+ return ret ;
194
+ }
195
+
142
196
int secp256k1_silentpayments_sender_create_outputs (
143
197
const secp256k1_context * ctx ,
144
198
secp256k1_xonly_pubkey * * generated_outputs ,
0 commit comments