From 243acf5491e22c8cec11e23703547b3743d4da1e Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Tue, 4 Feb 2014 11:50:33 -0500 Subject: [PATCH] Fix issue calculating eligible inputs. Use the new confirmed function to test whether unspent transaction outputs are confirmed enough to be used as a possible transaction inputs instead of the old check (which was incorrect and required an extra confirmation). Modified the test to require one confirmation instead of none so the confirmed enough check actually occurs. --- createtx.go | 2 +- createtx_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/createtx.go b/createtx.go index 0a0f98e..06dd4fc 100644 --- a/createtx.go +++ b/createtx.go @@ -126,7 +126,7 @@ func selectInputs(s tx.UtxoStore, amt uint64, minconf int) (inputs []*tx.Utxo, b // to a change address, resulting in a UTXO not yet mined in a block. // For now, disallow creating transactions until these UTXOs are mined // into a block and show up as part of the balance. - if utxo.Height != -1 && int(bs.Height-utxo.Height) >= minconf { + if confirmed(minconf, utxo.Height, bs.Height) { eligible = append(eligible, utxo) } } diff --git a/createtx_test.go b/createtx_test.go index b9f5070..42b8378 100644 --- a/createtx_test.go +++ b/createtx_test.go @@ -118,7 +118,7 @@ func TestFakeTxs(t *testing.T) { pairs := map[string]int64{ "17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH": 5000, } - _, err = a.txToPairs(pairs, 0) + _, err = a.txToPairs(pairs, 1) if err != nil { t.Errorf("Tx creation failed: %s", err) return