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.
This commit is contained in:
Josh Rickmar 2014-02-04 11:50:33 -05:00
parent b978c7e059
commit 243acf5491
2 changed files with 2 additions and 2 deletions

View file

@ -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. // to a change address, resulting in a UTXO not yet mined in a block.
// For now, disallow creating transactions until these UTXOs are mined // For now, disallow creating transactions until these UTXOs are mined
// into a block and show up as part of the balance. // 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) eligible = append(eligible, utxo)
} }
} }

View file

@ -118,7 +118,7 @@ func TestFakeTxs(t *testing.T) {
pairs := map[string]int64{ pairs := map[string]int64{
"17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH": 5000, "17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH": 5000,
} }
_, err = a.txToPairs(pairs, 0) _, err = a.txToPairs(pairs, 1)
if err != nil { if err != nil {
t.Errorf("Tx creation failed: %s", err) t.Errorf("Tx creation failed: %s", err)
return return