lnwallet: rename DelayKey->ToLocalKey, NoDelayKey->ToRemoteKey
Since both parties are going to have their ouputs delayed, we move way from the DelayKey naming, and instead use ToLocalKey and ToRemoteKey.
This commit is contained in:
7 files changed
+61
-49
No files matched your search
+32
-20
@@ -59,18 +59,30 @@ type CommitmentKeyRing struct {
|
||||
// of whether this is our commit or not.
|
||||
RemoteHtlcKey *btcec.PublicKey
|
||||
|
||||
// DelayKey is the commitment transaction owner's key which is included
|
||||
// in HTLC success and timeout transaction scripts.
|
||||
DelayKey *btcec.PublicKey
|
||||
// ToLocalKey is the commitment transaction owner's key which is
|
||||
// included in HTLC success and timeout transaction scripts. This is
|
||||
// the public key used for the to_local output of the commitment
|
||||
// transaction.
|
||||
//
|
||||
// NOTE: Who's key this is depends on the current perspective. If this
|
||||
// is our commitment this will be our key.
|
||||
ToLocalKey *btcec.PublicKey
|
||||
|
||||
// NoDelayKey is the other party's payment key in the commitment tx.
|
||||
// This is the key used to generate the unencumbered output within the
|
||||
// ToRemoteKey is the non-owner's payment key in the commitment tx.
|
||||
// This is the key used to generate the to_remote output within the
|
||||
// commitment transaction.
|
||||
NoDelayKey *btcec.PublicKey
|
||||
//
|
||||
// NOTE: Who's key this is depends on the current perspective. If this
|
||||
// is our commitment this will be their key.
|
||||
ToRemoteKey *btcec.PublicKey
|
||||
|
||||
// RevocationKey is the key that can be used by the other party to
|
||||
// redeem outputs from a revoked commitment transaction if it were to
|
||||
// be published.
|
||||
//
|
||||
// NOTE: Who can sign for this key depends on the current perspective.
|
||||
// If this is our commitment, it means the remote node can sign for
|
||||
// this key in case of a breach.
|
||||
RevocationKey *btcec.PublicKey
|
||||
}
|
||||
|
||||
@@ -100,29 +112,29 @@ func DeriveCommitmentKeys(commitPoint *btcec.PublicKey,
|
||||
),
|
||||
}
|
||||
|
||||
// We'll now compute the delay, no delay, and revocation key based on
|
||||
// the current commitment point. All keys are tweaked each state in
|
||||
// We'll now compute the to_local, to_remote, and revocation key based
|
||||
// on the current commitment point. All keys are tweaked each state in
|
||||
// order to ensure the keys from each state are unlinkable. To create
|
||||
// the revocation key, we take the opposite party's revocation base
|
||||
// point and combine that with the current commitment point.
|
||||
var (
|
||||
delayBasePoint *btcec.PublicKey
|
||||
noDelayBasePoint *btcec.PublicKey
|
||||
toLocalBasePoint *btcec.PublicKey
|
||||
toRemoteBasePoint *btcec.PublicKey
|
||||
revocationBasePoint *btcec.PublicKey
|
||||
)
|
||||
if isOurCommit {
|
||||
delayBasePoint = localChanCfg.DelayBasePoint.PubKey
|
||||
noDelayBasePoint = remoteChanCfg.PaymentBasePoint.PubKey
|
||||
toLocalBasePoint = localChanCfg.DelayBasePoint.PubKey
|
||||
toRemoteBasePoint = remoteChanCfg.PaymentBasePoint.PubKey
|
||||
revocationBasePoint = remoteChanCfg.RevocationBasePoint.PubKey
|
||||
} else {
|
||||
delayBasePoint = remoteChanCfg.DelayBasePoint.PubKey
|
||||
noDelayBasePoint = localChanCfg.PaymentBasePoint.PubKey
|
||||
toLocalBasePoint = remoteChanCfg.DelayBasePoint.PubKey
|
||||
toRemoteBasePoint = localChanCfg.PaymentBasePoint.PubKey
|
||||
revocationBasePoint = localChanCfg.RevocationBasePoint.PubKey
|
||||
}
|
||||
|
||||
// With the base points assigned, we can now derive the actual keys
|
||||
// using the base point, and the current commitment tweak.
|
||||
keyRing.DelayKey = input.TweakPubKey(delayBasePoint, commitPoint)
|
||||
keyRing.ToLocalKey = input.TweakPubKey(toLocalBasePoint, commitPoint)
|
||||
keyRing.RevocationKey = input.DeriveRevocationPubkey(
|
||||
revocationBasePoint, commitPoint,
|
||||
)
|
||||
@@ -130,10 +142,10 @@ func DeriveCommitmentKeys(commitPoint *btcec.PublicKey,
|
||||
// If this commitment should omit the tweak for the remote point, then
|
||||
// we'll use that directly, and ignore the commitPoint tweak.
|
||||
if tweaklessCommit {
|
||||
keyRing.NoDelayKey = noDelayBasePoint
|
||||
keyRing.ToRemoteKey = toRemoteBasePoint
|
||||
} else {
|
||||
keyRing.NoDelayKey = input.TweakPubKey(
|
||||
noDelayBasePoint, commitPoint,
|
||||
keyRing.ToRemoteKey = input.TweakPubKey(
|
||||
toRemoteBasePoint, commitPoint,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -377,7 +389,7 @@ func CreateCommitTx(fundingOutput wire.TxIn, keyRing *CommitmentKeyRing,
|
||||
// the funds with the revocation key if we broadcast a revoked
|
||||
// commitment transaction.
|
||||
toLocalRedeemScript, err := input.CommitScriptToSelf(
|
||||
uint32(localChanCfg.CsvDelay), keyRing.DelayKey,
|
||||
uint32(localChanCfg.CsvDelay), keyRing.ToLocalKey,
|
||||
keyRing.RevocationKey,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -393,7 +405,7 @@ func CreateCommitTx(fundingOutput wire.TxIn, keyRing *CommitmentKeyRing,
|
||||
// Next, we create the script paying to the remote. This is just a
|
||||
// regular P2WPKH output, without any added CSV delay.
|
||||
toRemoteWitnessKeyHash, err := input.CommitScriptUnencumbered(
|
||||
keyRing.NoDelayKey,
|
||||
keyRing.ToRemoteKey,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user