Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
deadline: 10m
timeout: 10m

output:
format: github-actions,colored-line-number
Expand Down
42 changes: 31 additions & 11 deletions api/types/insightapitypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package types

import (
"encoding/hex"
"encoding/json"

"github.com/decred/dcrdata/v8/db/dbtypes"
Expand Down Expand Up @@ -80,19 +81,38 @@ type InsightPagination struct {
IsToday string `json:"isToday,omitempty"`
}

var _ json.Unmarshaler = (*HexBytes)(nil)
var _ json.Marshaler = HexBytes{}

type HexBytes []byte

func (hb HexBytes) MarshalJSON() ([]byte, error) {
return []byte(`"` + hex.EncodeToString(hb) + `"`), nil // json.Marshal(hex.EncodeToString(hb)) but not absurdly inefficient
}

func (hb *HexBytes) UnmarshalJSON(b []byte) error {
var str string
err := json.Unmarshal(b, &str)
if err != nil {
return err
}
*hb, err = hex.DecodeString(str)
return err
}

// AddressTxnOutput models an address transaction outputs.
type AddressTxnOutput struct {
Address string `json:"address"`
TxnID string `json:"txid"`
Vout uint32 `json:"vout"`
BlockTime int64 `json:"ts,omitempty"`
ScriptPubKey string `json:"scriptPubKey"`
Height int64 `json:"height,omitempty"`
BlockHash string `json:"block_hash,omitempty"`
Amount float64 `json:"amount,omitempty"`
Atoms int64 `json:"atoms,omitempty"` // Not Required per Insight spec
Satoshis int64 `json:"satoshis,omitempty"`
Confirmations int64 `json:"confirmations"`
Address string `json:"address"`
TxnID string `json:"txid"`
Vout uint32 `json:"vout"`
BlockTime int64 `json:"ts,omitempty"`
ScriptPubKey HexBytes `json:"scriptPubKey"`
Height int64 `json:"height,omitempty"`
BlockHash string `json:"block_hash,omitempty"`
Amount float64 `json:"amount,omitempty"`
Atoms int64 `json:"atoms,omitempty"` // Not Required per Insight spec
Satoshis int64 `json:"satoshis,omitempty"`
Confirmations int64 `json:"confirmations"`
}

// TxOutFromDB converts a dbtypes.AddressTxnOutput to a api/types.AddressTxnOutput.
Expand Down
18 changes: 18 additions & 0 deletions api/types/insightapitypes_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package types

import (
"fmt"
"testing"
)

func TestHexBytes_UnmarshalJSON(t *testing.T) {
in := []byte(`"deadbeef"`)
var hb HexBytes
err := hb.UnmarshalJSON(in)
if err != nil {
t.Fatal(err)
}
fmt.Printf("%x\n", []byte(hb))
out, _ := hb.MarshalJSON()
fmt.Println(string(out))
}
4 changes: 2 additions & 2 deletions cmd/dcrdata/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/decred/dcrdata/cmd/dcrdata

go 1.18
go 1.21

replace (
github.com/decred/dcrdata/db/dcrpg/v8 => ../../db/dcrpg/
Expand Down Expand Up @@ -147,7 +147,7 @@ require (
github.com/klauspost/cpuid/v2 v2.0.9 // 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
github.com/lib/pq v1.10.9 // indirect
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
github.com/lightninglabs/neutrino v0.14.3-0.20221024182812-792af8548c14 // indirect
github.com/lightningnetwork/lnd/clock v1.0.1 // indirect
Expand Down
15 changes: 13 additions & 2 deletions cmd/dcrdata/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
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/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down Expand Up @@ -578,6 +579,7 @@ github.com/didip/tollbooth/v6 v6.1.3-0.20220606152938-a7634c70944a h1:YKCmFFZGFW
github.com/didip/tollbooth/v6 v6.1.3-0.20220606152938-a7634c70944a/go.mod h1:wop/gy+XfJK/TXFmmVbFT46jsYOMU15K0Q1lWr4gIW8=
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+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 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
Expand Down Expand Up @@ -690,6 +692,7 @@ github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1
github.com/go-critic/go-critic v0.5.6/go.mod h1:cVjj0DfqewQVIlIAGexPCaGaZDAqGE29PYDDADIVNEo=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -725,6 +728,7 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4=
github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ=
github.com/go-toolsmith/astequal v0.0.0-20180903214952-dcb477bfacd6/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY=
Expand Down Expand Up @@ -767,6 +771,7 @@ github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -848,6 +853,7 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM=
github.com/google/go-licenses v0.0.0-20210329231322-ce1d9163b77d/go.mod h1:+TYOmkVoJOpwnS0wfdsJCV9CoD5nJYsHoFk/0CrTK4M=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
Expand Down Expand Up @@ -1132,8 +1138,8 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI/f/O0Avg7t8sqkPo78HFzjmeYFl6DPnc=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk=
github.com/lightninglabs/neutrino v0.14.2/go.mod h1:OICUeTCn+4Tu27YRJIpWvvqySxx4oH4vgdP33Sw9RDc=
Expand Down Expand Up @@ -1535,6 +1541,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
Expand Down Expand Up @@ -2225,6 +2232,7 @@ google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20180808183934-383e8b2c3b9e/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
Expand Down Expand Up @@ -2407,6 +2415,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
Expand Down Expand Up @@ -2447,7 +2456,9 @@ gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
11 changes: 8 additions & 3 deletions cmd/dcrdata/internal/api/apiroutes.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type DataSource interface {
GetBlockHash(idx int64) (string, error)
GetBlockHeight(hash string) (int64, error)
GetBlockByHash(string) (*wire.MsgBlock, error)
SpendingTransaction(fundingTx string, vout uint32) (string, uint32, int8, error)
SpendingTransaction(fundingTx string, vout uint32) (string, uint32, error)
SpendingTransactions(fundingTxID string) ([]string, []uint32, []uint32, error)
AddressHistory(address string, N, offset int64, txnType dbtypes.AddrTxnViewType) ([]*dbtypes.AddressRow, *dbtypes.AddressBalance, error)
FillAddressTransactions(addrInfo *dbtypes.AddressInfo) error
Expand All @@ -80,7 +80,7 @@ type DataSource interface {
GetStakeInfoExtendedByHash(hash string) *apitypes.StakeInfoExtended
GetStakeInfoExtendedByHeight(idx int) *apitypes.StakeInfoExtended
GetPoolInfo(idx int) *apitypes.TicketPoolInfo
GetPoolInfoByHash(hash string) *apitypes.TicketPoolInfo
// GetPoolInfoByHash(hash string) *apitypes.TicketPoolInfo
GetPoolInfoRange(idx0, idx1 int) []apitypes.TicketPoolInfo
GetPoolValAndSizeRange(idx0, idx1 int) ([]float64, []uint32)
GetPool(idx int64) ([]string, error)
Expand Down Expand Up @@ -1667,6 +1667,11 @@ func (c *appContext) addressIoCsv(crlf bool, w http.ResponseWriter, r *http.Requ
strDirection = "-1"
}

var matchingTx string
if r.MatchingTxHash != nil {
matchingTx = r.MatchingTxHash.String()
}

err = writer.Write([]string{
r.TxHash.String(),
strDirection,
Expand All @@ -1675,7 +1680,7 @@ func (c *appContext) addressIoCsv(crlf bool, w http.ResponseWriter, r *http.Requ
strconv.FormatFloat(dcrutil.Amount(r.Value).ToCoin(), 'f', -1, 64),
strconv.FormatInt(r.TxBlockTime, 10),
txhelpers.TxTypeToString(int(r.TxType)),
r.MatchingTxHash.String(),
matchingTx,
})
if err != nil {
return // too late to write an error code
Expand Down
10 changes: 5 additions & 5 deletions cmd/dcrdata/internal/api/insight/apiroutes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

type BlockDataSource interface {
AddressBalance(address string) (bal *dbtypes.AddressBalance, cacheUpdated bool, err error)
AddressIDsByOutpoint(txHash string, voutIndex uint32) ([]uint64, []string, int64, error)
OutpointAddresses(txHash string, voutIndex uint32) ([]string, int64, error)
AddressUTXO(address string) ([]*dbtypes.AddressTxnOutput, bool, error)
BlockSummaryTimeRange(min, max int64, limit int) ([]dbtypes.BlockDataBasic, error)
GetBlockHash(idx int64) (string, error)
Expand Down Expand Up @@ -130,7 +130,7 @@ func writeJSON(w http.ResponseWriter, thing interface{}, indent string) {
func writeInsightError(w http.ResponseWriter, str string) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusBadRequest)
io.WriteString(w, str)
io.WriteString(w, str) //nolint:errcheck
}

// Insight API response for an item NOT FOUND. This means the request was valid
Expand All @@ -140,7 +140,7 @@ func writeInsightError(w http.ResponseWriter, str string) {
func writeInsightNotFound(w http.ResponseWriter, str string) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusNotFound)
io.WriteString(w, str)
io.WriteString(w, str) //nolint:errcheck
}

func (iapi *InsightApi) getTransaction(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -459,7 +459,7 @@ func (iapi *InsightApi) getAddressesTxnOutput(w http.ResponseWriter, r *http.Req
// need to do one more search on utxo and do not add if this is
// already in the list as a confirmed tx.
for _, utxo := range confirmedTxnOutputs {
if utxo.Vout == f.Index && utxo.TxHash == f.Hash {
if utxo.Vout == f.Index && utxo.TxHash == dbtypes.ChainHash(f.Hash) {
continue FUNDING_TX_DUPLICATE_CHECK
}
}
Expand All @@ -473,7 +473,7 @@ func (iapi *InsightApi) getAddressesTxnOutput(w http.ResponseWriter, r *http.Req
TxnID: fundingTx.Hash().String(),
Vout: f.Index,
BlockTime: fundingTx.MemPoolTime,
ScriptPubKey: hex.EncodeToString(txOut.PkScript),
ScriptPubKey: txOut.PkScript,
Amount: dcrutil.Amount(txOut.Value).ToCoin(),
Satoshis: txOut.Value,
Confirmations: 0,
Expand Down
2 changes: 1 addition & 1 deletion cmd/dcrdata/internal/api/insight/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (iapi *InsightApi) DcrToInsightTxns(txs []*chainjson.TxRawResult, noAsm, no
// work if the funding transaction is confirmed. Otherwise use RPC
// to get the funding transaction outpoint addresses.
if !vinGenerated {
_, addresses, _, err := iapi.BlockData.AddressIDsByOutpoint(vin.Txid, vin.Vout)
addresses, _, err := iapi.BlockData.OutpointAddresses(vin.Txid, vin.Vout)
if err == nil && len(addresses) > 0 {
InsightVin.Addr = addresses[0]
} else {
Expand Down
4 changes: 3 additions & 1 deletion cmd/dcrdata/internal/api/insight/socket.io.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ func NewSocketServer(params *chaincfg.Params, txGetter txhelpers.RawTransactionG

apiLog.Infof("Started Insight socket.io server.")

go server.Serve()
go func() {
apiLog.Warnf("SocketServer.Serve: %v", server.Serve())
}()
return server, nil
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/dcrdata/internal/explorer/explorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type explorerDataSource interface {
Height() int64
HeightDB() (int64, error)
BlockHash(height int64) (string, error)
SpendingTransaction(fundingTx string, vout uint32) (string, uint32, int8, error)
SpendingTransaction(fundingTx string, vout uint32) (string, uint32, error)
SpendingTransactions(fundingTxID string) ([]string, []uint32, []uint32, error)
PoolStatusForTicket(txid string) (dbtypes.TicketSpendType, dbtypes.TicketPoolStatus, error)
TreasuryBalance() (*dbtypes.TreasuryBalance, error)
Expand All @@ -89,7 +89,7 @@ type explorerDataSource interface {
TicketPoolVisualization(interval dbtypes.TimeBasedGrouping) (*dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, int64, error)
TransactionBlocks(hash string) ([]*dbtypes.BlockStatus, []uint32, error)
Transaction(txHash string) ([]*dbtypes.Tx, error)
VinsForTx(*dbtypes.Tx) (vins []dbtypes.VinTxProperty, prevPkScripts []string, scriptVersions []uint16, err error)
VinsForTx(*dbtypes.Tx) (vins []dbtypes.VinTxProperty, err error)
VoutsForTx(*dbtypes.Tx) ([]dbtypes.Vout, error)
PosIntervals(limit, offset uint64) ([]*dbtypes.BlocksGroupedInfo, error)
TimeBasedIntervals(timeGrouping dbtypes.TimeBasedGrouping, limit, offset uint64) ([]*dbtypes.BlocksGroupedInfo, error)
Expand Down
Loading
Loading