Exemplo n.º 1
0
func UpdatePayment(c db.MConn, p *Payment) {
	p.Updated = time.Now().Unix()
	_, err := c.Exec(
		`UPDATE payment SET blockhash=?, blockheight=?, orphaned=?, time=?, updated=? WHERE tx_id=? AND vout=?`,
		p.Blockhash, p.Blockheight, p.Orphaned, p.Time, p.Updated, p.TxId, p.Vout,
	)
	if err != nil {
		panic(err)
	}
}
Exemplo n.º 2
0
func SaveBalance(c db.MConn, balance *Balance) *Balance {
	_, err := c.Exec(
		`INSERT INTO account_balance (`+BalanceModel.FieldsInsert+`)
         VALUES (`+BalanceModel.Placeholders+`)`,
		balance,
	)
	if err != nil {
		panic(err)
	}
	return balance
}
Exemplo n.º 3
0
func SavePayment(c db.MConn, p *Payment) (*Payment, error) {
	if p.Time == 0 {
		p.Time = time.Now().Unix()
	}
	err := c.QueryRow(
		`INSERT INTO payment (`+PaymentModel.FieldsInsert+`)
         VALUES (`+PaymentModel.Placeholders+`)
         RETURNING id`,
		p,
	).Scan(&p.Id)
	return p, err
}
Exemplo n.º 4
0
func LoadWithdrawalsByStatus(c db.MConn, coin string, status int32, limit uint) []*Withdrawal {
	rows, err := c.QueryAll(Withdrawal{},
		`SELECT `+WithdrawalModel.FieldsSimple+`
         FROM account_withdrawal
         WHERE status=? AND coin=?
         ORDER BY id ASC LIMIT ?`,
		status, coin, limit,
	)
	if err != nil {
		panic(err)
	}
	return rows.([]*Withdrawal)
}
Exemplo n.º 5
0
func LoadWithdrawal(c db.MConn, id int64) *Withdrawal {
	var wth Withdrawal
	err := c.QueryRow(
		`SELECT `+WithdrawalModel.FieldsSimple+`
         FROM account_withdrawal
         WHERE id=?`,
		id,
	).Scan(&wth)
	if err != nil {
		panic(err)
	}
	return &wth
}
Exemplo n.º 6
0
func LoadDepositForPayment(c db.MConn, paymentId int64) *Deposit {
	var dep Deposit
	err := c.QueryRow(
		`SELECT `+DepositModel.FieldsSimple+`
         FROM account_deposit
         WHERE payment_id=?`,
		paymentId,
	).Scan(&dep)
	if err != nil {
		panic(err)
	}
	return &dep
}
Exemplo n.º 7
0
// Might throw an error if the deposit already exists.
func SaveDeposit(c db.MConn, dep *Deposit) (*Deposit, error) {
	if dep.Time == 0 {
		dep.Time = time.Now().Unix()
	}
	// Add to DB
	err := c.QueryRow(
		`INSERT INTO account_deposit (`+DepositModel.FieldsInsert+`)
         VALUES (`+DepositModel.Placeholders+`)
         RETURNING id`,
		dep,
	).Scan(&dep.Id)
	return dep, err
}
Exemplo n.º 8
0
func SaveTransfer(c db.MConn, trans *Transfer) *Transfer {
	if trans.Time == 0 {
		trans.Time = time.Now().Unix()
	}
	err := c.QueryRow(
		`INSERT INTO account_transfer (`+TransferModel.FieldsInsert+`)
         VALUES (`+TransferModel.Placeholders+`)
         RETURNING id`,
		trans,
	).Scan(&trans.Id)
	if err != nil {
		panic(err)
	}
	return trans
}
Exemplo n.º 9
0
func SaveWithdrawal(c db.MConn, wth *Withdrawal) *Withdrawal {
	if wth.Time == 0 {
		wth.Time = time.Now().Unix()
	}
	// Add to DB
	err := c.QueryRow(
		`INSERT INTO account_withdrawal (`+WithdrawalModel.FieldsInsert+`)
         VALUES (`+WithdrawalModel.Placeholders+`)
         RETURNING id`,
		wth,
	).Scan(&wth.Id)
	if err != nil {
		panic(err)
	}
	return wth
}