uspv: update to new upstream btcd api to fix compile errors
This commit is contained in:
parent
566bf47cbf
commit
6eaf4908fb
2
shell.go
2
shell.go
@ -30,7 +30,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Params = &chaincfg.SegNetParams
|
Params = &chaincfg.SegNet4Params
|
||||||
SCon uspv.SPVCon // global here for now
|
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
|
for _, tx := range blk.Transactions { // make slice of (w)/txids
|
||||||
txid := tx.TxSha()
|
txid := tx.TxSha()
|
||||||
wtxid := tx.WTxSha()
|
wtxid := tx.WitnessHash()
|
||||||
if !witMode && !txid.IsEqual(&wtxid) {
|
if !witMode && !txid.IsEqual(&wtxid) {
|
||||||
witMode = true
|
witMode = true
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ func (s *SPVCon) GetDataHandler(m *wire.MsgGetData) {
|
|||||||
log.Printf("error getting tx %s: %s",
|
log.Printf("error getting tx %s: %s",
|
||||||
thing.Hash.String(), err.Error())
|
thing.Hash.String(), err.Error())
|
||||||
}
|
}
|
||||||
tx.Flags = 0x00 // dewitnessify
|
//tx.Flags = 0x00 // dewitnessify
|
||||||
s.outMsgQueue <- tx
|
s.outMsgQueue <- tx
|
||||||
sent++
|
sent++
|
||||||
continue
|
continue
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/roasbeef/btcd/blockchain"
|
||||||
"github.com/roasbeef/btcd/txscript"
|
"github.com/roasbeef/btcd/txscript"
|
||||||
"github.com/roasbeef/btcd/wire"
|
"github.com/roasbeef/btcd/wire"
|
||||||
"github.com/roasbeef/btcutil"
|
"github.com/roasbeef/btcutil"
|
||||||
@ -124,7 +125,7 @@ func (s *SPVCon) SendOne(u Utxo, adr btcutil.Address) error {
|
|||||||
|
|
||||||
var prevPKs []byte
|
var prevPKs []byte
|
||||||
if u.IsWit {
|
if u.IsWit {
|
||||||
tx.Flags = 0x01
|
//tx.Flags = 0x01
|
||||||
wa, err := btcutil.NewAddressWitnessPubKeyHash(
|
wa, err := btcutil.NewAddressWitnessPubKeyHash(
|
||||||
s.TS.Adrs[u.KeyIdx].PkhAdr.ScriptAddress(), s.TS.Param)
|
s.TS.Adrs[u.KeyIdx].PkhAdr.ScriptAddress(), s.TS.Param)
|
||||||
prevPKs, err = txscript.PayToAddrScript(wa)
|
prevPKs, err = txscript.PayToAddrScript(wa)
|
||||||
@ -143,7 +144,7 @@ func (s *SPVCon) SendOne(u Utxo, adr btcutil.Address) error {
|
|||||||
|
|
||||||
var sig []byte
|
var sig []byte
|
||||||
var wit [][]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)
|
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
|
// these are all zeroed out during signing but it's an easy way to keep track
|
||||||
var prevPKs []byte
|
var prevPKs []byte
|
||||||
if utxo.IsWit {
|
if utxo.IsWit {
|
||||||
tx.Flags = 0x01
|
//tx.Flags = 0x01
|
||||||
wa, err := btcutil.NewAddressWitnessPubKeyHash(
|
wa, err := btcutil.NewAddressWitnessPubKeyHash(
|
||||||
s.TS.Adrs[utxo.KeyIdx].PkhAdr.ScriptAddress(), s.TS.Param)
|
s.TS.Adrs[utxo.KeyIdx].PkhAdr.ScriptAddress(), s.TS.Param)
|
||||||
prevPKs, err = txscript.PayToAddrScript(wa)
|
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
|
// generate tx-wide hashCache for segwit stuff
|
||||||
// middle index number doesn't matter for sighashAll.
|
// 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 {
|
for i, txin := range tx.TxIn {
|
||||||
// pick key
|
// pick key
|
||||||
@ -408,7 +409,7 @@ func EstFee(otx *wire.MsgTx, spB int64) int64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf(TxToString(tx))
|
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)
|
fmt.Printf("%d spB, est vsize %d, fee %d\n", spB, size, size*spB)
|
||||||
return size * spB
|
return size * spB
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/roasbeef/btcd/blockchain"
|
||||||
"github.com/roasbeef/btcd/chaincfg"
|
"github.com/roasbeef/btcd/chaincfg"
|
||||||
|
|
||||||
"github.com/boltdb/bolt"
|
"github.com/boltdb/bolt"
|
||||||
@ -139,9 +140,9 @@ func CheckDoubleSpends(
|
|||||||
|
|
||||||
// TxToString prints out some info about a transaction. for testing / debugging
|
// TxToString prints out some info about a transaction. for testing / debugging
|
||||||
func TxToString(tx *wire.MsgTx) string {
|
func TxToString(tx *wire.MsgTx) string {
|
||||||
str := fmt.Sprintf("size %d vsize %d wsize %d locktime %d flag %x txid %s\n",
|
str := fmt.Sprintf("size %d vsize %d wsize %d locktime %d txid %s\n",
|
||||||
tx.SerializeSize(), tx.VirtualSize(), tx.SerializeSizeWitness(),
|
tx.SerializeSize(), blockchain.GetTxVirtualSize(btcutil.NewTx(tx)),
|
||||||
tx.LockTime, tx.Flags, tx.TxSha().String())
|
tx.SerializeSize(), tx.LockTime, tx.TxSha().String())
|
||||||
for i, in := range tx.TxIn {
|
for i, in := range tx.TxIn {
|
||||||
str += fmt.Sprintf("Input %d spends %s\n", i, in.PreviousOutPoint.String())
|
str += fmt.Sprintf("Input %d spends %s\n", i, in.PreviousOutPoint.String())
|
||||||
str += fmt.Sprintf("\tSigScript: %x\n", in.SignatureScript)
|
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
|
// if hits is nonzero it's a relevant tx and we should store it
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
tx.SerializeWitness(&buf) // always store witness version
|
tx.Serialize(&buf)
|
||||||
err = txns.Put(cachedSha.Bytes(), buf.Bytes())
|
err = txns.Put(cachedSha.Bytes(), buf.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user