<div dir="ltr">Hey everyone, <div><br></div><div><div class="gmail_quote"><div dir="ltr">On Sun, Aug 26, 2018 at 2:23 PM Christian Decker <<a href="mailto:decker.christian@gmail.com">decker.christian@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The embedded plugins would also be<br>
completely isolated, which is good for autopilots and similar<br>
self-contained things, but not so good for wallets and things that<br>
actually need to talk to the outside world.<br></blockquote></div><div><br></div><div><div>being allowed to write python code I was finally able to do some meaning full contribution (:  I have created a first draft for a c-lightning autopilot in python as a side car.  Some more explainations are in the pull request:</div></div><div><br></div><div><a href="https://github.com/ElementsProject/lightning/pull/1888">https://github.com/ElementsProject/lightning/pull/1888</a><br></div><div><br></div><div>I would love to get some feedback on this before progressing. Currently the lib only takes the network to pythong networkx lib and uses four different heuristics to generate a rather diverse candidate set. The current code has no suggestions of how many funds to allocate to each channel (and how many channels should be opened). However in the pull request I discussed a strategy with which to decide how many funds to allocate for each channel. The key idea is that it makes sense to use a channel balance that is about the average of the channel balances of the suggested partner. I think the following code snippet is easier than explaining the strategy. the results of that code can be seen in the pull request: </div><div><br></div><div>





<p class="gmail-p1" style="margin:0px;font:17px Monaco">pdf = {}</p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-s1" style="color:rgb(4,51,255)">for</span> candidate <span class="gmail-s1" style="color:rgb(4,51,255)">in</span> candidates:</p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-Apple-converted-space">    </span>neighbors = list(self.G.neighbors(candidate))</p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-Apple-converted-space">    </span>capacity = sum([self.G.get_edge_data(candidate, n)[<span class="gmail-s2" style="color:rgb(0,180,0)">"</span><span class="gmail-s3" style="text-decoration:underline;color:rgb(0,180,0)">satoshis</span><span class="gmail-s2" style="color:rgb(0,180,0)">"</span>] <span class="gmail-s1" style="color:rgb(4,51,255)">for</span> n <span class="gmail-s1" style="color:rgb(4,51,255)">in</span> neighbors])</p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-Apple-converted-space">    </span>average = capacity / len(neighbors)</p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-Apple-converted-space">    </span>pdf[candidate] = average</p><p class="gmail-p1" style="margin:0px;font:17px Monaco">cumsum = sum(pdf.values())</p><p class="gmail-p1" style="margin:0px;font:17px Monaco">pdf = {k:v/cumsum <span class="gmail-s1" style="color:rgb(4,51,255)">for</span> k,v <span class="gmail-s1" style="color:rgb(4,51,255)">in</span> pdf.items()}</p><p class="gmail-p1" style="margin:0px;font:17px Monaco">w = <span class="gmail-s6" style="color:rgb(148,17,0)">0.70</span></p><p class="gmail-p3" style="margin:0px;font:17px Monaco;color:rgb(0,180,0)"><span class="gmail-s1" style="color:rgb(4,51,255)">print</span><span class="gmail-s4" style="color:rgb(0,0,0)">(</span>"percentage <span class="gmail-Apple-converted-space">  </span>smoothed percentage<span class="gmail-Apple-converted-space">    </span>capacity<span class="gmail-Apple-converted-space">    </span><span class="gmail-s5" style="text-decoration:underline">numchannels</span> <span class="gmail-Apple-converted-space">    </span>alias"<span class="gmail-s4" style="color:rgb(0,0,0)">)</span></p><p class="gmail-p3" style="margin:0px;font:17px Monaco;color:rgb(0,180,0)"><span class="gmail-s1" style="color:rgb(4,51,255)">print</span><span class="gmail-s4" style="color:rgb(0,0,0)">(</span>"----------------------------------------------------------------------"<span class="gmail-s4" style="color:rgb(0,0,0)">)</span></p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-s1" style="color:rgb(4,51,255)">for</span> k,v <span class="gmail-s1" style="color:rgb(4,51,255)">in</span> pdf.items():</p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-Apple-converted-space">    </span>neighbors = list(self.G.neighbors(k))</p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-Apple-converted-space">    </span>capacity = sum([self.G.get_edge_data(k, n)[<span class="gmail-s2" style="color:rgb(0,180,0)">"</span><span class="gmail-s3" style="text-decoration:underline;color:rgb(0,180,0)">satoshis</span><span class="gmail-s2" style="color:rgb(0,180,0)">"</span>] <span class="gmail-s1" style="color:rgb(4,51,255)">for</span> n <span class="gmail-s1" style="color:rgb(4,51,255)">in</span> neighbors])</p><p class="gmail-p1" style="margin:0px;font:17px Monaco"><span class="gmail-Apple-converted-space">    </span>v = v*<span class="gmail-s6" style="color:rgb(148,17,0)">100</span></p><p class="gmail-p1" style="margin:0px;font:17px Monaco">





















</p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:17px;line-height:normal;font-family:Monaco"><span class="gmail-Apple-converted-space">    </span><span class="gmail-s1" style="color:rgb(4,51,255)">print</span>(<span class="gmail-s2" style="color:rgb(0,180,0)">"{:12.2f}<span class="gmail-Apple-converted-space">  </span>"</span>.format(v), <span class="gmail-s2" style="color:rgb(0,180,0)">"{:12.2f} <span class="gmail-Apple-converted-space">    </span>"</span>.format(w * v + <span class="gmail-s6" style="color:rgb(148,17,0)">100</span>*(<span class="gmail-s6" style="color:rgb(148,17,0)">1</span>-w)/len(candidates)) ,<span class="gmail-s2" style="color:rgb(0,180,0)">"{:10} {:10} <span class="gmail-Apple-converted-space">    </span>"</span>.format( capacity, len(neighbors)), self.G.node[k][<span class="gmail-s2" style="color:rgb(0,180,0)">"alias"</span>] )</p></div><div><br></div><div>with kind regards Rene</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><a href="https://www.rene-pickhardt.de" target="_blank">https://www.rene-pickhardt.de</a></div><div><br></div><div>Skype: rene.pickhardt <br></div><div><br></div><div>mobile: +49 (0)176 5762 3618   </div></div></div></div></div></div></div></div></div>