Skip to content
Open
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
35 changes: 20 additions & 15 deletions api/types/apitypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"
"time"

"github.com/decred/dcrd/dcrutil/v4"
chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v4"
"github.com/decred/dcrd/txscript/v4/stdscript"
"github.com/decred/dcrdata/v8/db/dbtypes"
Expand Down Expand Up @@ -93,15 +94,17 @@ type Vin = chainjson.Vin

// TxShort models info about transaction TxID
type TxShort struct {
TxID string `json:"txid"`
Size int32 `json:"size"`
Version int32 `json:"version"`
Locktime uint32 `json:"locktime"`
Expiry uint32 `json:"expiry"`
Vin []Vin `json:"vin"`
Vout []Vout `json:"vout"`
Tree int8 `json:"tree"`
Type string `json:"type"`
TxID string `json:"txid"`
Size int32 `json:"size"`
Version int32 `json:"version"`
Locktime uint32 `json:"locktime"`
Expiry uint32 `json:"expiry"`
Fee dcrutil.Amount `json:"fee"`
FeeRate dcrutil.Amount `json:"feerate"`
Vin []Vin `json:"vin"`
Vout []Vout `json:"vout"`
Tree int8 `json:"tree"`
Type string `json:"type"`
}

// AgendasInfo holds the high level details about an agenda.
Expand All @@ -121,12 +124,14 @@ type AgendaAPIResponse struct {

// TrimmedTx models data to resemble to result of the decoderawtransaction RPC.
type TrimmedTx struct {
TxID string `json:"txid"`
Version int32 `json:"version"`
Locktime uint32 `json:"locktime"`
Expiry uint32 `json:"expiry"`
Vin []Vin `json:"vin"`
Vout []Vout `json:"vout"`
TxID string `json:"txid"`
Version int32 `json:"version"`
Locktime uint32 `json:"locktime"`
Expiry uint32 `json:"expiry"`
Fee dcrutil.Amount `json:"fee"`
FeeRate dcrutil.Amount `json:"feerate"`
Vin []Vin `json:"vin"`
Vout []Vout `json:"vout"`
}

// Txns models the multi transaction post data structure
Expand Down
2 changes: 1 addition & 1 deletion cmd/dcrdata/internal/api/apiroutes.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ func (c *appContext) getTxSwapsInfo(w http.ResponseWriter, r *http.Request) {
writeJSON(w, swapsInfo, m.GetIndentCtx(r))
}

// getTransactions handles the /txns POST API endpoint.
// getTransactions handles the /txs POST API endpoint.
func (c *appContext) getTransactions(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down
10 changes: 6 additions & 4 deletions cmd/dcrdata/views/mempool.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@
<tr>
<th>Transaction ID</th>
<th class="text-end">Total DCR</th>
<th class="text-end">Size</th>
<th class="text-end">Fee Rate</th>
<th class="text-end">Size</th>
<th class="text-end">Time in Mempool</th>
</tr>
</thead>
Expand All @@ -247,8 +247,8 @@
<td class="mono fs15 text-end">
{{template "decimalParts" (float64AsDecimalParts .TotalOut 8 false)}}
</td>
<td class="mono fs15 text-end">{{.Size}} B</td>
<td class="mono fs15 text-end">{{printf "%.8f" (.FeeRate)}} DCR/kB</td>
<td class="mono fs15 text-end">{{.Size}} B</td>
<td class="mono fs15 text-end" data-time-target="age" data-age="{{.Time}}"></td>
</tr>
{{- end -}}
Expand Down Expand Up @@ -307,8 +307,9 @@
<tr>
<th>Transaction ID</th>
<th class="text-end">Total DCR</th>
<th class="text-end">Size</th>
<th class="text-end">Fee</th>
<th class="text-end">Fee Rate</th>
<th class="text-end">Size</th>
<th class="text-end">Time in Mempool</th>
</tr>
</thead>
Expand All @@ -323,8 +324,9 @@
<td class="mono fs15 text-end">
{{template "decimalParts" (float64AsDecimalParts .TotalOut 8 false)}}
</td>
<td class="mono fs15 text-end">{{.Fee}}</td>
<td class="mono fs15 text-end">{{dcrPerKbToAtomsPerByte .FeeRate}} atoms/B</td>
<td class="mono fs15 text-end">{{.Size}} B</td>
<td class="mono fs15 text-end">{{printf "%.8f" (.FeeRate)}} DCR/kB</td>
<td class="mono fs15 text-end" data-time-target="age" data-age="{{.Time}}"></td>
</tr>
{{- end -}}
Expand Down
3 changes: 3 additions & 0 deletions db/dcrpg/pgblockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4983,6 +4983,7 @@ func (pgb *ChainDB) GetAPITransaction(ctx context.Context, txid *chainhash.Hash)
},
}

tx.Fee, tx.FeeRate = txhelpers.TxFeeRate(msgTx)
copy(tx.Vin, txraw.Vin)

for i := range txraw.Vout {
Expand Down Expand Up @@ -5024,6 +5025,8 @@ func (pgb *ChainDB) GetTrimmedTransaction(ctx context.Context, txid *chainhash.H
Expiry: tx.Expiry,
Vin: tx.Vin,
Vout: tx.Vout,
Fee: tx.Fee,
FeeRate: tx.FeeRate,
}
}

Expand Down
11 changes: 5 additions & 6 deletions explorer/types/explorertypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,11 @@ type TicketPoolInfo struct {

// MempoolTx models the tx basic data for the mempool page
type MempoolTx struct {
TxID string `json:"txid"`
Version int32 `json:"version"`
Fees float64 `json:"fees"`
FeeRate float64 `json:"fee_rate"`
// Consider atom representation:
//FeeAmount int64 `json:"fee_amount"`
TxID string `json:"txid"`
Version int32 `json:"version"`
Fee dcrutil.Amount `json:"fee"`
Fees float64 `json:"fees"`
FeeRate float64 `json:"fee_rate"`
VinCount int `json:"vin_count"`
VoutCount int `json:"vout_count"`
Vin []MempoolInput `json:"vin,omitempty"`
Expand Down
3 changes: 2 additions & 1 deletion mempool/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ func (t *DataCollector) mempoolTxns() ([]exptypes.MempoolTx, txhelpers.MempoolAd
//fee, _ := txhelpers.TxFeeRate(msgTx)
// log.Tracef("tx fee: GRM result = %f, msgTx = %f", tx.Fee, fee.ToCoin())

_, feeRate := txhelpers.TxFeeRate(msgTx)
fee, feeRate := txhelpers.TxFeeRate(msgTx)

txs = append(txs, exptypes.MempoolTx{
TxID: hashStr,
Version: int32(msgTx.Version),
Fees: tx.Fee,
Fee: fee,
FeeRate: feeRate.ToCoin(),
VinCount: len(msgTx.TxIn),
VoutCount: len(msgTx.TxOut),
Expand Down
1 change: 1 addition & 0 deletions mempool/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func (p *MempoolMonitor) TxHandler(rawTx *chainjson.TxRawResult) error {
tx := exptypes.MempoolTx{
TxID: hash,
Version: rawTx.Version,
Fee: fee,
Fees: fee.ToCoin(),
FeeRate: feeRate.ToCoin(),
VinCount: len(msgTx.TxIn),
Expand Down