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
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