예제 #1
0
파일: wallet.go 프로젝트: Chao-Jia/skycoin
// 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}
}