diff --git a/go.mod b/go.mod index e5cff0493..ed86d6666 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( decred.org/dcrdex v0.6.3 - decred.org/dcrwallet/v3 v3.0.1 decred.org/dcrwallet/v4 v4.1.1 gioui.org v0.7.0 github.com/JohannesKaufmann/html-to-markdown v1.2.1 @@ -57,7 +56,7 @@ require ( github.com/onsi/gomega v1.10.5 github.com/tyler-smith/go-bip39 v1.1.0 github.com/yeqown/go-qrcode v1.5.1 - go.etcd.io/bbolt v1.3.8 + go.etcd.io/bbolt v1.3.9 golang.org/x/crypto v0.23.0 golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91 golang.org/x/image v0.10.0 @@ -116,10 +115,8 @@ require ( github.com/decred/dcrd/txscript/v3 v3.0.0 // indirect github.com/decred/dcrtime v0.0.0-20191018193024-8d8b4ef0458e // indirect github.com/decred/go-socks v1.1.0 // indirect - github.com/decred/vspd/client/v2 v2.1.0 // indirect - github.com/decred/vspd/types v1.1.0 // indirect github.com/dgraph-io/ristretto v0.0.2 // indirect - github.com/dustin/go-humanize v1.0.1-0.20210705192016-249ff6c91207 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/edsrzf/mmap-go v1.0.0 // indirect github.com/ethereum/go-ethereum v1.11.5 // indirect github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect @@ -159,7 +156,7 @@ require ( github.com/jrick/wsrpc/v2 v2.3.5 // indirect github.com/kkdai/bstream v1.0.0 // indirect github.com/klauspost/compress v1.15.15 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.4 // indirect @@ -176,7 +173,7 @@ require ( github.com/ltcsuite/ltcd/ltcutil/psbt v1.1.1-0.20240131072528-64dfa402637a // indirect github.com/marcopeereboom/sbox v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -207,7 +204,7 @@ require ( golang.org/x/sys v0.20.0 // indirect golang.org/x/term v0.20.0 // indirect golang.org/x/time v0.3.0 // indirect - google.golang.org/protobuf v1.34.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect @@ -229,4 +226,4 @@ replace github.com/lib/pq => github.com/lib/pq v1.10.4 replace github.com/btcsuite/btcwallet v0.16.10-0.20230706223227-037580c66b74 => github.com/btcsuite/btcwallet v0.16.9 // https://github.com/ukane-philemon/dcrdex/tree/btc-node -replace decred.org/dcrdex v0.6.3 => github.com/ukane-philemon/dcrdex v0.0.0-20240610032745-5750210859cb +replace decred.org/dcrdex v0.6.3 => github.com/ukane-philemon/dcrdex v0.0.0-20240702002443-384278ca5340 diff --git a/go.sum b/go.sum index f9cfc18dd..da4b4086d 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,6 @@ decred.org/cspp/v2 v2.2.0 h1:VSOUC1w0Wo+QOGS0r1XO6TLnO16X67KuvpDmRRYyr08= decred.org/cspp/v2 v2.2.0/go.mod h1:9nO3bfvCheOPIFZw5f6sRQ42CjBFB5RKSaJ9Iq6G4MA= decred.org/dcrwallet v1.7.0 h1:U/ew00YBdUlx3rJAynt2OdKDgGzBKK4O89FijBq8iVg= decred.org/dcrwallet v1.7.0/go.mod h1:hNOGyvH53gWdgFB601/ubGRzCPfPtWnEVAi9Grs90y4= -decred.org/dcrwallet/v3 v3.0.1 h1:+OLi+u/MvKc3Ubcnf19oyG/a5hJ/qp4OtezdiQZnLIs= -decred.org/dcrwallet/v3 v3.0.1/go.mod h1:a+R8BZIOKVpWVPat5VZoBWNh/cnIciwcRkPtrzfS/tw= decred.org/dcrwallet/v4 v4.1.1 h1:imwPBboytp1PH6V8q7/JLTHiKgj/Scq9a3I1WmnJv0Y= decred.org/dcrwallet/v4 v4.1.1/go.mod h1:WxerkRcUGVreJsAI0ptCBPUujPUmWncbdYbme8Kl5r0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -565,12 +563,8 @@ github.com/decred/slog v1.0.0/go.mod h1:zR98rEZHSnbZ4WHZtO0iqmSZjDLKhkXfrPTZQKtA github.com/decred/slog v1.1.0/go.mod h1:kVXlGnt6DHy2fV5OjSeuvCJ0OmlmTF6LFpEPMu/fOY0= github.com/decred/slog v1.2.0 h1:soHAxV52B54Di3WtKLfPum9OFfWqwtf/ygf9njdfnPM= github.com/decred/slog v1.2.0/go.mod h1:kVXlGnt6DHy2fV5OjSeuvCJ0OmlmTF6LFpEPMu/fOY0= -github.com/decred/vspd/client/v2 v2.1.0 h1:RzwmM/FCvpJDskNMeqeJ8UNnlR7kLCl3JlG8iZiLbG0= -github.com/decred/vspd/client/v2 v2.1.0/go.mod h1:r/CtdQF7TmuoIaFuanHtUMYYlQxWgRBGapdn4b+Bouc= github.com/decred/vspd/client/v3 v3.0.0 h1:4gAGDTeIU0r4quCxmV5Ez7T2J+P+OLPSibkCF+/Yb6w= github.com/decred/vspd/client/v3 v3.0.0/go.mod h1:5pfPvIa6V38AmophMrKUCl3KMpEIxcltWtgL2R+wsW8= -github.com/decred/vspd/types v1.1.0 h1:hTeqQwgRUN2FGIbuCIdyzBejKV+jxKrmEIcLKxpsB1g= -github.com/decred/vspd/types v1.1.0/go.mod h1:THsO8aBSwWBq6ZsIG25cNqbkNb+EEASXzLhFvODVc0s= github.com/decred/vspd/types/v2 v2.1.0 h1:cUVlmHPeLVsksPRnr2WHsmC2t1Skl6g1WH0HmpcPS7w= github.com/decred/vspd/types/v2 v2.1.0/go.mod h1:2xnNqedkt9GuL+pK8uIzDxqYxFlwLRflYFJH64b76n0= github.com/denis-tingajkin/go-header v0.4.2/go.mod h1:eLRHAVXzE5atsKAnNRDB90WHCFFnBUn4RN0nRcs1LJA= @@ -590,8 +584,8 @@ github.com/docker/docker v1.6.2 h1:HlFGsy+9/xrgMmhmN+NGhCc5SHGJ7I+kHosRR1xc/aI= github.com/docker/docker v1.6.2/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.1-0.20210705192016-249ff6c91207 h1:06VJ6lVl9r9kvzqs3r1gSfUDm6aiMKmyaZyLVc2ShmA= -github.com/dustin/go-humanize v1.0.1-0.20210705192016-249ff6c91207/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= @@ -1115,8 +1109,8 @@ github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9 github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -1213,8 +1207,9 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= @@ -1588,8 +1583,8 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ukane-philemon/dcrdex v0.0.0-20240610032745-5750210859cb h1:x510yGrmUKzRG9/kfMmmKRyqLaRYAGb1yJ+1OReAhIk= -github.com/ukane-philemon/dcrdex v0.0.0-20240610032745-5750210859cb/go.mod h1:t9ur12VGbTof3MPbvnmOBSvufxFE4w4fGlWt83lE2vY= +github.com/ukane-philemon/dcrdex v0.0.0-20240702002443-384278ca5340 h1:9zww9DabSvrNDoknMv9p/G2T8d1pm2pMhZ6kcI30G6I= +github.com/ukane-philemon/dcrdex v0.0.0-20240702002443-384278ca5340/go.mod h1:kDrMHtJOGEq0Og28U0DTQnsuUz7V0bjrAnMIZbpzeIw= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= @@ -1649,8 +1644,8 @@ go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.5-0.20200615073812-232d8fc87f50/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= -go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI= +go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c/go.mod h1:xCI7ZzBfRuGgBXyXO6yfWfDmlWd35khcWpUa4L0xI/k= go.etcd.io/etcd/api/v3 v3.5.0-alpha.0/go.mod h1:mPcW6aZJukV6Aa81LSKpBjQXTWlXB5r74ymPoSWa3Sw= @@ -2049,6 +2044,7 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -2429,8 +2425,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= -google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/libwallet/assets/dcr/dex_wallet.go b/libwallet/assets/dcr/dex_wallet.go index 5511bb9f6..141ec9530 100644 --- a/libwallet/assets/dcr/dex_wallet.go +++ b/libwallet/assets/dcr/dex_wallet.go @@ -19,11 +19,7 @@ import ( dexdcr "decred.org/dcrdex/client/asset/dcr" "decred.org/dcrdex/dex" - // Version v3 of dcrwallet library is still in use because dcrdex is yet to upgrade - // to dcrd v2. - walletjson "decred.org/dcrwallet/v3/rpc/jsonrpc/types" - wallettypes "decred.org/dcrwallet/v3/rpc/jsonrpc/types" - dcrwalletv3 "decred.org/dcrwallet/v3/wallet" + walletjson "decred.org/dcrwallet/v4/rpc/jsonrpc/types" walleterrors "decred.org/dcrwallet/v4/errors" dcrwallet "decred.org/dcrwallet/v4/wallet" @@ -125,13 +121,6 @@ func (dw *DEXWallet) Accounts() dexdcr.XCWalletAccounts { } } -// NotifyOnTipChange is not used, in favor of the tipNotifier pattern. See: -// https://github.com/decred/dcrdex/blob/master/client/asset/dcr/spv.go#513. -// Part of the Wallet interface. -func (dw *DEXWallet) NotifyOnTipChange(_ context.Context, _ dexdcr.TipChangeCallback) bool { - return false -} - // AddressInfo returns information for the provided address. It is an error // if the address is not owned by the wallet. // Part of the Wallet interface. @@ -580,37 +569,50 @@ func (dw *DEXWallet) AddressPrivKey(ctx context.Context, addr stdaddr.Address) ( return privKey, err } -func (dw *DEXWallet) ListSinceBlock(ctx context.Context, start, end, syncHeight int32) ([]walletjson.ListTransactionsResult, error) { - data, err := dw.w.ListSinceBlock(ctx, start, end, syncHeight) - var array = make([]walletjson.ListTransactionsResult, len(data)) - // To faciliate backwards compatibity with dcrdex that is yet to upgrade to - // dcrwallet v4, copy v4 data into a v3 instance. - for _, val := range data { - var txType = wallettypes.ListTransactionsTxType(*val.TxType) - newVal := walletjson.ListTransactionsResult{ - Account: val.Account, - Address: val.Address, - Amount: val.Amount, - BlockHash: val.BlockHash, - BlockIndex: val.BlockIndex, - BlockTime: val.BlockTime, - Category: val.Category, - Confirmations: val.Confirmations, - Fee: val.Fee, - Generated: val.Generated, - InvolvesWatchOnly: val.InvolvesWatchOnly, - Time: val.Time, - TimeReceived: val.TimeReceived, - TxID: val.TxID, - TxType: &txType, - Vout: val.Vout, - WalletConflicts: val.WalletConflicts, - Comment: val.Comment, - OtherAccount: val.OtherAccount, +func (dw *DEXWallet) ListSinceBlock(ctx context.Context, start int32) ([]dexdcr.ListTransactionsResult, error) { + res := make([]dexdcr.ListTransactionsResult, 0) + f := func(block *dcrwallet.Block) (bool, error) { + for _, tx := range block.Transactions { + convertTxType := func(txType dcrwallet.TransactionType) *walletjson.ListTransactionsTxType { + switch txType { + case dcrwallet.TransactionTypeTicketPurchase: + txType := walletjson.LTTTTicket + return &txType + case dcrwallet.TransactionTypeVote: + txType := walletjson.LTTTVote + return &txType + case dcrwallet.TransactionTypeRevocation: + txType := walletjson.LTTTRevocation + return &txType + case dcrwallet.TransactionTypeCoinbase: + case dcrwallet.TransactionTypeRegular: + txType := walletjson.LTTTRegular + return &txType + } + log.Warnf("unknown transaction type %v", tx.Type) + regularTxType := walletjson.LTTTRegular + return ®ularTxType + } + fee := tx.Fee.ToUnit(dcrutil.AmountCoin) + var blockIndex, blockTime int64 + if block.Header != nil { + blockIndex = int64(block.Header.Height) + blockTime = block.Header.Timestamp.Unix() + } + res = append(res, dexdcr.ListTransactionsResult{ + TxID: tx.Hash.String(), + BlockIndex: &blockIndex, + BlockTime: blockTime, + Send: len(tx.MyInputs) > 0, + TxType: convertTxType(tx.Type), + Fee: &fee, + }) } - array = append(array, newVal) + return false, nil } - return array, err + + startID := dcrwallet.NewBlockIdentifierFromHeight(start) + return res, dw.w.GetTransactions(ctx, f, startID, nil) } // Part of the Wallet interface. @@ -623,7 +625,7 @@ func (dw *DEXWallet) Reconfigure(_ context.Context, _ *dexasset.WalletConfig, _ // PurchaseTickets purchases n tickets. vspHost and vspPubKey only // needed for internal wallets. -func (dw *DEXWallet) PurchaseTickets(_ context.Context, _ int, _, _ string, _ *dexdcr.MixingConfig) ([]*dexasset.Ticket, error) { +func (dw *DEXWallet) PurchaseTickets(_ context.Context, _ int, _, _ string, _ bool) ([]*dexasset.Ticket, error) { return nil, errors.New("PurchaseTickets not implemented by Cryptopower DEX wallet") } @@ -648,6 +650,6 @@ func (dw *DEXWallet) SetTxFee(_ context.Context, _ dcrutil.Amount) error { return errors.New("SetTxFee not implemented by Cryptopower DEX wallet") } -func (dw *DEXWallet) StakeInfo(_ context.Context) (*dcrwalletv3.StakeInfoData, error) { +func (dw *DEXWallet) StakeInfo(_ context.Context) (*dcrwallet.StakeInfoData, error) { return nil, errors.New("StakeInfo not implemented by Cryptopower DEX wallet") } diff --git a/ui/page/components/wallet_sync_info.go b/ui/page/components/wallet_sync_info.go index 13c98e452..3458663ee 100644 --- a/ui/page/components/wallet_sync_info.go +++ b/ui/page/components/wallet_sync_info.go @@ -27,15 +27,20 @@ type WalletSyncInfo struct { syncSwitch *cryptomaterial.Switch toBackup cryptomaterial.Button - isStatusConnected bool - reload Reload - backup func(sharedW.Asset) - ForwardButton cryptomaterial.IconButton - syncProgressInfoMutex sync.Mutex + isStatusConnected bool + reload Reload + backup func(sharedW.Asset) + ForwardButton cryptomaterial.IconButton IsSlider bool } +// SyncProgressInfo is made independent of the walletInfo struct so that once +// set with a value, it always persists till unset. This will help address the +// progress bar issue where, changing UI pages alters the progress on the sync +// status progress percentage. Stores sharedW.Asset : ProgressInfo. +var syncProgressInfo = sync.Map{} + type ProgressInfo struct { remainingSyncTime string HeadersToFetchOrScan int32 @@ -45,12 +50,6 @@ type ProgressInfo struct { type Reload func() -// SyncProgressInfo is made independent of the walletInfo struct so that once -// set with a value, it always persists till unset. This will help address the -// progress bar issue where, changing UI pages alters the progress on the sync -// status progress percentage. -var syncProgressInfo = map[sharedW.Asset]ProgressInfo{} - func NewWalletSyncInfo(l *load.Load, wallet sharedW.Asset, reload Reload, backup func(sharedW.Asset)) *WalletSyncInfo { wsi := &WalletSyncInfo{ Load: l, @@ -495,20 +494,21 @@ func (wsi *WalletSyncInfo) layoutAutoSyncSection(gtx C) D { } func (wsi *WalletSyncInfo) FetchSyncProgress() ProgressInfo { - pgrss, ok := syncProgressInfo[wsi.wallet] + pgrss, ok := syncProgressInfo.Load(wsi.wallet) if !ok { - pgrss = ProgressInfo{} + return ProgressInfo{} } + // remove the unnecessary sync progress data if already synced. wsi.deleteSyncProgress() - return pgrss + return pgrss.(ProgressInfo) } // deleteSyncProgress removes the map entry after the data persisted is no longer necessary. func (wsi *WalletSyncInfo) deleteSyncProgress() { wal := wsi.wallet if wal.IsSynced() { - delete(syncProgressInfo, wal) + syncProgressInfo.Delete(wal) } } @@ -543,12 +543,8 @@ func (wsi *WalletSyncInfo) ListenForNotifications() { // headers to fetch cannot be less than the previously fetched. // Page refresh only needed if there is new data to update the UI. if progress.HeadersToFetchOrScan >= previousProgress.HeadersToFetchOrScan { - // Lock the map before updating it - wsi.syncProgressInfoMutex.Lock() - // Ensure the mutex is unlocked even if there is a panic - defer wsi.syncProgressInfoMutex.Unlock() // set the new progress against the associated asset. - syncProgressInfo[wsi.wallet] = progress + syncProgressInfo.Store(wsi.wallet, progress) // We only care about sync state changes here, to // refresh the window display.