diff --git a/rpcserver.go b/rpcserver.go index 952b769ec..0cc50bf00 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2169,6 +2169,15 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest, in.CommitmentType) } + // We limit the channel memo to be 500 characters long. This enforces + // a reasonable upper bound on storage consumption. This also mimics + // the length limit for the label of a TX. + const maxMemoLength = 500 + if len(in.Memo) > maxMemoLength { + return nil, fmt.Errorf("provided memo (%s) is of length %d, "+ + "exceeds %d", in.Memo, len(in.Memo), maxMemoLength) + } + // Instruct the server to trigger the necessary events to attempt to // open a new channel. A stream is returned in place, this stream will // be used to consume updates of the state of the pending channel.