// prevOutVal looks up all the values of the oupoints used in the current tx func PrevOutVal(tx *btcwire.MsgTx, client *btcrpcclient.Client) (int64, error) { // requires an rpc client and outpoints within wallets realm total := int64(0) for _, txin := range tx.TxIn { prevTxHash := txin.PreviousOutPoint.Hash var tx *btcutil.Tx tx, err := client.GetRawTransaction(&prevTxHash) if err != nil { return -1, err } vout := txin.PreviousOutPoint.Index txout := tx.MsgTx().TxOut[vout] total += txout.Value } return total, nil }