Ejemplo n.º 1
0
// Each coin should only have 1 processor.
// This allows for more granular transactions.
// NOTE: consider select ... for update when selecting the payments to use.
// CONTRACT: call this in a goroutine, it won't stop until a fatal error.
func Process(coin string) {
	defer Recover("Treasury::Process(" + coin + ")")

	for {

		// if privkey hasn't been seeded yet, then wait.
		if !hasHotPrivKey() {
			Warn("Please seed the master privKey for %v", account.GetHotMPK().PubKey)
			time.Sleep(60 * time.Second)
			continue
		}

		// Process sweep transactions
		// TODO: automatically figure out sweeps.
		// TODO: for now, get sweeps from admin.

		// Process user initiated withdrawals
		processed, err := ProcessUserWithdrawals(coin)
		if err != nil {
			// Notify admin of the error, will retry manually.
			alert.Alert(fmt.Sprintf("Withdrawals for %v stalled: %v", coin, err.Error()))
			continue
		} else if !processed {
			Info("Sleeping, no withdrawals to process")
			time.Sleep(30 * time.Second)
			continue
		}

	}
}
Ejemplo n.º 2
0
func init() {
	hotMPK = account.GetHotMPK()
}