Description
Background
I am creating an asset invoice using tapchannelrpc.AddInvoice
where the AddInvoiceRequest
passed in uses a lnrpc.Invoice
in the InvoiceRequest
field that contains RouteHints
. In these route hints I have 1 hop hint which contains the NodeId
of a direct peer and a ChanId
with a value that came from a PeerAcceptedBuyQuote
where I grabbed its Scid
value. This AddInvoice
calls fails with:
rpc error: code = Unknown desc = unexpected HTTP status code received from server: 500 (Internal Server Error); transport: received unexpected content-type "text/plain; charset=utf-8
and the node crashes.
Here are logs I was able to gather of the runtime error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x20f7258]
goroutine 599249 [running]:
github.com/lightninglabs/taproot-assets.validateInvoiceAmount(0x0, 0x125116e3, 0x4014897240?)
github.com/lightninglabs/[email protected]/rpcserver.go:8344 +0x98
github.com/lightninglabs/taproot-assets.(*rpcServer).AddInvoice(0x4003231080, {0x43764b8, 0x4008657200}, 0x4014550c60)
github.com/lightninglabs/[email protected]/rpcserver.go:8156 +0x870
github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc._TaprootAssetChannels_AddInvoice_Handler.func1({0x43764b8?, 0x4008657200?}, {0x2b36140?, 0x4014550c60?})
github.com/lightninglabs/taproot-assets/[email protected]/tapchannelrpc/tapchannel_grpc.pb.go:264 +0xd0
github.com/lightningnetwork/lnd/rpcperms.(*InterceptorChain).CreateServerOpts.(*InterceptorChain).middlewareUnaryServerInterceptor.func7({0x43764b8, 0x4008657200}, {0x2b36140, 0x4014550c60}, 0x4009b9aa00, 0x400e6fcba0)
github.com/lightningnetwork/[email protected]/rpcperms/interceptor.go:832 +0xec
google.golang.org/grpc.getChainUnaryHandler.func1({0x43764b8, 0x4008657200}, {0x2b36140, 0x4014550c60})
google.golang.org/[email protected]/server.go:1196 +0xa0
github.com/lightningnetwork/lnd/rpcperms.(*InterceptorChain).CreateServerOpts.(*InterceptorChain).MacaroonUnaryServerInterceptor.func5({0x43764b8, 0x4008657200}, {0x2b36140, 0x4014550c60}, 0x4009b9aa00?, 0x4007300e80)
github.com/lightningnetwork/[email protected]/rpcperms/interceptor.go:689 +0x90
google.golang.org/grpc.getChainUnaryHandler.func1({0x43764b8, 0x4008657200}, {0x2b36140, 0x4014550c60})
google.golang.org/[email protected]/server.go:1196 +0xa0
github.com/lightningnetwork/lnd/rpcperms.(*InterceptorChain).CreateServerOpts.(*InterceptorChain).rpcStateUnaryServerInterceptor.func3({0x43764b8, 0x4008657200}, {0x2b36140, 0x4014550c60}, 0x4009b9aa00, 0x4007300e40)
github.com/lightningnetwork/[email protected]/rpcperms/interceptor.go:781 +0x108
google.golang.org/grpc.getChainUnaryHandler.func1({0x43764b8, 0x4008657200}, {0x2b36140, 0x4014550c60})
google.golang.org/[email protected]/server.go:1196 +0xa0
github.com/lightningnetwork/lnd/rpcperms.(*InterceptorChain).CreateServerOpts.errorLogUnaryServerInterceptor.func1({0x43764b8?, 0x4008657200?}, {0x2b36140?, 0x4014550c60?}, 0x4009b9aa00, 0x400e6fcba0?)
github.com/lightningnetwork/[email protected]/rpcperms/interceptor.go:605 +0x48
google.golang.org/grpc.NewServer.chainUnaryServerInterceptors.chainUnaryInterceptors.func1({0x43764b8, 0x4008657200}, {0x2b36140, 0x4014550c60}, 0x4009b9aa00, 0x2beef60?)
google.golang.org/[email protected]/server.go:1187 +0x88
github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc._TaprootAssetChannels_AddInvoice_Handler({0x2d27f00, 0x4000acf560}, {0x43764b8, 0x4008657200}, 0x4003ddd880, 0x400015bdc0)
github.com/lightninglabs/taproot-assets/[email protected]/tapchannelrpc/tapchannel_grpc.pb.go:266 +0x148
google.golang.org/grpc.(*Server).processUnaryRPC(0x400004f600, {0x43764b8, 0x4008657020}, {0x4394080, 0x400032a000}, 0x4000b05d40, 0x4000a8c390, 0x63b4190, 0x0)
google.golang.org/[email protected]/server.go:1379 +0xb58
google.golang.org/grpc.(*Server).handleStream(0x400004f600, {0x4394080, 0x400032a000}, 0x4000b05d40)
google.golang.org/[email protected]/server.go:1790 +0xb20
google.golang.org/grpc.(*Server).serveStreams.func2.1()
google.golang.org/[email protected]/server.go:1029 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 493
google.golang.org/[email protected]/server.go:1040 +0x13c
My 2 cents is that this check is failing since existingQuotes
should be true
in my case, and when that is true then this hits: which means acquiredQuotes
may not get populated and this expensiveQuote
would be nil. With expensiveQuote
being nil we would run into this runtime error when we call UnmarshalRfqFixedPoint
on it inside validateInvoiceAmount
.
Your environment
taproot assets v0.6.0
terminal v0.15.0-alpha
LND 0.19.1-beta
- any other relevant environment details
Steps to reproduce
Get an accepted quote with AddAssetBuyOrder
, create an asset invoice using tapchannelrpc.AddInvoice
, and in the tapchannelrpc.AddInvoiceRequest
inside the InvoiceRequest
field, include route hints that have a hop hint that looks like:
invoiceHopHints := []*lnrpc.HopHint{
{
NodeId: myPeersPubkey,
ChanId: acceptedBuyQuoteScid,
CltvExpiryDelta: cltvExpiry,
FeeBaseMsat: feeBaseMsat,
FeeProportionalMillionths: feeProportionalMillionths,
},
}
Expected behavior
A runtime error should not occur
Actual behavior
Asset invoice creation yields a runtime error, the node crashes.