diff --git a/uspv/txstore.go b/uspv/txstore.go index e666ed6c6..036ca4fe0 100644 --- a/uspv/txstore.go +++ b/uspv/txstore.go @@ -30,11 +30,12 @@ type TxStore struct { } type Utxo struct { // cash money. - // combo of outpoint and txout which has all the info needed to spend - AtHeight int32 // block height where this tx was confirmed, 0 for unconf - KeyIdx uint32 // index for private key needed to sign / spend - Op wire.OutPoint // where - Txo wire.TxOut // what + // all the info needed to spend + AtHeight int32 // block height where this tx was confirmed, 0 for unconf + KeyIdx uint32 // index for private key needed to sign / spend + Value int64 // higher is better + + Op wire.OutPoint // where } type MyAdr struct { // an address I have the private key for @@ -118,7 +119,7 @@ func (t *TxStore) AbsorbTx(tx *wire.MsgTx, height int32) error { var newu Utxo newu.AtHeight = height newu.KeyIdx = a.KeyIdx - newu.Txo = *out + newu.Value = out.Value var newop wire.OutPoint newop.Hash = tx.TxSha() @@ -150,7 +151,7 @@ func (t *TxStore) ExpellTx(tx *wire.MsgTx, height int32) error { for i, myutxo := range t.Utxos { if myutxo.Op == in.PreviousOutPoint { hits++ - loss += myutxo.Txo.Value + loss += myutxo.Value err := t.MarkSpent(&myutxo.Op, height, tx) if err != nil { return err diff --git a/uspv/utxodb.go b/uspv/utxodb.go index e27e91400..ffa7ee008 100644 --- a/uspv/utxodb.go +++ b/uspv/utxodb.go @@ -171,13 +171,7 @@ func (u *Utxo) ToBytes() ([]byte, error) { return nil, err } // write 8 byte amount of money at the utxo - err = binary.Write(&buf, binary.BigEndian, u.Txo.Value) - if err != nil { - return nil, err - } - - // write variable length (usually like 25 byte) pkscript - _, err = buf.Write(u.Txo.PkScript) + err = binary.Write(&buf, binary.BigEndian, u.Value) if err != nil { return nil, err } @@ -218,11 +212,9 @@ func UtxoFromBytes(b []byte) (Utxo, error) { return u, err } // read 8 byte amount of money at the utxo - err = binary.Read(buf, binary.BigEndian, &u.Txo.Value) + err = binary.Read(buf, binary.BigEndian, &u.Value) if err != nil { return u, err } - // read variable length (usually like 25 byte) pkscript - u.Txo.PkScript = buf.Bytes() return u, nil }