diff --git a/server/public.go b/server/public.go index 7b507c02..40376e33 100644 --- a/server/public.go +++ b/server/public.go @@ -416,6 +416,7 @@ func (s *PublicServer) parseTemplates() []*template.Template { "formatAmountWithDecimals": formatAmountWithDecimals, "setTxToTemplateData": setTxToTemplateData, "isOwnAddress": isOwnAddress, + "isOwnAddresses": isOwnAddresses, } var createTemplate func(filenames ...string) *template.Template if s.debug { @@ -504,19 +505,25 @@ func setTxToTemplateData(td *TemplateData, tx *api.Tx) *TemplateData { return td } -// returns true if addresses are "own", +// returns true if address is "own", // i.e. either the address of the address detail or belonging to the xpub -func isOwnAddress(td *TemplateData, addresses []string) bool { - if len(addresses) == 1 { - a := addresses[0] - if a == td.AddrStr { +func isOwnAddress(td *TemplateData, a string) bool { + if a == td.AddrStr { + return true + } + if td.Address != nil && td.Address.XPubAddresses != nil { + if _, found := td.Address.XPubAddresses[a]; found { return true } - if td.Address != nil && td.Address.XPubAddresses != nil { - if _, found := td.Address.XPubAddresses[a]; found { - return true - } - } + } + return false +} + +// returns true if addresses are "own", +// i.e. either the address of the address detail or belonging to the xpub +func isOwnAddresses(td *TemplateData, addresses []string) bool { + if len(addresses) == 1 { + return isOwnAddress(td, addresses[0]) } return false } diff --git a/static/templates/txdetail.html b/static/templates/txdetail.html index 57bde9c9..6b3a3f82 100644 --- a/static/templates/txdetail.html +++ b/static/templates/txdetail.html @@ -14,7 +14,7 @@ {{- range $vin := $tx.Vin -}} - +
{{- if $vin.Txid -}} ➡  @@ -49,7 +49,7 @@ {{- range $vout := $tx.Vout -}} - +
{{- range $a := $vout.Addresses -}} diff --git a/static/templates/txdetail_ethereumtype.html b/static/templates/txdetail_ethereumtype.html index ec760955..bb71a8cc 100644 --- a/static/templates/txdetail_ethereumtype.html +++ b/static/templates/txdetail_ethereumtype.html @@ -1,4 +1,4 @@ -{{define "txdetail"}}{{$cs := .CoinShortcut}}{{$addr := .AddrStr}}{{$tx := .Tx}} +{{define "txdetail"}}{{$cs := .CoinShortcut}}{{$addr := .AddrStr}}{{$tx := .Tx}}{{$data := .}}
@@ -11,18 +11,18 @@
-
+
{{- range $vin := $tx.Vin -}} - + @@ -41,18 +41,18 @@
-
+
{{- range $a := $vin.Addresses -}} - + {{if and (ne $a $addr) $vin.Searchable}}{{$a}}{{else}}{{$a}}{{end}} {{- else -}} - Unparsed address + Unparsed address {{- end -}}
{{- range $vout := $tx.Vout -}} - + @@ -76,12 +76,12 @@ {{- range $erc20 := $tx.TokenTransfers -}}
-
+
{{- range $a := $vout.Addresses -}} - + {{- if and (ne $a $addr) $vout.Searchable}}{{$a}}{{else}}{{$a}}{{- end -}} {{- else -}} - Unparsed address + Unparsed address {{- end -}}
- + @@ -94,12 +94,12 @@
-
+
- {{if ne $erc20.From $addr}}{{$erc20.From}}{{else}}{{$erc20.From}}{{end}} + {{if ne $erc20.From $addr}}{{$erc20.From}}{{else}}{{$erc20.From}}{{end}}
- + diff --git a/static/templates/xpub.html b/static/templates/xpub.html index a4b1f57f..d67c76a3 100644 --- a/static/templates/xpub.html +++ b/static/templates/xpub.html @@ -29,7 +29,7 @@ - {{- if $addr.Tokens -}} + {{- if or $addr.Tokens $addr.TotalTokens -}}
- {{if ne $erc20.To $addr}}{{$erc20.To}}{{else}}{{$erc20.To}}{{end}} + {{if ne $erc20.To $addr}}{{$erc20.To}}{{else}}{{$erc20.To}}{{end}}
Used XPUB Addresses {{$addr.TotalTokens}}
{{if $data.NonZeroBalanceTokens}}XPUB Addresses with Balance{{else}}XPUB Addresses{{end}}