Skip to content

Commit

Permalink
add tx "tree" to apitypes.TxShort
Browse files Browse the repository at this point in the history
  • Loading branch information
ukane-philemon committed Dec 9, 2022
1 parent 5d2df4b commit 1e883bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/types/apitypes.go
Expand Up @@ -100,6 +100,7 @@ type TxShort struct {
Expiry uint32 `json:"expiry"`
Vin []Vin `json:"vin"`
Vout []Vout `json:"vout"`
Tree int8 `json:"tree"`
}

// AgendasInfo holds the high level details about an agenda.
Expand Down
12 changes: 12 additions & 0 deletions db/dcrpg/pgblockchain.go
Expand Up @@ -4827,6 +4827,17 @@ func (pgb *ChainDB) GetAPITransaction(txid *chainhash.Hash) *apitypes.Tx {
return nil
}

msgTx, err := txhelpers.MsgTxFromHex(txraw.Hex)
if err != nil {
log.Errorf("Cannot create MsgTx for tx %v: %v", txid.String(), err)
return nil
}

treasuryActive := true
if txraw.BlockHeight > 0 {
treasuryActive = txhelpers.IsTreasuryActive(pgb.chainParams.Net, txraw.BlockHeight)
}

tx := &apitypes.Tx{
TxShort: apitypes.TxShort{
TxID: txraw.Txid,
Expand All @@ -4836,6 +4847,7 @@ func (pgb *ChainDB) GetAPITransaction(txid *chainhash.Hash) *apitypes.Tx {
Expiry: txraw.Expiry,
Vin: make([]apitypes.Vin, len(txraw.Vin)),
Vout: make([]apitypes.Vout, len(txraw.Vout)),
Tree: txhelpers.TxTree(msgTx, treasuryActive),
},
Confirmations: txraw.Confirmations,
Block: &apitypes.BlockID{
Expand Down

0 comments on commit 1e883bb

Please sign in to comment.