Skip to content

Commit

Permalink
Add silentpayments_test_outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
jlest01 committed Aug 1, 2024
1 parent 5c604b4 commit c4e3d89
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/modules/silentpayments/main_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ static int secp256k1_silentpayments_create_output_pubkey(const secp256k1_context
return ret;
}

static void print_hex(unsigned char* data, size_t size) {
size_t i;
printf("0x");
for (i = 0; i < size; i++) {
printf("%02x", data[i]);
}
printf("\n");
}

int secp256k1_silentpayments_test_outputs(
const secp256k1_context *ctx,
const secp256k1_silentpayments_recipient *recipients,
Expand All @@ -156,7 +165,9 @@ int secp256k1_silentpayments_test_outputs(
unsigned char compressed_scan_pubkey[33];
unsigned char compressed_spend_pubkey[33];
size_t len;


printf("index: %ld\n", recipients[i].index);

/* Serialize pubkey1 in a compressed form (33 bytes), should always return 1 */
len = sizeof(compressed_scan_pubkey);
ret = secp256k1_ec_pubkey_serialize(ctx, compressed_scan_pubkey, &len, &recipients[i].scan_pubkey, SECP256K1_EC_COMPRESSED);
Expand All @@ -167,6 +178,13 @@ int secp256k1_silentpayments_test_outputs(
ret = secp256k1_ec_pubkey_serialize(ctx, compressed_spend_pubkey, &len, &recipients[i].spend_pubkey, SECP256K1_EC_COMPRESSED);
/* Should be the same size as the size of the output, because we passed a 33 byte array. */
VERIFY_CHECK(len == sizeof(compressed_spend_pubkey));

printf("scan_pubkey: ");
print_hex(compressed_scan_pubkey, sizeof(compressed_scan_pubkey));

printf("spend_pubkey: ");
print_hex(compressed_spend_pubkey, sizeof(compressed_spend_pubkey));

}

return ret;
Expand Down

0 comments on commit c4e3d89

Please sign in to comment.