|
func (manager *htlcManager) getPath(obdClient *ObdNode, msgData string) (path interface{}, err error) { |
|
manager.mu.Lock() |
|
defer manager.mu.Unlock() |
|
|
|
log.Println("getPath", msgData) |
|
if tool.CheckIsString(&msgData) == false { |
|
return "", errors.New("wrong inputData") |
|
} |
|
pathRequest := &bean.HtlcPathRequest{} |
|
err = json.Unmarshal([]byte(msgData), pathRequest) |
|
if err != nil { |
|
return "", err |
|
} |
|
|
|
if tool.CheckIsString(&pathRequest.RealPayerPeerId) == false { |
|
return "", errors.New("wrong realPayerPeerId") |
|
} |
|
if tool.CheckIsString(&pathRequest.PayeePeerId) == false { |
|
return "", errors.New("wrong SendeePeerId") |
|
} |
|
if pathRequest.Amount < tool.GetOmniDustBtc() { |
|
return "", errors.New("wrong amount") |
|
} |
|
|
|
manager.createChannelNetwork(pathRequest.RealPayerPeerId, pathRequest.PayeePeerId, pathRequest.PropertyId, pathRequest.Amount, nil, true) |
|
resultIndex := manager.getPathIndex() |
|
|
|
retNode := make(map[string]interface{}) |
|
retNode["senderPeerId"] = pathRequest.RealPayerPeerId |
|
retNode["h"] = pathRequest.H |
|
retNode["amount"] = pathRequest.Amount |
|
retNode["path"] = "" |
|
if resultIndex != -1 { |
|
splitArr := strings.Split(manager.openList[resultIndex].ChannelIds, ",") |
|
path := "" |
|
for i := len(splitArr) - 1; i > -1; i-- { |
|
path += splitArr[i] + "," |
|
} |
|
path = strings.TrimSuffix(path, ",") |
|
retNode["path"] = path |
|
} |
|
log.Println("return path info", retNode) |
|
return retNode, nil |
|
} |
this issue is the 11 bug in issue 53: #53
obd/tracker/service/htlc_service.go
Lines 40 to 83 in 5829315