-
Notifications
You must be signed in to change notification settings - Fork 111
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
tapchannel: add awareness of 1st and 2nd level HTLC sweeps to the AuxSweeper #1154
base: script-key-upsert
Are you sure you want to change the base?
Commits on Nov 13, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 379dfe2 - Browse repository at this point
Copy the full SHA 379dfe2View commit details -
tapchannelmsg: expand fields of ContractResolution for 2nd level sweeps
In this commit, we expand the fields of the `ContractResolution` struct to account for second level sweeps. When we have an HTLC that needs to go to the second level, we'll need to create 2 vPkts: one for a direct spend from the commitment txns with the second level txn, and the other for the spend from the sweeping transaction. We can construct that transaction early, but can only sign for it once we know the sweeping transaction. Therefore, we need to keep some extra data for a given resolution, namely the tapTweak and the control block.
Configuration menu - View commit details
-
Copy full SHA for 86887c6 - Browse repository at this point
Copy the full SHA 86887c6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9c8a7a0 - Browse repository at this point
Copy the full SHA 9c8a7a0View commit details -
tapchannel: extract allocation creation from CreateSecondLevelHtlcPac…
…kets This'll be useful later when we need to generate the vPkt for second level spends.
Configuration menu - View commit details
-
Copy full SHA for 6877f4c - Browse repository at this point
Copy the full SHA 6877f4cView commit details -
tapchannel: add 2nd level information to tapscriptSweepDesc
In this commit, we add two fields to the tapscriptSweepDesc struct related to 2nd level HTLCs. First, we add the second level sig index, which is needed to be able to know where to insert our signature after we generate it. We also add an optional lnwallet.AuxSigDesc, which contains the remote party's signature, and also the sighash needed for it and a sign desc to generate it with.
Configuration menu - View commit details
-
Copy full SHA for 571e532 - Browse repository at this point
Copy the full SHA 571e532View commit details -
tapchannel: add sweep desc gen for remote HTLC sweeps
In this commit, we add sweep desc generation for remote HTLCs sweeps. This is needed when the remote party force closes, and we can spend the HTLC directly from their commitment transaction.
Configuration menu - View commit details
-
Copy full SHA for 56f51af - Browse repository at this point
Copy the full SHA 56f51afView commit details -
tapchannel: add blobWithWitnessInfo struct
In this commit, we add `blobWithWitnessInfo` which couples the raw resolution TLV blob with some additional information such as the input that carried the blob, and also preimage information. Preimage information is needed to know where to insert the preimage in the witness once we learn about it on chain.
Configuration menu - View commit details
-
Copy full SHA for 9fc1a00 - Browse repository at this point
Copy the full SHA 9fc1a00View commit details -
tapchannel: update createSweepVpackets to be second level aware
In this commit, we update `createSweepVpackets` to be second level aware. This means that if we detect an auxSigInfo, then we know the vPkt we need to create is actually just the second level vPkt. We also don't need to generate a new script key either. Finally, we'll properly set the absolute delay if the sweep desc indicates as such.
Configuration menu - View commit details
-
Copy full SHA for 66ea173 - Browse repository at this point
Copy the full SHA 66ea173View commit details -
tapchannel: update signSweepVpackets to be 2nd level HTLC aware
In this commit, we update `signSweepVpackets` to be 2nd level HTLC aware. If we have an auxSigDesc, then that means we're spending a 2nd level HTLC txn. To spend this properly, we'll need to insert the remote party's signature at the proper location, as it's a 2-of-2 multi-sig.
Configuration menu - View commit details
-
Copy full SHA for 768c343 - Browse repository at this point
Copy the full SHA 768c343View commit details -
tapchannel: update createAndSignSweepVpackets to be 2nd level aware
In this commit, we make sure to pass in the correct signDesc when we go to sign for a second level txn. For a 2nd level txn, we'll actually use the signDesc that's needed to generate the 2-of-2 multi-sig, instead of the one that we'd normally use to sweep.
Configuration menu - View commit details
-
Copy full SHA for 6826f2e - Browse repository at this point
Copy the full SHA 6826f2eView commit details -
tapchannel: create 2nd lvl vPkts in resolveContract
With all the prior commits in place, we can now create the new contract resolution that includes the 1st and 2nd level packets, and the information that we'll need to re-sign the second level packets later.
Configuration menu - View commit details
-
Copy full SHA for 1805fde - Browse repository at this point
Copy the full SHA 1805fdeView commit details -
tapchannel: update sweepContracts for HTLC sweeps
In this commit, we add some intermediate functions and types needed to properly handle HTLC sweeps. We now use the preimage info added in a prior commit to make sure that once we learn of the preimage (after vPkt creation, but before publish), we'll properly insert it in the correct location. In sweepContracts, when we go to create the new anchor change output, we'll make sure to omit any second level transactions, as they already have a destination location specified. Direct spends are spends directly from the commitment transaction. If we don't have any direct spends, then we don't need to make a change addr, as second level spends are already bound to an anchor output.
Configuration menu - View commit details
-
Copy full SHA for 9fdac50 - Browse repository at this point
Copy the full SHA 9fdac50View commit details -
tapchannel: update registerAndBroadcastSweep for HTLC sweeps
In this commit, we update `registerAndBroadcastSweep` to be able to handle HTLC sweeps. First, we only need to set the anchor for first level sweeps. We weren't able to sign the 2nd level sweeps earlier as we didn't know the txid of the transaction that swept them. Now that we're about to broadcast, we know the sweeping transaction so we can set the prevID properly, then sign the sweeping transaction. If the sweeper is broadcasting _just_ a second level txn with an asset, then we won't have an extra change output. This transaction also already has its internal key bound.
Configuration menu - View commit details
-
Copy full SHA for a05313d - Browse repository at this point
Copy the full SHA a05313dView commit details -
Configuration menu - View commit details
-
Copy full SHA for da4df4c - Browse repository at this point
Copy the full SHA da4df4cView commit details -
tapchannel: properly set RelativeLockTime in DistributeCoins
If we don't do this here, then we'll sign a second level success transaction that doesn't have the sequence set properly. This will then propagate all the way up to anchor output, leading to an incorrect inclusion proof later.
Configuration menu - View commit details
-
Copy full SHA for ac98848 - Browse repository at this point
Copy the full SHA ac98848View commit details -
tapchannel: properly thread thru lock time for 2nd level HTLCs
In this commit, we fix an existing logic gap related to 2nd level HTLCs. Before if we were signing a timeout for the remote party, neither of us would properly apply the lock time to the vPkt. In this commit, we fix it by first gaining a new `whoseCommit` param in `FetchLeavesFromCommit`. We then use that to decide when to use a non zero CLTV timeout.
Configuration menu - View commit details
-
Copy full SHA for 1672d2a - Browse repository at this point
Copy the full SHA 1672d2aView commit details -
tapchannel: ensure the root commit asset has a valid witness
In this commit, we fix a very subtle issue related to split witnesses and root assets. Before this commit, when we went to sign a second level txn, which is a split, we would create a virtual txn, which will commit to the _entire_ witness of the root asset in the vIn. Note that this bypasses the normal segwit encoding logic, as that currently doesn't apply to the root asset encoded in the split commit proof. In the future, we may want to expand the segwit encoding semantics to root assets after careful consideration. In this commit, we fix a bug that would cause an invalid 2nd level sig by ensuring that before we create the output commitments, we update the root asset witness in each split, to the funding witness script, which is just OP_TRUE.
Configuration menu - View commit details
-
Copy full SHA for 9233d13 - Browse repository at this point
Copy the full SHA 9233d13View commit details -
tapchannel: add an extra budget for each input w/ a blob
In this commit, we fix an issue that would cause lnd to not broadcast sweeps of HTLCs due to their small value. Before we didn't add enough budget to actually convince lnd to init the fee function and broadcast the sweep. In the future, we should do a more careful calculation here based on the current BTC value of the asset, to make an economical decision. For now, we just increase the amt based on the amt of inputs we have. This gives lnd a fee budget to use for bumping.
Configuration menu - View commit details
-
Copy full SHA for e079cb3 - Browse repository at this point
Copy the full SHA e079cb3View commit details -
tapchannel: utilize new outpointToTxIndex map in NotifyBroadcast
In this commit, we update the logic of `notifyBroadcast` to use the new `outpointToTxIndex` map. We'll use this to make sure that the vOut has the correct anchor output index, as the sweeper applies a sorting routine before broadcast. Otherwise, we'll have invalid inclusion proofs.
Configuration menu - View commit details
-
Copy full SHA for 92f83fa - Browse repository at this point
Copy the full SHA 92f83faView commit details -
tapchannel: import script keys of all HTLC outputs, as known
If we don't import these script keys, spends will fail later as we didn't credit the balance, so we can't spend them.
Configuration menu - View commit details
-
Copy full SHA for cb4f1f1 - Browse repository at this point
Copy the full SHA cb4f1f1View commit details