func (db *DB) InsertDepositAddresses(pubkey *koblitz.PublicKey, addressMap map[*coinparam.Params]string) (err error) {
	// begin the transaction
	tx, err := db.DBHandler.Begin()
	if err != nil {
		return fmt.Errorf("Error beginning transaction while inserting addresses: \n%s", err)
	}

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

	logging.Infof("pubkey length (serialized, compressed): %d", len(pubkey.SerializeCompressed()))

	// use deposit schema
	if _, err = tx.Exec("USE " + db.depositSchema + ";"); err != nil {
		return
	}

	for chain, addr := range addressMap {
		logging.Infof("Addr: %s, len: %d", addr, len(addr))
		// insert into db
		insertDepositAddrQuery := fmt.Sprintf("INSERT INTO %s VALUES ('%x', '%s') ON DUPLICATE KEY UPDATE address='%s';", chain.Name, pubkey.SerializeCompressed(), addr, addr)
		logging.Infof("%s", insertDepositAddrQuery)
		if _, err = tx.Exec(insertDepositAddrQuery); err != nil {
			return
		}
	}

	return
}
// InsertDepositAddresses inserts deposit addresses based on the addressmap you give it
InsertDepositAddresses inserts deposit addresses based on the addressmap you give it
// InsertDepositAddresses inserts deposit addresses based on the addressmap you give it
func (db *DB) InsertDepositAddresses(pubkey *koblitz.PublicKey, addressMap map[*coinparam.Params]string) (err error) {
	tx, err := db.DBHandler.Begin()
	if err != nil {
		return fmt.Errorf("Error beginning transaction while inserting addresses: \n%s", err)
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while inserting addresses: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	logging.Infof("pubkey length (serialized, compressed): %d", len(pubkey.SerializeCompressed()))
	if _, err = tx.Exec("USE " + db.depositSchema + ";"); err != nil {
		return
	}
	for chain, addr := range addressMap {
		logging.Infof("Addr: %s, len: %d", addr, len(addr))
		insertDepositAddrQuery := fmt.Sprintf("INSERT INTO %s VALUES ('%x', '%s') ON DUPLICATE KEY UPDATE address='%s';", chain.Name, pubkey.SerializeCompressed(), addr, addr)
		logging.Infof("%s", insertDepositAddrQuery)
		if _, err = tx.Exec(insertDepositAddrQuery); err != nil {
			return
		}
	}
	return
}
func ( db * DB ) InsertDepositAddresses ( pubkey * koblitz . PublicKey , addressMap map [ * coinparam . Params ] string ) ( 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 ( ) } ( ) logging . Infof ( " " , len ( pubkey . SerializeCompressed ( ) ) ) if _ , err = tx . Exec ( " " + db . depositSchema + " " ) ; err != nil { return } for chain , addr := range addressMap { logging . Infof ( " " , addr , len ( addr ) ) insertDepositAddrQuery := fmt . Sprintf ( " " , chain . Name , pubkey . SerializeCompressed ( ) , addr , addr ) logging . Infof ( " " , insertDepositAddrQuery ) if _ , err = tx . Exec ( insertDepositAddrQuery ) ; err != nil { return } } return }
InsertDepositAddresses inserts deposit addresses based on the addressmap you give it
InsertDepositAddresses inserts deposit addresses based on the addressmap you give it
// begin the transaction // Setup small custom error msg for trace // use deposit schema // insert into db