Conversation
Codecov Report
@@ Coverage Diff @@
## main #185 +/- ##
=======================================
Coverage 93.70% 93.71%
=======================================
Files 178 179 +1
Lines 4672 4693 +21
Branches 547 547
=======================================
+ Hits 4378 4398 +20
- Misses 162 163 +1
Partials 132 132
Continue to review full report at Codecov.
|
bmancini55
left a comment
There was a problem hiding this comment.
Looking good, couple comment changes and you'll need to fix the de/ser methods to properly handle the scriptPubKey len.
|
|
||
| /** | ||
| * ShutdownMessage represents the `shutdown` message defined in | ||
| * BOLT #2 of the Lightning Specification. This message can be sent by the |
There was a problem hiding this comment.
s/sent by either/sent by the either/
| /** | ||
| * ShutdownMessage represents the `shutdown` message defined in | ||
| * BOLT #2 of the Lightning Specification. This message can be sent by the | ||
| * either node. The scriptPubKey must follow the standards which are accepted |
There was a problem hiding this comment.
The scriptPubKey has stricter requirements than this. Must be a valid P2WPKH, P2WSH, P2SH-P2WPKH, P2SH-P2WSH, or any valid witness script if option_shutdown_anysegwit is negotiated.
Also may want to make a note that this scriptPubKey must be the same as the shutdown_scriptpubkey value if it was sent during channel open/accept.
There was a problem hiding this comment.
1st remark comment added, For 2nd I have updated the scriptPubKey in test file!
| * by Bitcoin network that ensures the resulting transaction will propagate | ||
| * to miners. If shutdown is sent by either node , corresponding node should send | ||
| * commitment_signed to commit any outstanding changes before replying shutdown. Once | ||
| * shutdown is sent by both nodes no new HTLCs should be added or accepted by the channel. |
There was a problem hiding this comment.
Add one more note that after this, fee negotiation and signature sending can begin with closing_signed
| const writer = new BufferWriter(); | ||
| writer.writeUInt16BE(this.type); | ||
| writer.writeBytes(this.channelId.toBuffer()); | ||
| writer.writeBytes(this.len); |
|
|
||
| reader.readUInt16BE(); // read type | ||
| instance.channelId = new ChannelId(reader.readBytes(32)); | ||
| instance.len = reader.readBytes(16); |
There was a problem hiding this comment.
Len should be a uint16be and used as input when reading the scriptPubKey bytes
bmancini55
left a comment
There was a problem hiding this comment.
Comments are looking good. Just need to add some info to the scriptPubKey property.
Biggest issue is we can get rid of the len property on the class. The length is implicit in the scriptPubKey buffer. During serialization you can just use the length property of the Buffer. For deserialization, you can read len into a temp variable and then call readBytes with len to read the scriptPubKey buffer.
|
|
||
| reader.readUInt16BE(); // read type | ||
| instance.channelId = new ChannelId(reader.readBytes(32)); | ||
| instance.len = reader.readUInt16BE(); |
There was a problem hiding this comment.
Just read this into a temp variable instead of a class property.
There was a problem hiding this comment.
deser similar to this one - https://github.com/altangent/node-lightning/blob/main/packages/wire/lib/messages/ErrorMessage.ts ?
There was a problem hiding this comment.
got it! Thanks for being patient with me!.🙇
There was a problem hiding this comment.
No worries at all, you're doing great!
| */ | ||
| public channelId: ChannelId; | ||
|
|
||
| public len: number; |
There was a problem hiding this comment.
Don't need a class property. The value is implicit in the scriptPubKey buffer.
| const writer = new BufferWriter(); | ||
| writer.writeUInt16BE(this.type); | ||
| writer.writeBytes(this.channelId.toBuffer()); | ||
| writer.writeUInt16BE(this.len); |
There was a problem hiding this comment.
Use the length of scriptPubKey
| * outstanding changes before replying shutdown. Once shutdown is sent by both nodes no new HTLCs should be added or accepted by the channel. | ||
| * After successful handshake of shutdown message, fee negotiation and signature sending can begin with `closing_signed` message. | ||
| */ | ||
|
|
There was a problem hiding this comment.
nit: remove newline between comment block and class and watch comment line length.
|
|
||
| public len: number; | ||
| /** | ||
| * scriptPubKey is used by the sender to get paid. |
There was a problem hiding this comment.
Beef up the comment on what this value should or move comment from class to here. Either is fine.
bmancini55
left a comment
There was a problem hiding this comment.
Awesome, looks great! Thanks!
wire: create shutdown message type #179
BOLT #2
shutdownin BOLT #2