lnwallet: AddHTLC now returns log index of created log entry
This commit is contained in:
parent
2a57f9182a
commit
2c303a1879
@ -998,7 +998,7 @@ func (lc *LightningChannel) ExtendRevocationWindow() (*lnwire.CommitRevocation,
|
|||||||
|
|
||||||
// AddPayment adds a new HTLC to either the local or remote HTLC log depending
|
// AddPayment adds a new HTLC to either the local or remote HTLC log depending
|
||||||
// on the value of 'incoming'.
|
// on the value of 'incoming'.
|
||||||
func (lc *LightningChannel) AddHTLC(htlc *lnwire.HTLCAddRequest, incoming bool) error {
|
func (lc *LightningChannel) AddHTLC(htlc *lnwire.HTLCAddRequest, incoming bool) uint32 {
|
||||||
pd := &PaymentDescriptor{
|
pd := &PaymentDescriptor{
|
||||||
entryType: Add,
|
entryType: Add,
|
||||||
RHash: PaymentHash(htlc.RedemptionHashes[0]),
|
RHash: PaymentHash(htlc.RedemptionHashes[0]),
|
||||||
@ -1019,7 +1019,7 @@ func (lc *LightningChannel) AddHTLC(htlc *lnwire.HTLCAddRequest, incoming bool)
|
|||||||
pd.Index = index
|
pd.Index = index
|
||||||
lc.stateUpdateLog.PushBack(pd)
|
lc.stateUpdateLog.PushBack(pd)
|
||||||
|
|
||||||
return nil
|
return index
|
||||||
}
|
}
|
||||||
|
|
||||||
// SettleHTLC attempts to settle an existing outstanding HTLC with an htlc
|
// SettleHTLC attempts to settle an existing outstanding HTLC with an htlc
|
||||||
|
@ -225,15 +225,11 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
|||||||
|
|
||||||
// First Alice adds the outgoing HTLC to her local channel's state
|
// First Alice adds the outgoing HTLC to her local channel's state
|
||||||
// update log.
|
// update log.
|
||||||
if err := aliceChannel.AddHTLC(htlc, false); err != nil {
|
aliceChannel.AddHTLC(htlc, false)
|
||||||
t.Fatalf("unable to add htlc to alice's channel: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then Alice sends this wire message over to Bob who also adds this
|
// Then Alice sends this wire message over to Bob who also adds this
|
||||||
// htlc to his local state update log.
|
// htlc to his local state update log.
|
||||||
if err := bobChannel.AddHTLC(htlc, true); err != nil {
|
bobChannel.AddHTLC(htlc, true)
|
||||||
t.Fatalf("unable to add htlc bob's channel: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next alice commits this change by sending a signature message.
|
// Next alice commits this change by sending a signature message.
|
||||||
aliceSig, bobLogIndex, err := aliceChannel.SignNextCommitment()
|
aliceSig, bobLogIndex, err := aliceChannel.SignNextCommitment()
|
||||||
|
Loading…
Reference in New Issue
Block a user