From 1751aaabfa59b1f18ae4be4265c0afc2ec9a4123 Mon Sep 17 00:00:00 2001 From: PsySc0rpi0n <5173990+PsySc0rpi0n@users.noreply.github.com> Date: Tue, 13 Jun 2023 20:56:58 +0100 Subject: [PATCH] Fix `circular` after CLN breaking change (msat migration) Co-authored-by: PsySc0rpi0n --- go.mod | 22 ++++++------ go.sum | 73 ++++++++++++-------------------------- graph/channel.go | 20 +++++------ graph/graph.go | 12 +++---- graph/route.go | 4 +-- graph/stats.go | 3 +- node/db.go | 2 +- node/payment.go | 2 +- node/peers.go | 4 +-- rebalance/bynode.go | 4 +-- rebalance/parallel/pull.go | 4 +-- rebalance/parallel/push.go | 4 +-- rebalance/params.go | 4 +-- 13 files changed, 60 insertions(+), 98 deletions(-) diff --git a/go.mod b/go.mod index 0f5ab87..aa2918a 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,20 @@ module circular -go 1.18 +go 1.20 require ( - github.com/dgraph-io/badger/v3 v3.2103.2 - github.com/elementsproject/glightning v0.0.0-20220502095901-74f998c51367 - github.com/gammazero/deque v0.2.0 + github.com/dgraph-io/badger/v4 v4.1.0 + github.com/elementsproject/glightning v0.0.0-20230525134205-ef34d849f564 + github.com/gammazero/deque v0.2.1 github.com/robfig/cron/v3 v3.0.1 - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.8.4 github.com/virtuald/go-paniclog v0.0.0-20190812204905-43a7fa316459 ) require ( - github.com/cespare/xxhash v1.1.0 // indirect - github.com/cespare/xxhash/v2 v2.1.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgraph-io/ristretto v0.1.0 // indirect + github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect @@ -24,10 +23,11 @@ require ( github.com/golang/snappy v0.0.3 // indirect github.com/google/flatbuffers v1.12.1 // indirect github.com/klauspost/compress v1.12.3 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opencensus.io v0.22.5 // indirect - golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect - golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index c7103d0..5ee736c 100644 --- a/go.sum +++ b/go.sum @@ -1,33 +1,25 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8= -github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M= -github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= -github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= +github.com/dgraph-io/badger/v4 v4.1.0 h1:E38jc0f+RATYrycSUf9LMv/t47XAy+3CApyYSq4APOQ= +github.com/dgraph-io/badger/v4 v4.1.0/go.mod h1:P50u28d39ibBRmIJuQC/NSdBOg46HnHw7al2SW5QRHg= +github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= +github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/elementsproject/glightning v0.0.0-20220502095901-74f998c51367 h1:q1fJg4S6S+ZMBC5STPZPLCQU4tvIq17/7ZEmKO/4bVU= -github.com/elementsproject/glightning v0.0.0-20220502095901-74f998c51367/go.mod h1:YAdIeSyx8VEhDCtEaGOJLmWNpPaQ3x4vYSAj9Vrppdo= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gammazero/deque v0.2.0 h1:SkieyNB4bg2/uZZLxvya0Pq6diUlwx7m2TeT7GAIWaA= -github.com/gammazero/deque v0.2.0/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= +github.com/elementsproject/glightning v0.0.0-20230525134205-ef34d849f564 h1:orSb6yU9D1Ow9epbRZJVAfGF6vC1HxaPqg9zLWga6Hw= +github.com/elementsproject/glightning v0.0.0-20230525134205-ef34d849f564/go.mod h1:YAdIeSyx8VEhDCtEaGOJLmWNpPaQ3x4vYSAj9Vrppdo= +github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0= +github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -43,52 +35,30 @@ github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.12.3 h1:G5AfA94pHPysR56qqrkO2pxEexdDzrpFJ6yt/VqWxVU= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/virtuald/go-paniclog v0.0.0-20190812204905-43a7fa316459 h1:x9pIfbdIjnw+Ylb2vE27Gtqb7BDmfR+nLcJwvbJh98U= github.com/virtuald/go-paniclog v0.0.0-20190812204905-43a7fa316459/go.mod h1:nFvuG3SWu3VWqobG3cX8nt57wXU0OOFapeCs/8axIuM= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -105,8 +75,9 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -115,13 +86,13 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -143,8 +114,8 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/graph/channel.go b/graph/channel.go index 7fdba6c..d492e30 100644 --- a/graph/channel.go +++ b/graph/channel.go @@ -2,8 +2,6 @@ package graph import ( "github.com/elementsproject/glightning/glightning" - "strconv" - "strings" "time" ) @@ -11,19 +9,17 @@ type Channel struct { *glightning.Channel `json:"channel"` Liquidity uint64 `json:"liquidity"` Timestamp int64 `json:"timestamp"` - maxHtlcMsat uint64 `json:"-"` - minHtlcMsat uint64 `json:"-"` + maxHtlcMsat uint64 + minHtlcMsat uint64 } func NewChannel(channel *glightning.Channel, liquidity uint64, timestamp int64) *Channel { - maxHtlcMsat, _ := strconv.ParseUint(strings.TrimSuffix(channel.HtlcMaximumMilliSatoshis, "msat"), 10, 64) - minHtlcMsat, _ := strconv.ParseUint(strings.TrimSuffix(channel.HtlcMinimumMilliSatoshis, "msat"), 10, 64) return &Channel{ Channel: channel, Liquidity: liquidity, Timestamp: timestamp, - maxHtlcMsat: maxHtlcMsat, - minHtlcMsat: minHtlcMsat, + maxHtlcMsat: channel.HtlcMaximumMilliSatoshis.MSat(), + minHtlcMsat: channel.HtlcMinimumMilliSatoshis.MSat(), } } @@ -43,17 +39,17 @@ func (c *Channel) ComputeFeePPM(amount uint64) uint64 { return c.ComputeFee(amount) * 1000000 / amount } -func (c *Channel) GetHop(amount uint64, delay uint) glightning.RouteHop { +func (c *Channel) GetHop(amount uint64, delay uint32) glightning.RouteHop { return glightning.RouteHop{ Id: c.Destination, ShortChannelId: c.ShortChannelId, - MilliSatoshi: amount, + AmountMsat: glightning.AmountFromMSat(amount), Delay: delay, Direction: c.GetDirection(), } } -func (c *Channel) GetDirection() uint8 { +func (c *Channel) GetDirection() uint32 { if c.Source < c.Destination { return 0 } @@ -68,6 +64,6 @@ func (c *Channel) CanForward(amount uint64) bool { } func (c *Channel) ResetLiquidity() { - c.Liquidity = uint64(0.5 * float64(c.Satoshis*1000)) + c.Liquidity = uint64(0.5 * float64(c.AmountMsat.MSat())) c.Timestamp = time.Now().Unix() } diff --git a/graph/graph.go b/graph/graph.go index e110cbb..4bdb4e6 100644 --- a/graph/graph.go +++ b/graph/graph.go @@ -3,8 +3,6 @@ package graph import ( "circular/util" "github.com/elementsproject/glightning/glightning" - "strconv" - "strings" "sync" "time" ) @@ -78,12 +76,10 @@ func (g *Graph) AddChannel(c *Channel) { g.Inbound[c.Destination][c.Source] = append(g.Inbound[c.Destination][c.Source], c.ShortChannelId) if c.maxHtlcMsat == 0 { - maxHtlcMsat, _ := strconv.ParseUint(strings.TrimSuffix(c.HtlcMaximumMilliSatoshis, "msat"), 10, 64) - c.maxHtlcMsat = maxHtlcMsat + c.maxHtlcMsat = c.HtlcMaximumMilliSatoshis.MSat() } if c.minHtlcMsat == 0 { - minHtlcMsat, _ := strconv.ParseUint(strings.TrimSuffix(c.HtlcMinimumMilliSatoshis, "msat"), 10, 64) - c.minHtlcMsat = minHtlcMsat + c.minHtlcMsat = c.HtlcMinimumMilliSatoshis.MSat() } } @@ -99,7 +95,7 @@ func (g *Graph) RefreshChannels(channelList []*glightning.Channel) { channelId := c.ShortChannelId + "/" + util.GetDirection(c.Source, c.Destination) // if the channel did not exist prior to this refresh estimate its initial liquidity to be 50/50 if _, ok := g.Channels[channelId]; !ok { - channel = NewChannel(c, uint64(0.5*float64(c.Satoshis*1000)), 0) + channel = NewChannel(c, uint64(0.5*float64(c.AmountMsat.MSat())), 0) g.AddChannel(channel) } else { channel = NewChannel(c, g.Channels[channelId].Liquidity, g.Channels[channelId].Timestamp) @@ -175,7 +171,7 @@ func (g *Graph) UpdateChannel(channelId, oppositeChannelId string, amount uint64 if _, ok := g.Channels[oppositeChannelId]; ok { g.Channels[oppositeChannelId].Liquidity = - g.Channels[oppositeChannelId].Satoshis*1000 - amount + g.Channels[oppositeChannelId].AmountMsat.MSat() - amount g.Channels[oppositeChannelId].Timestamp = now } } diff --git a/graph/route.go b/graph/route.go index dddde32..9224a39 100644 --- a/graph/route.go +++ b/graph/route.go @@ -77,8 +77,8 @@ func (r *Route) ToLightningRoute() []glightning.RouteHop { hops = append(hops, glightning.RouteHop{ Id: hop.Destination, ShortChannelId: hop.ShortChannelId, - MilliSatoshi: hop.MilliSatoshi, - Delay: hop.Delay, + AmountMsat: glightning.AmountFromMSat(hop.MilliSatoshi), + Delay: uint32(hop.Delay), Direction: hop.GetDirection(), }) } diff --git a/graph/stats.go b/graph/stats.go index 902560c..cc1640b 100644 --- a/graph/stats.go +++ b/graph/stats.go @@ -2,7 +2,6 @@ package graph import ( "strconv" - "strings" ) type Stats struct { @@ -29,7 +28,7 @@ func (g *Graph) GetStats() *Stats { if c.Liquidity >= 200000000 { atLeast200kLiquidity++ } - maxHtlc, _ := strconv.ParseUint(strings.TrimSuffix(c.HtlcMaximumMilliSatoshis, "msat"), 10, 64) + maxHtlc := c.HtlcMaximumMilliSatoshis.MSat() if maxHtlc >= 200000000 { atLeast200kMaxHtlc++ } diff --git a/node/db.go b/node/db.go index 48504f3..0e9c442 100644 --- a/node/db.go +++ b/node/db.go @@ -3,7 +3,7 @@ package node import ( "circular/graph" "encoding/json" - badger "github.com/dgraph-io/badger/v3" + "github.com/dgraph-io/badger/v4" "github.com/elementsproject/glightning/glightning" "log" "time" diff --git a/node/payment.go b/node/payment.go index 61bd4de..086bb27 100644 --- a/node/payment.go +++ b/node/payment.go @@ -4,7 +4,7 @@ import ( "circular/graph" "circular/util" "errors" - "github.com/dgraph-io/badger/v3" + "github.com/dgraph-io/badger/v4" "github.com/elementsproject/glightning/glightning" "time" ) diff --git a/node/peers.go b/node/peers.go index ac1e02e..6d03582 100644 --- a/node/peers.go +++ b/node/peers.go @@ -104,13 +104,13 @@ func (n *Node) UpdateChannelBalance(outPeer, inPeer, outScid, inScid string, amo for _, channel := range n.Peers[outPeer].Channels { if channel.ShortChannelId == outScid { - channel.MilliSatoshiToUs -= amount * 1000 + channel.ToUsMsat = glightning.AmountFromMSat(channel.ToUsMsat.MSat() - amount*1000) break } } for _, channel := range n.Peers[inPeer].Channels { if channel.ShortChannelId == inScid { - channel.MilliSatoshiToUs += amount * 1000 + channel.ToUsMsat = glightning.AmountFromMSat(channel.ToUsMsat.MSat() + amount*1000) break } } diff --git a/rebalance/bynode.go b/rebalance/bynode.go index 9c3a31c..8f5a0fa 100644 --- a/rebalance/bynode.go +++ b/rebalance/bynode.go @@ -28,14 +28,14 @@ func (r *RebalanceByNode) New() interface{} { func (r *RebalanceByNode) getBestOutgoingChannel() (*graph.Channel, error) { bestScid := r.Node.GetBestPeerChannel(r.OutNode, func(channel *glightning.PeerChannel) uint64 { - return channel.MilliSatoshiToUs + return channel.ToUsMsat.MSat() }).ShortChannelId return r.Node.GetOutgoingChannelFromScid(bestScid) } func (r *RebalanceByNode) getBestIncomingChannel() (*graph.Channel, error) { bestScid := r.Node.GetBestPeerChannel(r.InNode, func(channel *glightning.PeerChannel) uint64 { - return channel.MilliSatoshiTotal - channel.MilliSatoshiToUs + return channel.TotalMsat.MSat() - channel.ToUsMsat.MSat() }).ShortChannelId return r.Node.GetIncomingChannelFromScid(bestScid) } diff --git a/rebalance/parallel/pull.go b/rebalance/parallel/pull.go index 2b0fc03..018ba90 100644 --- a/rebalance/parallel/pull.go +++ b/rebalance/parallel/pull.go @@ -86,9 +86,9 @@ func (r *RebalancePull) IsGoodCandidate(peerChannel *glightning.PeerChannel) boo // Check that the channel is not under the deplete threshold and connection is active func (r *RebalancePull) CanUseChannel(channel *glightning.PeerChannel) error { depleteAmount := util.Min(r.DepleteUpToAmount, - uint64(float64(channel.MilliSatoshiTotal)*r.DepleteUpToPercent)) + uint64(float64(channel.TotalMsat.MSat())*r.DepleteUpToPercent)) r.Node.Logln(glightning.Debug, "depleteAmount:", depleteAmount) - if channel.MilliSatoshiToUs < depleteAmount { + if channel.ToUsMsat.MSat() < depleteAmount { return util.ErrChannelDepleted } diff --git a/rebalance/parallel/push.go b/rebalance/parallel/push.go index d8dacf0..cb0cb08 100644 --- a/rebalance/parallel/push.go +++ b/rebalance/parallel/push.go @@ -95,9 +95,9 @@ func (r *RebalancePush) IsGoodCandidate(peerChannel *glightning.PeerChannel) boo func (r *RebalancePush) CanUseChannel(channel *glightning.PeerChannel) error { // check that the channel is not over the fill threshold fillAmount := util.Min(r.FillUpToAmount, - uint64(float64(channel.MilliSatoshiTotal)*r.FillUpToPercent)) + uint64(float64(channel.TotalMsat.MSat())*r.FillUpToPercent)) r.Node.Logln(glightning.Debug, "fillAmount:", fillAmount) - if (channel.MilliSatoshiTotal - channel.MilliSatoshiToUs) < fillAmount { + if (channel.TotalMsat.MSat() - channel.ToUsMsat.MSat()) < fillAmount { return util.ErrChannelFilled } diff --git a/rebalance/params.go b/rebalance/params.go index aa0f667..54413b8 100644 --- a/rebalance/params.go +++ b/rebalance/params.go @@ -35,10 +35,10 @@ func (r *Rebalance) checkConnections(inChannel, outChannel *glightning.PeerChann func (r *Rebalance) checkLiquidity(inChannel, outChannel *glightning.PeerChannel) error { //validate that the amount is less than the liquidity of the channels - if (inChannel.MilliSatoshiTotal - inChannel.MilliSatoshiToUs) < r.Amount { + if (inChannel.TotalMsat.MSat() - inChannel.ToUsMsat.MSat()) < r.Amount { return util.ErrIncomingChannelDepleted } - if (outChannel.MilliSatoshiToUs) < r.Amount { + if (outChannel.ToUsMsat.MSat()) < r.Amount { return util.ErrOutgoingChannelDepleted } return nil