-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding ability to set expiry when creating a new invoice #632
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, with the simplification below I think this can be merged
README.md
Outdated
@@ -138,6 +138,7 @@ java -Declair.datadir=/tmp/node1 -jar eclair-node-gui-<version>-<commit_id>.jar | |||
allupdates | nodeId | list all channels updates for this nodeId | |||
receive | description | generate a payment request without a required amount (can be useful for donations) | |||
receive | amountMsat, description | generate a payment request for a given amount | |||
receive | amountMsat, description, expiryDuration | generate a payment request for a given amount that expires after given duration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: expiryDuration
-> expirySeconds
It's less fancy but simpler
@@ -225,7 +225,10 @@ trait Service extends Logging { | |||
// the amount is now given with the description | |||
case JInt(amountMsat) :: JString(description) :: Nil => | |||
completeRpcFuture(req.id, (paymentHandler ? ReceivePayment(Some(MilliSatoshi(amountMsat.toLong)), description)).mapTo[PaymentRequest].map(PaymentRequest.write)) | |||
case _ => reject(UnknownParamsRejection(req.id, "[description] or [amount, description]")) | |||
case JInt(amountMsat) :: JString(description) :: JString(expiry) :: Nil => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if expiry is in seconds, this can be simplified
@@ -346,6 +349,7 @@ trait Service extends Logging { | |||
"allupdates: list all channels updates", | |||
"allupdates (nodeId): list all channels updates for this nodeId", | |||
"receive (amountMsat, description): generate a payment request for a given amount", | |||
"receive (amountMsat, description, duration): generate a payment request for a given amount - duration is a string like \"2 hours\" that is expiry of invoice", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: this should be the same description as in the README
@@ -182,7 +183,7 @@ object PaymentLifecycle { | |||
def props(sourceNodeId: PublicKey, router: ActorRef, register: ActorRef) = Props(classOf[PaymentLifecycle], sourceNodeId, router, register) | |||
|
|||
// @formatter:off | |||
case class ReceivePayment(amountMsat_opt: Option[MilliSatoshi], description: String) | |||
case class ReceivePayment(amountMsat_opt: Option[MilliSatoshi], description: String, expiry: Option[FiniteDuration]=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't forget to use proper formatting
Think I have fixed all the above. Was planning to just have seconds then saw the fancy code for the config and did that. Oh well... |
eclair-core/eclair-cli
Outdated
@@ -80,6 +79,8 @@ case ${METHOD}_${#} in | |||
|
|||
"receive_2") call ${METHOD} "'$(printf '[%s,"%s"]' "${1}" "${2}")'" ;; # ${1} is numeric (amount to receive) | |||
|
|||
"receive_3") call ${METHOD} "'$(printf '[%s,"%s","%s"]' "${1}" "${2}" ${3})'" ;; # ${1} is numeric (amount to receive) as is ${2} for expiry in seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there shouldn't be quotes around %s
for the expiry, as it is numeric
case _ => reject(UnknownParamsRejection(req.id, "[description] or [amount, description]")) | ||
case JInt(amountMsat) :: JString(description) :: JInt(expirySeconds) :: Nil => | ||
completeRpcFuture(req.id, (paymentHandler ? ReceivePayment(Some(MilliSatoshi(amountMsat.toLong)), description, Some(expirySeconds.toLong))).mapTo[PaymentRequest].map(PaymentRequest.write)) | ||
case r => reject(UnknownParamsRejection(req.id, "[description] or [amount, description] or [amount, description, expiryDuration] : "+r.toString())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the more complete rejection handler is not necessarily a bad idea, but that is the kind of thing that needs to be addressed everywhere properly and not in a case-by-case basis, otherwise we end up with inconsistent code.
Leaving separate commits is better, it allows to see the progress and I can always group them when reviewing. |
Add option to have 3rd parameter to receive API call so you can set the expiry.