spend from wpkh works

This commit is contained in:
Tadge Dryja committed 2016-02-22 01:41:40 -08:00
1 parent 57a34f0753
commit 2b808724fb
6 files changed
+49 -26

No files matched your search

+2
View File
@@ -189,6 +189,7 @@ func (s *SPVCon) GetDataHandler(m *wire.MsgGetData) {
log.Printf("error getting tx %s: %s",
thing.Hash.String(), err.Error())
}
fmt.Printf(TxToString(tx))
s.outMsgQueue <- tx
sent++
continue
@@ -199,6 +200,7 @@ func (s *SPVCon) GetDataHandler(m *wire.MsgGetData) {
log.Printf("error getting tx %s: %s",
thing.Hash.String(), err.Error())
}
tx.Flags = 0x00 // dewitnessify
s.outMsgQueue <- tx
sent++
continue
+1 -1
View File
@@ -234,7 +234,7 @@ func (s *SPVCon) SendCoins(adr btcutil.Address, sendAmt int64) error {
fmt.Printf("tx: %s", TxToString(tx))
buf := bytes.NewBuffer(make([]byte, 0, tx.SerializeSize()))
tx.Serialize(buf)
tx.SerializeWitness(buf)
fmt.Printf("tx: %x\n", buf.Bytes())
// send it out on the wire. hope it gets there.
+6 -7
View File
@@ -137,20 +137,19 @@ func CheckDoubleSpends(
// TxToString prints out some info about a transaction. for testing / debugging
func TxToString(tx *wire.MsgTx) string {
str := fmt.Sprintf("\t size %d vsize %d wsize %d Tx %s\n",
str := fmt.Sprintf("size %d vsize %d wsize %d locktime %d flag %x txid %s\n",
tx.SerializeSize(), tx.VirtualSize(), tx.SerializeSizeWitness(),
tx.TxSha().String())
tx.LockTime, tx.Flags, tx.TxSha().String())
for i, in := range tx.TxIn {
str += fmt.Sprintf("Input %d: %s\n", i, in.PreviousOutPoint.String())
str += fmt.Sprintf("SigScript for input %d: %x\n", i, in.SignatureScript)
str += fmt.Sprintf("Input %d spends %s\n", i, in.PreviousOutPoint.String())
str += fmt.Sprintf("\tSigScript: %x\n", in.SignatureScript)
for j, wit := range in.Witness {
str += fmt.Sprintf("witness %d: %x\t", j, wit)
str += fmt.Sprintf("\twitness %d: %x\n", j, wit)
}
str += fmt.Sprintf("\n")
}
for i, out := range tx.TxOut {
if out != nil {
str += fmt.Sprintf("\toutput %d script: %x amt: %d\n",
str += fmt.Sprintf("output %d script: %x amt: %d\n",
i, out.PkScript, out.Value)
} else {
str += fmt.Sprintf("output %d nil (WARNING)\n", i)
+1 -1
View File
@@ -470,7 +470,7 @@ func (ts *TxStore) Ingest(tx *wire.MsgTx, height int32) (uint32, error) {
// store this relevant tx
sha := tx.TxSha()
var buf bytes.Buffer
tx.Serialize(&buf)
tx.SerializeWitness(&buf) // always store witness version
err = txns.Put(sha.Bytes(), buf.Bytes())
if err != nil {
return err