mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-18 21:34:39 +01:00
Check lnurl pay invoice description hash (#4931)
This commit is contained in:
parent
48a2a8f5e6
commit
ffee1a804e
@ -30,6 +30,7 @@ class LnURLClientTest extends BitcoinSAsyncTest {
|
||||
val amt = pay.minSendable.toLnCurrencyUnit
|
||||
client.getInvoice(pay, amt).map { inv =>
|
||||
assert(inv.amount.contains(amt))
|
||||
assert(inv.lnTags.descriptionHash.exists(_.hash == pay.metadataHash))
|
||||
}
|
||||
case _: LnURLWithdrawResponse =>
|
||||
fail("Incorrect response parsed")
|
||||
|
@ -6,6 +6,8 @@ import play.api.libs.json._
|
||||
import org.bitcoins.commons.serializers.JsonReaders._
|
||||
import org.bitcoins.commons.serializers.JsonWriters._
|
||||
import org.bitcoins.core.protocol.ln.LnInvoice
|
||||
import org.bitcoins.crypto._
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
import java.net._
|
||||
|
||||
@ -48,6 +50,9 @@ object LnURLJsonModels {
|
||||
extends LnURLResponse {
|
||||
override val tag: LnURLTag = PayRequest
|
||||
lazy val metadataJs: JsValue = Json.parse(metadata)
|
||||
|
||||
lazy val metadataHash: Sha256Digest =
|
||||
CryptoUtil.sha256(ByteVector(metadata.getBytes))
|
||||
}
|
||||
|
||||
implicit val LnURLPayResponseReads: Reads[LnURLPayResponse] =
|
||||
|
Loading…
Reference in New Issue
Block a user