From 0928361f22b0b1d01e7906963d7af800459a4e26 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Wed, 4 Sep 2013 09:32:14 -0400 Subject: [PATCH] Save address with Utxo. We want only one utxo file per wallet, so each serialized Utxo needs to also contain the receiving address. --- tx/tx.go | 3 +++ tx/tx_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tx/tx.go b/tx/tx.go index 9a4ed4c..9313a85 100644 --- a/tx/tx.go +++ b/tx/tx.go @@ -43,6 +43,7 @@ type UtxoStore struct { } type Utxo struct { + Addr [ripemd160.Size]byte TxHash btcwire.ShaHash Amt int64 // Measured in Satoshis Height int64 @@ -180,6 +181,7 @@ func (u *UtxoStore) WriteTo(w io.Writer) (n int64, err error) { // Each field is read little endian. func (u *Utxo) ReadFrom(r io.Reader) (n int64, err error) { datas := []interface{}{ + &u.Addr, &u.TxHash, &u.Amt, &u.Height, @@ -203,6 +205,7 @@ func (u *Utxo) ReadFrom(r io.Reader) (n int64, err error) { // Each field is written little endian. func (u *Utxo) WriteTo(w io.Writer) (n int64, err error) { datas := []interface{}{ + &u.Addr, &u.TxHash, &u.Amt, &u.Height, diff --git a/tx/tx_test.go b/tx/tx_test.go index c62642b..04b7f24 100644 --- a/tx/tx_test.go +++ b/tx/tx_test.go @@ -87,6 +87,10 @@ var ( func TestUtxoWriteRead(t *testing.T) { utxo1 := &Utxo{ + Addr: [ripemd160.Size]byte{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, + }, TxHash: [btcwire.HashSize]byte{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,