diff --git a/devtools/bolt12-cli.c b/devtools/bolt12-cli.c index 1b7796a11..44e51017d 100644 --- a/devtools/bolt12-cli.c +++ b/devtools/bolt12-cli.c @@ -373,6 +373,12 @@ static void print_payer_key(const struct pubkey32 *payer_key, printf("\n"); } +static void print_payer_note(const char *payer_note) +{ + printf("payer_note: %.*s\n", + (int)tal_bytelen(payer_note), payer_note); +} + static void print_timestamp(u64 timestamp) { printf("timestamp: %"PRIu64" (%s)\n", @@ -535,6 +541,8 @@ int main(int argc, char *argv[]) print_chains(invreq->chains); if (must_have(invreq, payer_key)) print_payer_key(invreq->payer_key, invreq->payer_info); + if (invreq->payer_note) + print_payer_note(invreq->payer_note); if (must_have(invreq, offer_id)) print_offer_id(invreq->offer_id); if (must_have(invreq, amount)) @@ -627,6 +635,8 @@ int main(int argc, char *argv[]) print_payer_key(invoice->payer_key, invoice->payer_info); if (must_have(invoice, timestamp)) print_timestamp(*invoice->timestamp); + if (invoice->payer_note) + print_payer_note(invoice->payer_note); print_relative_expiry(invoice->timestamp, invoice->relative_expiry); if (must_have(invoice, payment_hash)) diff --git a/plugins/offers.c b/plugins/offers.c index 2eec48cf1..979265f30 100644 --- a/plugins/offers.c +++ b/plugins/offers.c @@ -533,6 +533,9 @@ static void json_add_b12_invoice(struct json_stream *js, json_add_pubkey32(js, "payer_key", invoice->payer_key); if (invoice->payer_info) json_add_hex_talarr(js, "payer_info", invoice->payer_info); + if (invoice->payer_note) + json_add_stringn(js, "payer_note", invoice->payer_note, + tal_bytelen(invoice->payer_note)); /* BOLT-offers #12: * - MUST reject the invoice if `timestamp` is not present. @@ -663,6 +666,9 @@ static void json_add_invoice_request(struct json_stream *js, } if (invreq->payer_info) json_add_hex_talarr(js, "payer_info", invreq->payer_info); + if (invreq->payer_note) + json_add_stringn(js, "payer_note", invreq->payer_note, + tal_bytelen(invreq->payer_note)); /* BOLT-offers #12: * - MUST fail the request if there is no `payer_signature` field. diff --git a/plugins/offers_invreq_hook.c b/plugins/offers_invreq_hook.c index accd400b8..db57b9621 100644 --- a/plugins/offers_invreq_hook.c +++ b/plugins/offers_invreq_hook.c @@ -819,6 +819,14 @@ static struct command_result *listoffers_done(struct command *cmd, ir->inv->payer_info = tal_dup_talarr(ir->inv, u8, ir->invreq->payer_info); + /* BOLT-offers #12: + * - MUST set (or not set) `payer_note` exactly as the invoice_request + * did, or MUST not set it. + */ + /* i.e. we don't have to do anything, but we do. */ + ir->inv->payer_note + = tal_dup_talarr(ir->inv, char, ir->invreq->payer_note); + randombytes_buf(&ir->preimage, sizeof(ir->preimage)); ir->inv->payment_hash = tal(ir->inv, struct sha256); sha256(ir->inv->payment_hash, &ir->preimage, sizeof(ir->preimage));