Skip to content

Extend penalty to stealing HTLC outputs#517

Merged
pm47 merged 6 commits intomasterfrom
revoked-htlc
Mar 28, 2018
Merged

Extend penalty to stealing HTLC outputs#517
pm47 merged 6 commits intomasterfrom
revoked-htlc

Conversation

@pm47
Copy link
Member

@pm47 pm47 commented Mar 28, 2018

Previously we were only stealing the remote's main output when they publish a revoked commit, and were relying on a sufficiently high channel_reserve do deincentivize cheating.

In order to also steal the htlc outputs, we need to handle both cases:

  • they only publish their revoked commit tx => we claim the htlc outputs directly from the commit tx
  • they publish their revoked commit tx, and their 2nd-stage HTLCSuccessTx and HtlcTimeout txes => we claim the output of these htlcs tx

To do that, we need to be able to reconstruct htlc scripts (htlcOffered and htlcReceived), therefore we need to store paymentHash and cltvExpiry for each htlc we sign. Note that this won't be needed in the future when we have MAST.

@pm47 pm47 requested a review from sstone March 28, 2018 10:24
case u: UpdateFailMalformedHtlc => relayer ! CommandBuffer.CommandAck(u.channelId, u.id)
}
// TODO: be smarter and only consider commitments1.localChanges.signed and commitments1.remoteChanges.signed
htlcTxs.map {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick. map() instead of foreach()

.flatMap { remotePerCommitmentSecret =>
val remotePerCommitmentPoint = remotePerCommitmentSecret.toPoint
val remoteDelayedPaymentPubkey = Generators.derivePubKey(remoteParams.delayedPaymentBasepoint, remotePerCommitmentPoint)
val remoteRevocationPubkey = Generators.revocationPubKey(keyManager.revocationPoint(localParams.channelKeyPath).publicKey, remotePerCommitmentSecret.toPoint)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remotePerCommitmentPoint instead of remotePerCommitmentSecret.toPoint


// we watch outputs of the commitment tx that both parties may spend
val watchSpentQueue = mainPenaltyTx ++ claimHtlcTimeoutTxs ++ htlcTimeoutTxs
val watchSpentQueue = mainPenaltyTx ++ htlcPenaltyTxs ++ claimHtlcDelayedPenaltyTxs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claimHtlcDelayedPenaltyTxs don't spend commitTx so we should not set a watch here

@pm47 pm47 changed the title [WIP] Extend penalty to stealing HTLC outputs Extend penalty to stealing HTLC outputs Mar 28, 2018
@pm47 pm47 merged commit be4cf6b into master Mar 28, 2018
@pm47 pm47 deleted the revoked-htlc branch March 28, 2018 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants