mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-23 12:13:50 +02:00
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:
@@ -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.
|
||||
|
Reference in New Issue
Block a user