func (db *DB) InitializeAccountBalances(pubkey *koblitz.PublicKey) (err error) {

	// begin the transaction
	tx, err := db.DBHandler.Begin()
	if err != nil {
		return fmt.Errorf("Error beginning transaction while initializing accounts: \n%s", err)
	}

	// Setup small custom error msg for trace
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while initializing account: \n%s", err)
			return
		}
		err = tx.Commit()
	}()

	// Use the balance schema
	if _, err = tx.Exec("USE " + db.balanceSchema + ";"); err != nil {
		return
	}

	for _, chain := range db.coinList {
		// Insert 0 balance into balance table
		insertBalanceQueries := fmt.Sprintf("INSERT INTO %s VALUES ('%x', %d);", chain.Name, pubkey.SerializeCompressed(), 0)
		if _, err = tx.Exec(insertBalanceQueries); err != nil {
			return
		}
	}

	return nil
}
// InitializeAccountBalances initializes all database values for an account with username 'username'
InitializeAccountBalances initializes all database values for an account with username 'username'
// InitializeAccountBalances initializes all database values for an account with username ' username '
func (db *DB) InitializeAccountBalances(pubkey *koblitz.PublicKey) (err error) {
	tx, err := db.DBHandler.Begin()
	if err != nil {
		return fmt.Errorf("Error beginning transaction while initializing accounts: \n%s", err)
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while initializing account: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	if _, err = tx.Exec("USE " + db.balanceSchema + ";"); err != nil {
		return
	}
	for _, chain := range db.coinList {
		insertBalanceQueries := fmt.Sprintf("INSERT INTO %s VALUES ('%x', %d);", chain.Name, pubkey.SerializeCompressed(), 0)
		if _, err = tx.Exec(insertBalanceQueries); err != nil {
			return
		}
	}
	return nil
}
func ( db * DB ) InitializeAccountBalances ( pubkey * koblitz . PublicKey ) ( err error ) { tx , err := db . DBHandler . Begin ( ) if err != nil { return fmt . Errorf ( " \n " , err ) } defer func ( ) { if err != nil { tx . Rollback ( ) err = fmt . Errorf ( " \n " , err ) return } err = tx . Commit ( ) } ( ) if _ , err = tx . Exec ( " " + db . balanceSchema + " " ) ; err != nil { return } for _ , chain := range db . coinList { insertBalanceQueries := fmt . Sprintf ( " " , chain . Name , pubkey . SerializeCompressed ( ) , 0 ) if _ , err = tx . Exec ( insertBalanceQueries ) ; err != nil { return } } return nil }
InitializeAccountBalances initializes all database values for an account with username 'username'
InitializeAccountBalances initializes all database values for an account with username ' username '
// begin the transaction // Setup small custom error msg for trace // Use the balance schema // Insert 0 balance into balance table