Skip to content
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

PaymentRequest are generated in LocalPaymentHandler #63

Merged
merged 6 commits into from
Apr 11, 2017
Merged

Conversation

dpad85
Copy link
Member

@dpad85 dpad85 commented Apr 10, 2017

  • LocalPaymentHandler needs NodeParams when created to access the node pubkey
  • Added a NewPaymentRequest message in LocalPaymentHandler. Amount is
    checked and if the amount is not valid a failure is sent
  • Added a genPaymentRequest service
  • PaymentRequest in the GUI are now generated by the payment handler

@@ -93,6 +94,8 @@ trait Service extends Logging {
(router ? 'nodes).mapTo[Iterable[NodeAnnouncement]].map(_.map(_.nodeId))
case JsonRPCBody(_, _, "genh", _) =>
(paymentHandler ? 'genh).mapTo[BinaryData]
case JsonRPCBody(_,_, "genPaymentRequest", JInt(amountMsat) :: Nil) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer receive instead of genPaymentRequest

def getPaymentRequest(amountMsat: Long, textarea: TextArea) = {
(paymentHandler ? 'genh).mapTo[BinaryData].map { h =>
Platform.runLater(new Runnable() {
def getPaymentRequest(amountMsat: MilliSatoshi, textarea: TextArea) = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPaymentRequest -> receive would be more consistent with the send counterpart

case NewPaymentRequest(amount) if amount.amount > 0 && amount.amount < 4294967295L =>
val r = generateR
val h: BinaryData = Crypto.sha256(r)
val pr = s"${nodeParams.privateKey.publicKey}:${amount.amount}:${h.toString}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please isolate this in a static method of object LocalPaymentHandler for better testability.


object LocalPaymentHandler {
def props(nodeParams: NodeParams) = Props(new LocalPaymentHandler(nodeParams))
case class NewPaymentRequest(amountMsat: MilliSatoshi)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For more consistency:

  • NewPaymentRequest -> ReceivePayment
  • CreatePayment -> SendPayment

@dpad85
Copy link
Member Author

dpad85 commented Apr 11, 2017

PR Updated with proposed changes.

* LocalPaymentHandler needs NodeParams when created to access the node pubkey
* Added a NewPaymentRequest message in LocalPaymentHandler. Amount is
  checked and if the amount is not valid a failure is sent
* Added a genPaymentRequest service
* PaymentRequest in the GUI are now generated by the payment handler
* filling the payment request field in the modal is now handled by the
  controller
@pm47 pm47 merged commit 3f40402 into master Apr 11, 2017
@pm47 pm47 deleted the wip-paymentrequest branch April 11, 2017 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants