Addition of API calls checkinvoice and findroute#475
Conversation
|
fixed bug in help docs and squashed commits. |
There was a problem hiding this comment.
We should reject the method if the paymentRequest argument is missing, with something like:
case _ => reject(UnknownParamsRejection(req.id, "[payment_request]"))
There was a problem hiding this comment.
Same as checkinvoice, the method should be rejected if the paymentRequest argument is missing
There was a problem hiding this comment.
An amount is not required for a payment request (donation cases) and is not needed to find a route
There was a problem hiding this comment.
Arh - was hoping check route also checked the route had enough funds. Guess it does not.
Fixed
|
Great stuff, thanks for the PR! I noticed that the failures field in the {
"paymentHash": "ff75b8778563b85d525569a8259862ee9bc50ea7b5d781015dd957c17eaca496",
"failures": [
{
"t": {}
}
]
}This can be fixed with a ThrowableSerializer, something like: class ThrowableSerializer extends CustomSerializer[Throwable](format => ({ null }, {
case t: Throwable if t.getMessage != null => JString(t.getMessage)
case t: Throwable => JString(t.getClass.getSimpleName)
}))which then gives Could you add it to the |
There was a problem hiding this comment.
I understand the use case for checkinvoice, although I'm not sure just printing out the payment request will help, because there are usually a lot of zeroes. FWIW, the human-readable part of the payment request was designed to do just that, even if it is arguably difficult to read.
I think having a checkroute (or maybe findroute) method is nice, but you don't need to go through PaymentLifecycle (which role is to manage payment failures), instead just query the router directly, like allnodes/allchannels/allupdates do: send a RouteRequest and you'll get a RouteResponse.
edit: I also think this findroute method should take either a nodeid or a payment request as input.
There was a problem hiding this comment.
nitpick: remove unnecessary braces around completeRpc
There was a problem hiding this comment.
Arh - using the router is much simpler! Updated.
Use-case for both these is another app using the API - in checkinvoice case is to check amount is what we are expecting - before paying with send. So zeros fine.
|
Do you mind if I push 1 or 2 commits on your branch to fix some indentation issues? I also would like to add a serializer for the object returned by the {
"hops": "node1 -> node2 -> node3"
"channels": "shortid1 -> shortid2"
} |
|
@dpad85 - sure change however you want. Just want to be able to identify if there is a route, and get from the invoice the amount. |
|
rebased.. any chance of getting this merged as have some other api changes to come. |
…ll. Updated after review comments.
pm47
left a comment
There was a problem hiding this comment.
I left a few nitpick comments, please use proper identation and formatting (Ctrl+Shift+L on IntelliJ)
Also, please merge against master as there has been conflicting changes.
Thanks!
| case "checkinvoice" => req.params match { | ||
| case JString(paymentRequest) :: Nil => Try(PaymentRequest.read(paymentRequest)) match { | ||
| case Success(pr) => { | ||
| completeRpc(req.id,pr) |
There was a problem hiding this comment.
superfluous { } around completeRpc(req.id,pr)
| case JString(nodeId) :: Nil if nodeId.length()==66 => | ||
| Try(PublicKey(nodeId)) match { | ||
| case Success(pk) => completeRpcFuture(req.id, (router ? RouteRequest(appKit.nodeParams.nodeId, pk) ).mapTo[RouteResponse] ) | ||
| case (Failure(_)) => reject(RpcValidationRejection(req.id, s"invalid nodeId hash: '$nodeId'")) |
| } | ||
|
|
||
| case JString(paymentRequest) :: Nil => Try(PaymentRequest.read(paymentRequest)) match { | ||
| case pr@Success(PaymentRequest(_,_,_,_,_,_)) => |
There was a problem hiding this comment.
use case Success(pr: PaymentRequest) => instead
|
@pm47 can you update your review with the latest commits? |
pm47
left a comment
There was a problem hiding this comment.
API doc needs to be updated in README.md
|
Updated README - sorry about commit message - thought I changed that before I pushed?? |
|
annoying timeouts... can we add akka.test.timefactor=10 or something? As expecting to use travis as a performance tester is not a good idea? |
checkinvoice parses an invoice/PaymentRequest and returns the JSON object. Usecase is that you need to be 100% sure that Eclair is paying the amount you expect! Easy to be factor of 1000 out if someone has a bug!
checkroute takes an invoice and checks if we have a route to pay at that moment. Is useful when you do not want to accept a request for payment you know you can not make.
Includes tests for checkroute.