mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-20 02:27:21 +01:00
remove storage of pkscript; don't need it.
This commit is contained in:
parent
278971936f
commit
b7a2c46ea6
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user