Display fee per size in explorer transaction detail
This commit is contained in:
parent
6edbc2d99b
commit
84b931f42b
@ -415,6 +415,8 @@ func (w *Worker) getTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spe
|
||||
ValueInSat: (*Amount)(pValInSat),
|
||||
ValueOutSat: (*Amount)(&valOutSat),
|
||||
Version: bchainTx.Version,
|
||||
Size: len(bchainTx.Hex) >> 1,
|
||||
VSize: int(bchainTx.VSize),
|
||||
Hex: bchainTx.Hex,
|
||||
Rbf: rbf,
|
||||
Vin: vins,
|
||||
@ -423,11 +425,6 @@ func (w *Worker) getTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spe
|
||||
TokenTransfers: tokens,
|
||||
EthereumSpecific: ethSpecific,
|
||||
}
|
||||
if w.chainParser.SupportsVSize() {
|
||||
r.Size = len(bchainTx.Hex) >> 1
|
||||
r.VSize = int(bchainTx.VSize)
|
||||
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
|
||||
@ -454,6 +454,7 @@ func (s *PublicServer) parseTemplates() []*template.Template {
|
||||
"formatAmount": s.formatAmount,
|
||||
"formatAmountWithDecimals": formatAmountWithDecimals,
|
||||
"setTxToTemplateData": setTxToTemplateData,
|
||||
"feePerByte": feePerByte,
|
||||
"isOwnAddress": isOwnAddress,
|
||||
"toJSON": toJSON,
|
||||
"tokenTransfersCount": tokenTransfersCount,
|
||||
@ -556,6 +557,19 @@ func setTxToTemplateData(td *TemplateData, tx *api.Tx) *TemplateData {
|
||||
return td
|
||||
}
|
||||
|
||||
// feePerByte returns fee per vByte or Byte if vsize is unknown
|
||||
func feePerByte(tx *api.Tx) string {
|
||||
if tx.FeesSat != nil {
|
||||
if tx.VSize > 0 {
|
||||
return fmt.Sprintf("%.2f sat/vByte", float64(tx.FeesSat.AsInt64())/float64(tx.VSize))
|
||||
}
|
||||
if tx.Size > 0 {
|
||||
return fmt.Sprintf("%.2f sat/Byte", float64(tx.FeesSat.AsInt64())/float64(tx.Size))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// isOwnAddress returns true if the address is the one that is being shown in the explorer
|
||||
func isOwnAddress(td *TemplateData, a string) bool {
|
||||
return a == td.AddrStr
|
||||
|
||||
@ -59,17 +59,24 @@
|
||||
<td>Total Output</td>
|
||||
<td class="data">{{formatAmount $tx.ValueOutSat}} {{$cs}}</td>
|
||||
</tr>
|
||||
{{- if $tx.VSize -}}
|
||||
<tr>
|
||||
<td>Size / vSize</td>
|
||||
<td class="data">{{$tx.Size}} / {{$tx.VSize}}</td>
|
||||
</tr>
|
||||
{{- else -}}
|
||||
{{- if $tx.Size -}}
|
||||
<tr>
|
||||
<td>Size/VSize</td>
|
||||
<td class="data">{{$tx.Size}}/{{$tx.VSize}}</td>
|
||||
<td>Size</td>
|
||||
<td class="data">{{$tx.Size}}</td>
|
||||
</tr>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $tx.FeesSat -}}
|
||||
<tr>
|
||||
<td>Fees</td>
|
||||
<td class="data">{{formatAmount $tx.FeesSat}} {{$cs}}</td>
|
||||
<td class="data">{{formatAmount $tx.FeesSat}} {{$cs}}{{if $tx.Size}} ({{feePerByte $tx}}){{end}}</td>
|
||||
</tr>{{end -}}
|
||||
{{- if not $tx.Confirmations}}
|
||||
<tr>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user