Skip to content

Commit

Permalink
explorer: display maturity for revocations
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 authored and chappjc committed Jul 16, 2019
1 parent ae3a001 commit c5f9d26
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion db/dcrsqlite/apisource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ func (db *WiredDB) GetExplorerTx(txid string) *exptypes.TxInfo {
if tx.Vin[0].IsCoinBase() {
tx.Type = exptypes.CoinbaseTypeStr
}
if tx.Type == exptypes.CoinbaseTypeStr {
if tx.Type == exptypes.CoinbaseTypeStr || tx.IsRevocation() {
if tx.Confirmations < int64(db.params.CoinbaseMaturity) {
tx.Mature = "False"
} else {
Expand Down
2 changes: 1 addition & 1 deletion explorer/explorerroutes.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ func (exp *explorerUI) TxPage(w http.ResponseWriter, r *http.Request) {
}

// For coinbase and stakebase, get maturity status.
if tx.Coinbase || tx.IsVote() {
if tx.Coinbase || tx.IsVote() || tx.IsRevocation() {
tx.Maturity = int64(exp.ChainParams.CoinbaseMaturity)
if tx.IsVote() {
tx.Maturity++ // TODO why as elsewhere for votes?
Expand Down
6 changes: 6 additions & 0 deletions explorer/types/explorertypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ func (t *TxInfo) IsImmatureCoinbase() bool {
return t.Type == CoinbaseTypeStr && t.Mature == "False"
}

// IsImmatureCoinbase verifies the conditions: 1. is a revocation,
// 2. is not mature.
func (t *TxInfo) IsImmatureRevocation() bool {
return t.Type == RevTypeStr && t.Mature == "False"
}

// BlocksToTicketMaturity will return 0 if this isn't an immature ticket.
func (t *TxInfo) BlocksToTicketMaturity() (blocks int64) {
if t.Type != TicketTypeStr {
Expand Down
2 changes: 1 addition & 1 deletion views/tx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
</div>
</div>
</div>
{{else if (or .IsImmatureVote .IsImmatureCoinbase)}}
{{else if (or .IsImmatureVote .IsImmatureCoinbase .IsImmatureRevocation)}}
<div class="my-2 w-75" data-target="tx.ticketStage">
<div class="fs13 text-secondary pb-1">Maturity</div>
<div class="progress">
Expand Down

0 comments on commit c5f9d26

Please sign in to comment.