-
Notifications
You must be signed in to change notification settings - Fork 412
Fix spurious panic on bogus funding txn that confirm and are spent #1585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix spurious panic on bogus funding txn that confirm and are spent #1585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK 9d91dac, in conformity to what have been reviewed elsewhere.
1f80fad
to
dfc6a32
Compare
Oops, had some rebase errors in use statements, had to resolve that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK dfc6a32
Changes since last push :
- removing the use for
Transaction, TxOut, TxIn, OutPoint as BitcoinOutPoint
in functional tests - removing the use for
Witness
in functional tests
In c02b6a3 we moved the `payment_preimage` copy from inside the macro which only runs if we are spending an output we know is an HTLC output to doing it for any script that matches our expected length. This can panic if an inbound channel is created with a bogus funding transaction that has a witness program of the HTLC-Success/-Offered length but which does not have a second-to-last witness element which is 32 bytes. Luckily this panic is relatively simple for downstream users to work around - if an invalid-length-copy panic occurs, simply remove the ChannelMonitor from the bogus channel on startup and run without it. Because the channel must be funded by a bogus script in order to reach this panic, the channel will already have closed by the time the funding transaction is spent, and there can be no local funds in such a channel, so removing the `ChannelMonitor` wholesale is completely safe. In order to test this we have to disable an in-line assertion that checks that our transactions match expected scripts which we do by checking for the specific bogus script that we now use in `test_invalid_funding_tx`. Thanks to Eugene Siegel for reporting this issue.
dfc6a32
to
6c480ae
Compare
Oops, sorry, one more, looks like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One More Time Code Review ACK 6c480ae 🎵
Oops, sorry, one more, looks like Vec::from(array) needed const generics which we don't support.
Hmmm, the previous branch built well on my local host. Some issue with bindings or other platforms than x86_64 ?
It was an MSRV issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 6c480ae
// in-line tests later. | ||
|
||
#[cfg(test)] | ||
pub fn deliberately_bogus_accepted_htlc_witness_program() -> Vec<u8> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all bogus to me, but perhaps the beginning of a new age techno rap.
In c02b6a3 we moved the
payment_preimage
copy from inside the macro which only runs if weare spending an output we know is an HTLC output to doing it for
any script that matches our expected length. This can panic if an
inbound channel is created with a bogus funding transaction that
has a witness program of the HTLC-Success/-Offered length but which
does not have a second-to-last witness element which is 32 bytes.
Luckily this panic is relatively simple for downstream users to
work around - if an invalid-length-copy panic occurs, simply remove
the ChannelMonitor from the bogus channel on startup and run
without it. Because the channel must be funded by a bogus script in
order to reach this panic, the channel will already have closed by
the time the funding transaction is spent, and there can be no
local funds in such a channel, so removing the
ChannelMonitor
wholesale is completely safe.
In order to test this we have to disable an in-line assertion that
checks that our transactions match expected scripts which we do by
checking for the specific bogus script that we now use in
test_invalid_funding_tx
.Thanks to Eugene Siegel for reporting this issue.