Skip to content

Commit

Permalink
correct tx tree determination logic
Browse files Browse the repository at this point in the history
  • Loading branch information
itswisdomagain committed Mar 5, 2021
1 parent 631fa30 commit e2fee6f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions server/asset/dcr/dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,14 +932,30 @@ func (dcr *Backend) getTxOutInfo(ctx context.Context, txHash *chainhash.Hash, vo
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to decode MsgTx from hex for transaction %s: %w", txHash, err)
}
txTree := stake.DetermineTxType(msgTx, msgTx.Version == wire.TxVersionTreasury)
txOut, pkScript, err := dcr.getUnspentTxOut(ctx, txHash, vout, int8(txTree))
tree := determineTxTree(msgTx)
txOut, pkScript, err := dcr.getUnspentTxOut(ctx, txHash, vout, tree)
if err != nil {
return nil, nil, nil, err
}
return txOut, verboseTx, pkScript, nil
}

func determineTxTree(msgTx *wire.MsgTx) int8 {
// Try with treasury disabled first.
txType := stake.DetermineTxType(msgTx, false)
if txType != stake.TxTypeRegular {
return wire.TxTreeStake
}

// Try with treasury enabled.
txType = stake.DetermineTxType(msgTx, true)
if txType != stake.TxTypeRegular {
return wire.TxTreeStake
}

return wire.TxTreeRegular
}

// Get the block information, checking the cache first. Same as
// getDcrBlock, but takes a string argument.
func (dcr *Backend) getBlockInfo(ctx context.Context, blockid string) (*dcrBlock, error) {
Expand Down

0 comments on commit e2fee6f

Please sign in to comment.