|
| 1 | +# BOLT #14: Authorized Payment Initiation |
| 2 | + |
| 3 | +Some use cases require the ability to directly request a payment from a specific node. This BOLT defines how such payments can be initiated using `authorized payment initiation`. |
| 4 | + |
| 5 | +`authorized payment initiation` relies on token based authorization. Any node can request a payment from another node using the `initiate_payment` message described in this BOLT and by presenting a valid authorization token. |
| 6 | + |
| 7 | + |
| 8 | +### The `initiate_payment` message |
| 9 | + |
| 10 | +An `initiate_payment` message MUST have the following format: |
| 11 | + |
| 12 | +1. type: 45001 (`initiate_payment`) |
| 13 | +1. data: |
| 14 | + * [`u16`:`tlen`] |
| 15 | + * [`tlen*byte`:`token`] |
| 16 | + * [`u16`:`ilen`] |
| 17 | + * [`ilen*byte`: `invoice`] |
| 18 | + |
| 19 | +### Requirements |
| 20 | + |
| 21 | +The sending node: |
| 22 | +* MUST set `invoice` to a valid payment request / invoice. |
| 23 | +* MUST set `token` to the received authorization token. |
| 24 | + |
| 25 | + |
| 26 | +The receiving node: |
| 27 | +* if the `invoice` is not valid according to BOLT-11 |
| 28 | + * SHOULD NOT initiate the payment. |
| 29 | + * SHOULD respond with a `reject_payment` message. |
| 30 | +* otherwise, if the `token` is valid for `invoice` |
| 31 | + * SHOULD initiate the payment. |
| 32 | +* otherwise |
| 33 | + * SHOULD NOT initiate the payment. |
| 34 | + * SHOULD respond with a `reject_payment` message. |
| 35 | + |
| 36 | +### The `reject_payment` message |
| 37 | + |
| 38 | +1. type: 45003 (`reject_payment`) |
| 39 | +1. data: |
| 40 | + * [`32*byte`:`tokenhash`] |
| 41 | + * [`u16`:`ilen`] |
| 42 | + * [`ilen*byte`: `invoice`] |
| 43 | + |
| 44 | +The sending node: |
| 45 | +* if no peer connection is established: |
| 46 | + * MUST establish a peer connection before sending. |
| 47 | + * SHOULD terminate the peer connection after sending |
| 48 | +* otherwise: |
| 49 | + * MUST use the already existing peer connection. |
| 50 | + * SHOULD NOT terminate the peer connection after sending. |
| 51 | +* MUST set `invoice` to the invoice received by the `initiate_payment` message. |
| 52 | +* MUST set `tokenhash` to the sha256 hash of the authorization token received by the `initiate_payment` message. |
| 53 | + |
| 54 | +The receiving node: |
| 55 | +* MAY retry initiating the payment using a different token. |
| 56 | + |
| 57 | +## Token Transfer using Offline Data Transmission |
| 58 | + |
| 59 | +Authorization Tokens MAY be transmitted through Offline Data Transmission according to BOLT-12 using the `payment authorization` message. |
| 60 | + |
| 61 | + |
| 62 | +The message consists of the following parts: |
| 63 | +* [`2 * byte`:`type`]: set to `0x1` |
| 64 | +* [`u16`:`ulen`]: the length of `uri` |
| 65 | +* [`ulen*byte`:`uri`]: the URI of the node where to request the payment in the format `pubkey`@`host`:`port` |
| 66 | +* [`u16`:`tlen`]: the lenght of `token` |
| 67 | +* [`tlen*byte`:`token`]: the autorization token |
| 68 | + |
| 69 | + |
| 70 | +### Requirements |
| 71 | + |
| 72 | +A message sender |
| 73 | +* MUST set `uri` to a valid node URI, specifiying the node where the payment MAY be requested. |
| 74 | +* MUST set `token` to a valid token. |
| 75 | + |
| 76 | +A message receiver |
| 77 | +* MUST know which payment the token is intended for. |
| 78 | +* MAY use the token to initiate the corresponding payment. |
| 79 | +* SHOULD request the payment from no different node than the one specified in the `uri` part. |
| 80 | + |
| 81 | + |
| 82 | +## Token Validity |
| 83 | +As the receiving node of a `initiate_payment` message is the only one which MUST be able to validate authorization tokens, their concrete characteristics is not part of this specification. Therefore, node implementations are free to choose their own way(s) on deciding whether a token is valid. For example, one could require the token to be a trusted ECC signature of the respective invoice. Another approach could be limiting the tokens usage by the invoice amount or its usage frequency. |
0 commit comments