htlcswitch+lnwallet: remove PaymentDescriptor from ReceiveRevocation returns

This is part of a systematic removal of PaymentDescriptor from the public
API of the lnwallet package. This marks the last change needed before we
make the PaymentDescriptor structure private.
This commit is contained in:
Keagan McClelland 2024-08-16 14:35:49 -07:00 committed by Oliver Gugger
parent a3e127d1d6
commit 870800b81a
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
7 changed files with 120 additions and 114 deletions

View File

@ -2321,8 +2321,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
// We now process the message and advance our remote commit
// chain.
fwdPkg, _, _, remoteHTLCs, err := l.channel.
ReceiveRevocation(msg)
fwdPkg, remoteHTLCs, err := l.channel.ReceiveRevocation(msg)
if err != nil {
// TODO(halseth): force close?
l.failf(

View File

@ -129,7 +129,7 @@ func (l *linkTestContext) receiveRevAndAckAliceToBob() {
l.t.Fatalf("expected RevokeAndAck, got %T", msg)
}
_, _, _, _, err := l.bobChannel.ReceiveRevocation(rev)
_, _, err := l.bobChannel.ReceiveRevocation(rev)
if err != nil {
l.t.Fatalf("bob failed receiving revocation: %v", err)
}

View File

@ -2335,7 +2335,7 @@ func handleStateUpdate(link *channelLink,
if !ok {
return fmt.Errorf("expected RevokeAndAck got %T", msg)
}
_, _, _, _, err = remoteChannel.ReceiveRevocation(revoke)
_, _, err = remoteChannel.ReceiveRevocation(revoke)
if err != nil {
return fmt.Errorf("unable to receive "+
"revocation: %v", err)
@ -2389,7 +2389,7 @@ func updateState(batchTick chan time.Time, link *channelLink,
return fmt.Errorf("expected RevokeAndAck got %T",
msg)
}
_, _, _, _, err = remoteChannel.ReceiveRevocation(revoke)
_, _, err = remoteChannel.ReceiveRevocation(revoke)
if err != nil {
return fmt.Errorf("unable to receive "+
"revocation: %v", err)
@ -3643,7 +3643,7 @@ func TestChannelLinkTrimCircuitsRemoteCommit(t *testing.T) {
rev, _, _, err := harness.bobChannel.RevokeCurrentCommitment()
require.NoError(t, err, "unable to revoke current commitment")
_, _, _, _, err = alice.channel.ReceiveRevocation(rev)
_, _, err = alice.channel.ReceiveRevocation(rev)
require.NoError(t, err, "unable to receive revocation")
// Restart Alice's link, which simulates a disconnection with the remote

View File

@ -5375,15 +5375,10 @@ func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.RevokeAndAck,
// The returned values correspond to:
// 1. The forwarding package corresponding to the remote commitment height
// that was revoked.
// 2. The PaymentDescriptor of any Add HTLCs that were locked in by this
// revocation.
// 3. The PaymentDescriptor of any Settle/Fail HTLCs that were locked in by
// this revocation.
// 4. The set of HTLCs present on the current valid commitment transaction
// 2. The set of HTLCs present on the current valid commitment transaction
// for the remote party.
func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
*channeldb.FwdPkg, []*PaymentDescriptor, []*PaymentDescriptor,
[]channeldb.HTLC, error) {
*channeldb.FwdPkg, []channeldb.HTLC, error) {
lc.Lock()
defer lc.Unlock()
@ -5392,10 +5387,10 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
store := lc.channelState.RevocationStore
revocation, err := chainhash.NewHash(revMsg.Revocation[:])
if err != nil {
return nil, nil, nil, nil, err
return nil, nil, err
}
if err := store.AddNextEntry(revocation); err != nil {
return nil, nil, nil, nil, err
return nil, nil, err
}
// Verify that if we use the commitment point computed based off of the
@ -5404,7 +5399,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
currentCommitPoint := lc.channelState.RemoteCurrentRevocation
derivedCommitPoint := input.ComputeCommitmentPoint(revMsg.Revocation[:])
if !derivedCommitPoint.IsEqual(currentCommitPoint) {
return nil, nil, nil, nil, fmt.Errorf("revocation key mismatch")
return nil, nil, fmt.Errorf("revocation key mismatch")
}
// Now that we've verified that the prior commitment has been properly
@ -5434,10 +5429,8 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
// updates to disk and optimistically buffer the forwarding package in
// memory.
var (
addsToForward []*PaymentDescriptor
addUpdates []channeldb.LogUpdate
settleFailsToForward []*PaymentDescriptor
settleFailUpdates []channeldb.LogUpdate
addUpdatesToForward []channeldb.LogUpdate
settleFailUpdatesToForward []channeldb.LogUpdate
)
var addIndex, settleFailIndex uint16
@ -5489,7 +5482,13 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
addIndex++
pd.isForwarded = true
addsToForward = append(addsToForward, pd)
// At this point we put the update into our list of
// updates that we will eventually put into the
// FwdPkg at this height.
addUpdatesToForward = append(
addUpdatesToForward, pd.ToLogUpdate(),
)
case pd.EntryType != Add && committedRmv && shouldFwdRmv:
// Construct a reference specifying the location that
@ -5503,28 +5502,17 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
settleFailIndex++
pd.isForwarded = true
settleFailsToForward = append(settleFailsToForward, pd)
// At this point we put the update into our list of
// updates that we will eventually put into the
// FwdPkg at this height.
settleFailUpdatesToForward = append(
settleFailUpdatesToForward, pd.ToLogUpdate(),
)
default:
continue
}
// If we've reached this point, this HTLC will be added to the
// forwarding package at the height of the remote commitment.
// We'll map the type of the PaymentDescriptor to one of the
// four messages that it corresponds to and separate the
// updates into Adds and Settle/Fail/MalformedFail such that
// they can be written in the forwarding package. Adds are
// aggregated separately from the other types of HTLCs.
switch pd.EntryType {
case Add:
addUpdates = append(addUpdates, pd.ToLogUpdate())
case Settle, Fail, MalformedFail:
settleFailUpdates = append(
settleFailUpdates, pd.ToLogUpdate(),
)
}
}
// We use the remote commitment chain's tip as it will soon become the tail
@ -5540,7 +5528,8 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
// type, construct a forwarding package using the height that the remote
// commitment chain will be extended after persisting the revocation.
fwdPkg := channeldb.NewFwdPkg(
source, remoteChainTail, addUpdates, settleFailUpdates,
source, remoteChainTail, addUpdatesToForward,
settleFailUpdatesToForward,
)
// We will soon be saving the current remote commitment to revocation
@ -5553,7 +5542,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
revocation, lc.channelState, lc.leafStore,
)
if err != nil {
return nil, nil, nil, nil, err
return nil, nil, err
}
// Now that we have a new verification nonce from them, we can refresh
@ -5561,7 +5550,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
if lc.channelState.ChanType.IsTaproot() {
localNonce, err := revMsg.LocalNonce.UnwrapOrErrV(errNoNonce)
if err != nil {
return nil, nil, nil, nil, err
return nil, nil, err
}
session, err := lc.musigSessions.RemoteSession.Refresh(
@ -5570,7 +5559,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
},
)
if err != nil {
return nil, nil, nil, nil, err
return nil, nil, err
}
lc.musigSessions.RemoteSession = session
@ -5586,7 +5575,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
ourOutputIndex, theirOutputIndex,
)
if err != nil {
return nil, nil, nil, nil, err
return nil, nil, err
}
// Since they revoked the current lowest height in their commitment
@ -5603,7 +5592,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
remoteHTLCs := lc.channelState.RemoteCommitment.Htlcs
return fwdPkg, addsToForward, settleFailsToForward, remoteHTLCs, nil
return fwdPkg, remoteHTLCs, nil
}
// LoadFwdPkgs loads any pending log updates from disk and returns the payment

View File

@ -132,7 +132,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
// Alice then processes this revocation, sending her own revocation for
// her prior commitment transaction. Alice shouldn't have any HTLCs to
// forward since she's sending an outgoing HTLC.
fwdPkg, _, _, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
fwdPkg, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to process bob's revocation")
if len(fwdPkg.Adds) != 0 {
t.Fatalf("alice forwards %v add htlcs, should forward none",
@ -157,7 +157,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
// is fully locked in within both commitment transactions. Bob should
// also be able to forward an HTLC now that the HTLC has been locked
// into both commitment transactions.
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to process alice's revocation")
if len(fwdPkg.Adds) != 1 {
t.Fatalf("bob forwards %v add htlcs, should only forward one",
@ -249,7 +249,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
aliceNewCommit, err = aliceChannel.SignNextCommitment()
require.NoError(t, err, "alice unable to sign new commitment")
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation2)
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation2)
require.NoError(t, err, "bob unable to process alice's revocation")
if len(fwdPkg.Adds) != 0 {
t.Fatalf("bob forwards %v add htlcs, should forward none",
@ -286,7 +286,7 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool,
}
}
fwdPkg, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation2)
fwdPkg, _, err = aliceChannel.ReceiveRevocation(bobRevocation2)
require.NoError(t, err, "alice unable to process bob's revocation")
if len(fwdPkg.Adds) != 0 {
// Alice should now be able to forward the settlement HTLC to
@ -468,7 +468,7 @@ func TestChannelZeroAddLocalHeight(t *testing.T) {
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err)
// We now restore Alice's channel as this was the point at which
@ -643,7 +643,7 @@ func testCommitHTLCSigTieBreak(t *testing.T, restart bool) {
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err, "unable to revoke bob's commitment")
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "unable to receive bob's revocation")
// Now have Bob initiate the second half of the commitment dance. Here
@ -2554,7 +2554,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
// Alice receives the revocation of the old one, and can now assume
// that Bob's received everything up to the signature she sent,
// including the HTLC and fee update.
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to process bob's revocation")
// Alice receives new signature from Bob, and assumes this covers the
@ -2582,7 +2582,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
}
// Bob receives revocation from Alice.
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to process alice's revocation")
}
@ -2641,7 +2641,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
require.NoError(t, err, "unable to generate bob revocation")
// Bob receives the revocation of the old commitment
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "alice unable to process bob's revocation")
// Alice will sign next commitment. Since she sent the revocation, she
@ -2682,7 +2682,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
// Alice receives revocation from Bob, and can now be sure that Bob
// received the two updates, and they are considered locked in.
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "bob unable to process alice's revocation")
// Alice will receive the signature from Bob, which will cover what was
@ -2710,7 +2710,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
}
// Bob receives revocation from Alice.
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to process alice's revocation")
}
@ -2819,7 +2819,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
// Alice receives the revocation of the old one, and can now assume that
// Bob's received everything up to the signature she sent, including the
// HTLC and fee update.
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to process bob's revocation")
// Alice receives new signature from Bob, and assumes this covers the
@ -2849,7 +2849,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
}
// Bob receives revocation from Alice.
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to process alice's revocation")
}
@ -3264,13 +3264,13 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
require.NoError(t, err, "unable to revoke bob commitment")
bobNewCommit, err := bobChannel.SignNextCommitment()
require.NoError(t, err, "bob unable to sign commitment")
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to recv revocation")
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
require.NoError(t, err, "alice unable to rev bob's commitment")
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err, "alice unable to revoke commitment")
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to recv revocation")
// At this point, we'll now assert that their log states are what we
@ -3456,7 +3456,7 @@ func testChanSyncOweCommitmentPendingRemote(t *testing.T,
t.Fatalf("unable to revoke commitment: %v", err)
}
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevoke)
_, _, err = aliceChannel.ReceiveRevocation(bobRevoke)
if err != nil {
t.Fatalf("unable to revoke commitment: %v", err)
}
@ -3492,7 +3492,7 @@ func testChanSyncOweCommitmentPendingRemote(t *testing.T,
if err != nil {
t.Fatal(err)
}
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevoke)
_, _, err = bobChannel.ReceiveRevocation(aliceRevoke)
if err != nil {
t.Fatal(err)
}
@ -3586,7 +3586,7 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
bobNewCommit, err := bobChannel.SignNextCommitment()
require.NoError(t, err, "bob unable to sign commitment")
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to recv revocation")
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
require.NoError(t, err, "alice unable to rev bob's commitment")
@ -3681,7 +3681,7 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) {
// We'll continue by then allowing bob to process Alice's revocation
// message.
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to recv revocation")
// Finally, Alice will add an HTLC over her own such that we assert the
@ -3898,13 +3898,13 @@ func testChanSyncOweRevocationAndCommit(t *testing.T,
// We'll now finish the state transition by having Alice process both
// messages, and send her final revocation.
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to recv revocation")
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
require.NoError(t, err, "alice unable to recv bob's commitment")
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err, "alice unable to revoke commitment")
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to recv revocation")
}
@ -3989,7 +3989,7 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
// local commit chain getting height > remote commit chain.
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err, "alice unable to revoke commitment")
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to recv revocation")
// Next, Alice will settle that incoming HTLC, then we'll start the
@ -4121,7 +4121,7 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
// Now, we'll continue the exchange, sending Bob's revocation and
// signature message to Alice, ending with Alice sending her revocation
// message to Bob.
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to recv revocation")
err = aliceChannel.ReceiveNewCommitment(&CommitSigs{
CommitSig: bobSigMsg.CommitSig,
@ -4131,7 +4131,7 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T,
require.NoError(t, err, "alice unable to rev bob's commitment")
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err, "alice unable to revoke commitment")
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to recv revocation")
}
@ -4546,13 +4546,13 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
require.NoError(t, err, "unable to revoke bob commitment")
bobNewCommit, err := bobChannel.SignNextCommitment()
require.NoError(t, err, "bob unable to sign commitment")
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to recv revocation")
err = aliceChannel.ReceiveNewCommitment(bobNewCommit.CommitSigs)
require.NoError(t, err, "alice unable to rev bob's commitment")
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err, "alice unable to revoke commitment")
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to recv revocation")
// Both parties should now have the latest fee rate locked-in.
@ -4744,13 +4744,13 @@ func TestFeeUpdateOldDiskFormat(t *testing.T) {
require.NoError(t, err, "unable to revoke bob commitment")
bobNewCommitSigs, err := bobChannel.SignNextCommitment()
require.NoError(t, err, "bob unable to sign commitment")
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "alice unable to recv revocation")
err = aliceChannel.ReceiveNewCommitment(bobNewCommitSigs.CommitSigs)
require.NoError(t, err, "alice unable to rev bob's commitment")
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err, "alice unable to revoke commitment")
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to recv revocation")
// Both parties should now have the latest fee rate locked-in.
@ -5459,7 +5459,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
}
// Alice should detect that she doesn't need to forward any HTLC's.
fwdPkg, _, _, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
fwdPkg, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
if err != nil {
t.Fatal(err)
}
@ -5490,7 +5490,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
// Bob should now detect that he now has 2 incoming HTLC's that he can
// forward along.
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
if err != nil {
t.Fatal(err)
}
@ -5535,7 +5535,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
// At this point, Bob receives the revocation from Alice, which is now
// his signal to examine all the HTLC's that have been locked in to
// process.
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
if err != nil {
t.Fatal(err)
}
@ -5584,22 +5584,31 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
// Alice should detect that she doesn't need to forward any Adds's, but
// that the Fail has been locked in an can be forwarded.
_, adds, settleFails, _, err := aliceChannel.ReceiveRevocation(bobRevocation)
fwdPkg, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
if err != nil {
t.Fatal(err)
}
adds := fwdPkg.Adds
settleFails := fwdPkg.SettleFails
if len(adds) != 0 {
t.Fatalf("alice shouldn't forward any HTLC's, instead wants to "+
"forward %v htlcs", len(adds))
"forward %v htlcs", len(fwdPkg.Adds))
}
if len(settleFails) != 1 {
t.Fatalf("alice should only forward %d HTLC's, instead wants to "+
"forward %v htlcs", 1, len(settleFails))
"forward %v htlcs", 1, len(fwdPkg.SettleFails))
}
if settleFails[0].ParentIndex != htlc.ID {
fail, ok := settleFails[0].UpdateMsg.(*lnwire.UpdateFailHTLC)
if !ok {
t.Fatalf("expected UpdateFailHTLC, got %T",
settleFails[0].UpdateMsg)
}
if fail.ID != htlc.ID {
t.Fatalf("alice should forward fail for htlcid=%d, instead "+
"forwarding id=%d", htlc.ID,
settleFails[0].ParentIndex)
fail.ID)
}
// We'll now restart both Alice and Bob. This emulates a reconnection
@ -5633,7 +5642,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
// Alice should detect that she doesn't need to forward any HTLC's, as
// the updates haven't been committed by Bob yet.
fwdPkg, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
fwdPkg, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
if err != nil {
t.Fatal(err)
}
@ -5664,7 +5673,7 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
// Bob should detect that he has nothing to forward, as he hasn't
// received any HTLCs.
fwdPkg, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
fwdPkg, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
if err != nil {
t.Fatal(err)
}
@ -5694,10 +5703,13 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
// When Alice receives the revocation, she should detect that she
// can now forward the freshly locked-in Fail.
_, adds, settleFails, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
fwdPkg, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
if err != nil {
t.Fatal(err)
}
adds = fwdPkg.Adds
settleFails = fwdPkg.SettleFails
if len(adds) != 0 {
t.Fatalf("alice shouldn't forward any HTLC's, instead wants to "+
"forward %v htlcs", len(adds))
@ -5706,10 +5718,16 @@ func TestLockedInHtlcForwardingSkipAfterRestart(t *testing.T) {
t.Fatalf("alice should only forward one HTLC, instead wants to "+
"forward %v htlcs", len(settleFails))
}
if settleFails[0].ParentIndex != htlc2.ID {
fail, ok = settleFails[0].UpdateMsg.(*lnwire.UpdateFailHTLC)
if !ok {
t.Fatalf("expected UpdateFailHTLC, got %T",
settleFails[0].UpdateMsg)
}
if fail.ID != htlc2.ID {
t.Fatalf("alice should forward fail for htlcid=%d, instead "+
"forwarding id=%d", htlc2.ID,
settleFails[0].ParentIndex)
fail.ID)
}
}
@ -6309,13 +6327,13 @@ func TestMaxAsynchronousHtlcs(t *testing.T) {
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err, "unable to revoke revocation")
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "unable to receive revocation")
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err, "unable to revoke revocation")
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "unable to receive revocation")
// Send the final Add which should succeed as in step 6.
@ -6997,7 +7015,7 @@ func TestChannelRestoreUpdateLogs(t *testing.T) {
// sent. However her local commitment chain still won't include the
// state with the HTLC, since she hasn't received a new commitment
// signature from Bob yet.
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "unable to receive revocation")
// Now make Alice send and sign an additional HTLC. We don't let Bob
@ -7173,7 +7191,7 @@ func TestChannelRestoreUpdateLogsFailedHTLC(t *testing.T) {
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err, "unable to revoke commitment")
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "bob unable to process alice's revocation")
// At this point Alice has advanced her local commitment chain to a
@ -7203,7 +7221,7 @@ func TestChannelRestoreUpdateLogsFailedHTLC(t *testing.T) {
// the corresponding Fail from the local update log.
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err, "unable to revoke commitment")
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "unable to receive revocation")
assertInLogs(t, aliceChannel, 0, 0, 0, 0)
@ -7428,7 +7446,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 0, 1, 0)
// Alice receives the revocation, ACKing her pending commitment.
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "unable to receive revocation")
// However, the HTLC is still not locked into her local commitment, so
@ -7457,7 +7475,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
t, aliceChannel, false, 0, 1, 1,
)
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "unable to receive revocation")
// Alice ACKing Bob's pending commitment shouldn't change the heights
@ -7502,7 +7520,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 1, 2, 0)
// Alice receives the revocation, ACKing her pending commitment for Bob.
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err, "unable to receive revocation")
// Alice receiving Bob's revocation should bump both addCommitHeightRemote
@ -7540,7 +7558,7 @@ func TestChannelRestoreCommitHeight(t *testing.T) {
// Bob receives the revocation, which should set both addCommitHeightRemote
// fields to 2.
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err, "unable to receive revocation")
bobChannel = restoreAndAssertCommitHeights(t, bobChannel, true, 0, 2, 2)
@ -7643,7 +7661,7 @@ func TestForceCloseBorkedState(t *testing.T) {
// At this point, all channel mutating methods should now fail as they
// shouldn't be able to proceed if the channel is borked.
_, _, _, _, err = aliceChannel.ReceiveRevocation(revokeMsg)
_, _, err = aliceChannel.ReceiveRevocation(revokeMsg)
if err != channeldb.ErrChanBorked {
t.Fatalf("advance commitment tail should have failed")
}
@ -9436,7 +9454,7 @@ func TestChannelUnsignedAckedFailure(t *testing.T) {
// -----rev----->
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err)
// Alice should sign the next commitment and go down before
@ -9461,7 +9479,7 @@ func TestChannelUnsignedAckedFailure(t *testing.T) {
// <----rev------
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = newAliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = newAliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
// Now Bob sends an HTLC to Alice.
@ -9547,7 +9565,7 @@ func TestChannelLocalUnsignedUpdatesFailure(t *testing.T) {
// <----rev-----
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
// Restart Alice and assert that she can receive Bob's next commitment
@ -9631,7 +9649,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
// <----rev-----
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
// <----sig-----
@ -9658,7 +9676,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
// <----rev-----
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
// Restart Bob's channel state here.
@ -9671,7 +9689,7 @@ func TestChannelSignedAckRegression(t *testing.T) {
// -----rev---->
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err)
fwdPkg, _, _, _, err := newBobChannel.ReceiveRevocation(aliceRevocation)
fwdPkg, _, err := newBobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err)
// Assert that the fwdpkg is not empty.
@ -9763,7 +9781,7 @@ func TestIsChannelClean(t *testing.T) {
// <---rev---
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
@ -9777,7 +9795,7 @@ func TestIsChannelClean(t *testing.T) {
// ---rev--->
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err)
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
@ -9798,7 +9816,7 @@ func TestIsChannelClean(t *testing.T) {
// ---rev--->
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err)
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
@ -9812,7 +9830,7 @@ func TestIsChannelClean(t *testing.T) {
// <---rev---
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
assertCleanOrDirty(true, aliceChannel, bobChannel, t)
@ -9836,7 +9854,7 @@ func TestIsChannelClean(t *testing.T) {
// <---rev---
bobRevocation, _, _, err = bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
assertCleanOrDirty(false, aliceChannel, bobChannel, t)
@ -9851,7 +9869,7 @@ func TestIsChannelClean(t *testing.T) {
// ---rev--->
aliceRevocation, _, _, err = aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err)
assertCleanOrDirty(true, aliceChannel, bobChannel, t)
}
@ -9994,7 +10012,7 @@ func testGetDustSum(t *testing.T, chantype channeldb.ChannelType) {
// dust.
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
checkDust(aliceChannel, htlc2Amt, htlc2Amt)
checkDust(bobChannel, htlc2Amt, htlc2Amt)
@ -10007,7 +10025,7 @@ func testGetDustSum(t *testing.T, chantype channeldb.ChannelType) {
require.NoError(t, err)
aliceRevocation, _, _, err := aliceChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
_, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
require.NoError(t, err)
checkDust(aliceChannel, htlc2Amt, htlc2Amt)
checkDust(bobChannel, htlc2Amt, htlc2Amt)
@ -10967,7 +10985,7 @@ func TestAsynchronousSendingWithFeeBuffer(t *testing.T) {
bobRevocation, _, _, err := bobChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
_, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
require.NoError(t, err)
// Before testing the behavior of the fee buffer, we are going to fail

View File

@ -566,7 +566,7 @@ func ForceStateTransition(chanA, chanB *LightningChannel) error {
return err
}
_, _, _, _, err = chanA.ReceiveRevocation(bobRevocation)
_, _, err = chanA.ReceiveRevocation(bobRevocation)
if err != nil {
return err
}
@ -579,7 +579,7 @@ func ForceStateTransition(chanA, chanB *LightningChannel) error {
if err != nil {
return err
}
_, _, _, _, err = chanB.ReceiveRevocation(aliceRevocation)
_, _, err = chanB.ReceiveRevocation(aliceRevocation)
if err != nil {
return err
}

View File

@ -366,7 +366,7 @@ func testVectors(t *testing.T, chanType channeldb.ChannelType, test testCase) {
revMsg, _, _, err := remoteChannel.RevokeCurrentCommitment()
require.NoError(t, err)
_, _, _, _, err = localChannel.ReceiveRevocation(revMsg)
_, _, err = localChannel.ReceiveRevocation(revMsg)
require.NoError(t, err)
remoteNewCommit, err := remoteChannel.SignNextCommitment()