diff --git a/cmdmgr.go b/cmdmgr.go index 93b446d..b607eaf 100644 --- a/cmdmgr.go +++ b/cmdmgr.go @@ -194,7 +194,7 @@ func GetBalance(reply chan []byte, msg *btcjson.Message) { func GetBalances(reply chan []byte, msg *btcjson.Message) { wallets.RLock() for _, w := range wallets.m { - balance := w.CalculateBalance(6) + balance := w.CalculateBalance(1) unconfirmed := w.CalculateBalance(0) - balance NotifyWalletBalance(reply, w.name, balance) NotifyWalletBalanceUnconfirmed(reply, w.name, unconfirmed) @@ -411,7 +411,7 @@ func SendFrom(reply chan []byte, msg *btcjson.Message) { } // Notify all frontends of new account balances. - confirmed := w.CalculateBalance(6) + confirmed := w.CalculateBalance(1) unconfirmed := w.CalculateBalance(0) - confirmed NotifyWalletBalance(frontendNotificationMaster, w.name, confirmed) NotifyWalletBalanceUnconfirmed(frontendNotificationMaster, w.name, unconfirmed) @@ -566,7 +566,7 @@ func SendMany(reply chan []byte, msg *btcjson.Message) { } // Notify all frontends of new account balances. - confirmed := w.CalculateBalance(6) + confirmed := w.CalculateBalance(1) unconfirmed := w.CalculateBalance(0) - confirmed NotifyWalletBalance(frontendNotificationMaster, w.name, confirmed) NotifyWalletBalanceUnconfirmed(frontendNotificationMaster, w.name, unconfirmed) diff --git a/createtx.go b/createtx.go index 191b812..6c6844a 100644 --- a/createtx.go +++ b/createtx.go @@ -84,9 +84,13 @@ func selectInputs(s tx.UtxoStore, amt uint64, minconf int) (inputs []*tx.Utxo, b // Create list of eligible unspent previous outputs to use as tx // inputs, and sort by the amount in reverse order so a minimum number // of inputs is needed. - var eligible []*tx.Utxo + eligible := make([]*tx.Utxo, 0, len(s)) for _, utxo := range s { - if int(height-utxo.Height) >= minconf { + // TODO(jrick): if Height is -1, the UTXO is the result of spending + // 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(height-utxo.Height) >= minconf { eligible = append(eligible, utxo) } }