uspv: update to new upstream btcd api to fix compile errors

This commit is contained in:
Olaoluwa Osuntokun 2016-05-22 22:04:05 -07:00
parent 566bf47cbf
commit 6eaf4908fb
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
6 changed files with 14 additions and 12 deletions

@ -30,7 +30,7 @@ const (
)
var (
Params = &chaincfg.SegNetParams
Params = &chaincfg.SegNet4Params
SCon uspv.SPVCon // global here for now
)

@ -26,7 +26,7 @@ func BlockOK(blk wire.MsgBlock) bool {
for _, tx := range blk.Transactions { // make slice of (w)/txids
txid := tx.TxSha()
wtxid := tx.WTxSha()
wtxid := tx.WitnessHash()
if !witMode && !txid.IsEqual(&wtxid) {
witMode = true
}

@ -203,7 +203,7 @@ func (s *SPVCon) GetDataHandler(m *wire.MsgGetData) {
log.Printf("error getting tx %s: %s",
thing.Hash.String(), err.Error())
}
tx.Flags = 0x00 // dewitnessify
//tx.Flags = 0x00 // dewitnessify
s.outMsgQueue <- tx
sent++
continue

@ -6,6 +6,7 @@ import (
"log"
"sort"
"github.com/roasbeef/btcd/blockchain"
"github.com/roasbeef/btcd/txscript"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
@ -124,7 +125,7 @@ func (s *SPVCon) SendOne(u Utxo, adr btcutil.Address) error {
var prevPKs []byte
if u.IsWit {
tx.Flags = 0x01
//tx.Flags = 0x01
wa, err := btcutil.NewAddressWitnessPubKeyHash(
s.TS.Adrs[u.KeyIdx].PkhAdr.ScriptAddress(), s.TS.Param)
prevPKs, err = txscript.PayToAddrScript(wa)
@ -143,7 +144,7 @@ func (s *SPVCon) SendOne(u Utxo, adr btcutil.Address) error {
var sig []byte
var wit [][]byte
hCache := txscript.CalcHashCache(tx, 0, txscript.SigHashAll)
hCache := txscript.NewTxSigHashes(tx)
child, err := s.TS.rootPrivKey.Child(u.KeyIdx + hdkeychain.HardenedKeyStart)
@ -251,7 +252,7 @@ func (s *SPVCon) SendCoins(adrs []btcutil.Address, sendAmts []int64) error {
// these are all zeroed out during signing but it's an easy way to keep track
var prevPKs []byte
if utxo.IsWit {
tx.Flags = 0x01
//tx.Flags = 0x01
wa, err := btcutil.NewAddressWitnessPubKeyHash(
s.TS.Adrs[utxo.KeyIdx].PkhAdr.ScriptAddress(), s.TS.Param)
prevPKs, err = txscript.PayToAddrScript(wa)
@ -315,7 +316,7 @@ func (s *SPVCon) SendCoins(adrs []btcutil.Address, sendAmts []int64) error {
// generate tx-wide hashCache for segwit stuff
// middle index number doesn't matter for sighashAll.
hCache := txscript.CalcHashCache(tx, 0, txscript.SigHashAll)
hCache := txscript.NewTxSigHashes(tx)
for i, txin := range tx.TxIn {
// pick key
@ -408,7 +409,7 @@ func EstFee(otx *wire.MsgTx, spB int64) int64 {
}
}
fmt.Printf(TxToString(tx))
size := int64(tx.VirtualSize())
size := int64(blockchain.GetTxVirtualSize(btcutil.NewTx(tx)))
fmt.Printf("%d spB, est vsize %d, fee %d\n", spB, size, size*spB)
return size * spB
}

@ -7,6 +7,7 @@ import (
"log"
"sync"
"github.com/roasbeef/btcd/blockchain"
"github.com/roasbeef/btcd/chaincfg"
"github.com/boltdb/bolt"
@ -139,9 +140,9 @@ func CheckDoubleSpends(
// TxToString prints out some info about a transaction. for testing / debugging
func TxToString(tx *wire.MsgTx) string {
str := fmt.Sprintf("size %d vsize %d wsize %d locktime %d flag %x txid %s\n",
tx.SerializeSize(), tx.VirtualSize(), tx.SerializeSizeWitness(),
tx.LockTime, tx.Flags, tx.TxSha().String())
str := fmt.Sprintf("size %d vsize %d wsize %d locktime %d txid %s\n",
tx.SerializeSize(), blockchain.GetTxVirtualSize(btcutil.NewTx(tx)),
tx.SerializeSize(), tx.LockTime, tx.TxSha().String())
for i, in := range tx.TxIn {
str += fmt.Sprintf("Input %d spends %s\n", i, in.PreviousOutPoint.String())
str += fmt.Sprintf("\tSigScript: %x\n", in.SignatureScript)

@ -486,7 +486,7 @@ func (ts *TxStore) Ingest(tx *wire.MsgTx, height int32) (uint32, error) {
// if hits is nonzero it's a relevant tx and we should store it
var buf bytes.Buffer
tx.SerializeWitness(&buf) // always store witness version
tx.Serialize(&buf)
err = txns.Put(cachedSha.Bytes(), buf.Bytes())
if err != nil {
return err