Пример #1
0
// Returns JSON of pending transactions for user's wallet
func walletTransactionsHandler(gateway *daemon.Gateway) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		if r.Method == "GET" {
			wallet := Wg.GetWallet(wallet.WalletID(r.FormValue("id")))
			addresses := wallet.GetAddresses()
			ret := gateway.Visor.GetWalletTransactions(gateway.V, addresses)

			SendOr404(w, ret)
		}
	}
}
Пример #2
0
// Returns the confirmed & predicted balance for a Wallet
func (self *Visor) WalletBalance(walletID wallet.WalletID) BalancePair {
	wallet := self.Wallets.Get(walletID)
	if wallet == nil {
		return BalancePair{}
	}
	auxs := self.blockchain.Unspent.AllForAddresses(wallet.GetAddresses())
	puxs := self.Unconfirmed.SpendsForAddresses(&self.blockchain.Unspent,
		wallet.GetAddressSet())
	confirmed := self.totalBalance(auxs)
	predicted := self.totalBalance(auxs.Sub(puxs))
	return BalancePair{confirmed, predicted}
}