omnilaboratory / obd

OmniBOLT daemon, a golang implementation of OmniBOLT spec, the smart assets lightning network.
MIT License
213 stars 21 forks source link

channelInfo's fields on tracker are different to the obd. #56

Open neocarmack opened 2 years ago

neocarmack commented 2 years ago

This issue is the tenth bug in issue 53: https://github.com/omnilaboratory/obd/issues/53

  1. channelInfo's fields are different from the obd.
    when obd commits channelInfo to a tracker, now we have the code to convert:

    //infoRequest is the data submit to tracker
    infoRequest.PeerIdA = channelInfo.PeerIdA
    infoRequest.PeerIdB = channelInfo.PeerIdB
    
    infoRequest.IsAlice = false
    if commitmentTx.Id > 0 {
        if commitmentTx.Owner == channelInfo.PeerIdA {
            infoRequest.IsAlice = true
            infoRequest.AmountA = commitmentTx.AmountToRSMC
            infoRequest.AmountB = commitmentTx.AmountToCounterparty
        } else {
            infoRequest.AmountB = commitmentTx.AmountToRSMC
            infoRequest.AmountA = commitmentTx.AmountToCounterparty
        }
    }

    We should modify channelInfo's fields to be the same as the tracker. It will be easy when updates the sync mode between the obd and tracker.

channelInfo.IsAlice should be a function, it's a computed field. For example:

func (c *channelInfo)IsAlice(currentUserPeerID) bool{
    return c.PeerIdA==currentUserPeerID
}