rpcserver: enforce memo length is less than 500 characters

In this commit we ensure that the string length of the memo field
specified as part of the OpenChannelRequest is no longer than 500.
This commit is contained in:
shaurya947
2023-05-03 16:19:43 -04:00
parent 373e445cdc
commit 1724409647

View File

@@ -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.