// Gets a new address from an rpc client func newAddr(client *btcrpcclient.Client) (btcutil.Address, error) { addr, err := client.GetNewAddress() if err != nil { return nil, err } return addr, nil }
// check to see if we are connected func checkconnection(client *btcrpcclient.Client) error { _, err := client.GetDifficulty() if err != nil { return err } return nil }
// 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 }