Skip to content
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

DLC Subsystem. Contract settlement from counterparty works. #459

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions qln/dlc.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ func (nd *LitNode) OfferDlc(peerIdx uint32, cIdx uint64) error {
return err
}

ourPayoutPKHKey, err := nd.GetUsePub(kg, UseContractPayoutPKH)
if err != nil {
logging.Errorf("Error while getting our payout pubkey: %s", err.Error())
c.Status = lnutil.ContractStatusError
nd.DlcManager.SaveContract(c)
return err
}

copy(c.OurPayoutPKH[:], btcutil.Hash160(ourPayoutPKHKey[:]))

// Fund the contract
err = nd.FundContract(c)
if err != nil {
Expand Down Expand Up @@ -227,6 +237,7 @@ func (nd *LitNode) DlcOfferHandler(msg lnutil.DlcOfferMsg, peer *RemotePeer) {
c.OurChangePKH = msg.Contract.TheirChangePKH
c.TheirChangePKH = msg.Contract.OurChangePKH
c.TheirIdx = msg.Contract.Idx
c.TheirPayoutPKH = msg.Contract.OurPayoutPKH

c.Division = make([]lnutil.DlcContractDivision, len(msg.Contract.Division))
for i := 0; i < len(msg.Contract.Division); i++ {
Expand Down Expand Up @@ -324,6 +335,8 @@ func (nd *LitNode) DlcContractAckHandler(msg lnutil.DlcContractAckMsg, peer *Rem

c.Status = lnutil.ContractStatusAcknowledged

c.TheirSettlementSignatures = msg.SettlementSignatures

err = nd.DlcManager.SaveContract(c)
if err != nil {
logging.Errorf("DlcContractAckHandler SaveContract err %s\n", err.Error())
Expand Down