1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-23 22:46:44 +01:00

Removed PaymentRequest.MAX_AMOUNT (#1018)

It was obsole since
068b0bccf9.

Note that we use a signed long, but it doesn't matter since 2^64
milli-satoshis is greater than the total number of bitcoins.
This commit is contained in:
Pierre-Marie Padiou 2019-05-28 14:14:17 +02:00 committed by GitHub
parent b82d7211cc
commit c4b7ade038
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 11 deletions

View file

@ -41,7 +41,7 @@ import scala.util.Try
*/
case class PaymentRequest(prefix: String, amount: Option[MilliSatoshi], timestamp: Long, nodeId: PublicKey, tags: List[PaymentRequest.TaggedField], signature: ByteVector) {
amount.map(a => require(a.amount > 0 && a.amount <= PaymentRequest.MAX_AMOUNT.amount, s"amount is not valid"))
amount.map(a => require(a.amount > 0, s"amount is not valid"))
require(tags.collect { case _: PaymentRequest.PaymentHash => {} }.size == 1, "there must be exactly one payment hash tag")
require(tags.collect { case PaymentRequest.Description(_) | PaymentRequest.DescriptionHash(_) => {} }.size == 1, "there must be exactly one description tag or one description hash tag")
@ -106,9 +106,6 @@ case class PaymentRequest(prefix: String, amount: Option[MilliSatoshi], timestam
object PaymentRequest {
// https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
val MAX_AMOUNT = MilliSatoshi(4294967296L)
val prefixes = Map(
Block.RegtestGenesisBlock.hash -> "lnbcrt",
Block.TestnetGenesisBlock.hash -> "lntb",

View file

@ -105,11 +105,6 @@ class PaymentHandlerSpec extends TestKit(ActorSystem("test")) with FunSuiteLike
val zeroError = sender.expectMsgType[Failure]
assert(zeroError.cause.getMessage.contains("amount is not valid"))
// large amount should fail (> 42.95 mBTC)
sender.send(handler, ReceivePayment(Some(Satoshi(1) + PaymentRequest.MAX_AMOUNT), "1 coffee"))
val largeAmountError = sender.expectMsgType[Failure]
assert(largeAmountError.cause.getMessage.contains("amount is not valid"))
// success with 1 mBTC
sender.send(handler, ReceivePayment(Some(MilliSatoshi(100000000L)), "1 coffee"))
val pr = sender.expectMsgType[PaymentRequest]

View file

@ -73,8 +73,6 @@ class ReceivePaymentController(val handlers: Handlers, val stage: Stage) extends
Try(CoinUtils.convertStringAmountToMsat(amount.getText, unit.getValue)) match {
case Success(amountMsat) if amountMsat.amount < 0 =>
handleError("Amount must be greater than 0")
case Success(amountMsat) if amountMsat.amount >= PaymentRequest.MAX_AMOUNT.amount =>
handleError(s"Amount must be less than ${CoinUtils.formatAmountInUnit(PaymentRequest.MAX_AMOUNT, FxApp.getUnit, withUnit = true)}")
case Failure(_) =>
handleError("Amount is incorrect")
case Success(amountMsat) => createPaymentRequest(Some(amountMsat))