func (server *OpencxServer) ingestTransactionListAndHeight(txList []*wire.MsgTx, height uint64, coinType *coinparam.Params) (err error) {
	// get list of addresses we own
	// check the sender, amounts, receiver of all the transactions
	// check if the receiver is us
	// if so, add the deposit to the table, create a # of confirmations past the height at which it was received

	defer func() {
		if err != nil {
			err = fmt.Errorf("Error ingesting transaction list: \n%s", err)
			return
		}
	}()
	var addressesWeOwn map[string]*koblitz.PublicKey
	server.LockIngests()
	if addressesWeOwn, err = server.OpencxDB.GetDepositAddressMap(coinType); err != nil {
		// if errors out, unlock
		server.UnlockIngests()
		logging.Errorf("Error getting deposit address map")
		return
	}
	server.UnlockIngests()

	var deposits []match.Deposit

	for _, tx := range txList {
		for _, output := range tx.TxOut {

			// figure out if it's the right script type
			scriptType, data := util.ScriptType(output.PkScript)
			if scriptType == "P2PKH" {
				// It's P2PKH, let's get the address
				var addr *btcutil.AddressPubKeyHash
				if addr, err = btcutil.NewAddressPubKeyHash(data, coinType); err != nil {
					logging.Errorf("Error decoding p2pkh")
					return
				}

				if pubkey, found := addressesWeOwn[addr.String()]; found {
					newDeposit := match.Deposit{
						Pubkey:              pubkey,
						Address:             addr.String(),
						Amount:              uint64(output.Value),
						Txid:                tx.TxHash().String(),
						CoinType:            coinType,
						BlockHeightReceived: height,
						Confirmations:       6,
					}

					logging.Infof("Received deposit for %d %s", newDeposit.Amount, newDeposit.CoinType.Name)
					logging.Infof("%s\n", newDeposit.String())
					deposits = append(deposits, newDeposit)
				}
			}
		}
	}

	server.LockIngests()
	if err = server.OpencxDB.UpdateDeposits(deposits, height, coinType); err != nil {
		// if errors out, unlock
		server.UnlockIngests()
		logging.Errorf("Error updating deposits")
		return
	}
	server.UnlockIngests()

	logging.Debugf("Finished ingesting %s block at height %d", coinType.Name, height)
	if height%10000 == 0 {
		logging.Infof("Finished ingesting %s block at height %d\n", coinType.Name, height)
	}
	return
}
// IngestTransactionListAndHeight processes a transaction list and corresponding height
IngestTransactionListAndHeight processes a transaction list and corresponding height
// IngestTransactionListAndHeight processes a transaction list and corresponding height
func (server *OpencxServer) ingestTransactionListAndHeight(txList []*wire.MsgTx, height uint64, coinType *coinparam.Params) (err error) {
	defer func() {
		if err != nil {
			err = fmt.Errorf("Error ingesting transaction list: \n%s", err)
			return
		}
	}()
	var addressesWeOwn map[string]*koblitz.PublicKey
	server.LockIngests()
	if addressesWeOwn, err = server.OpencxDB.GetDepositAddressMap(coinType); err != nil {
		server.UnlockIngests()
		logging.Errorf("Error getting deposit address map")
		return
	}
	server.UnlockIngests()
	var deposits []match.Deposit
	for _, tx := range txList {
		for _, output := range tx.TxOut {
			scriptType, data := util.ScriptType(output.PkScript)
			if scriptType == "P2PKH" {
				var addr *btcutil.AddressPubKeyHash
				if addr, err = btcutil.NewAddressPubKeyHash(data, coinType); err != nil {
					logging.Errorf("Error decoding p2pkh")
					return
				}
				if pubkey, found := addressesWeOwn[addr.String()]; found {
					newDeposit := match.Deposit{
						Pubkey:              pubkey,
						Address:             addr.String(),
						Amount:              uint64(output.Value),
						Txid:                tx.TxHash().String(),
						CoinType:            coinType,
						BlockHeightReceived: height,
						Confirmations:       6,
					}
					logging.Infof("Received deposit for %d %s", newDeposit.Amount, newDeposit.CoinType.Name)
					logging.Infof("%s\n", newDeposit.String())
					deposits = append(deposits, newDeposit)
				}
			}
		}
	}
	server.LockIngests()
	if err = server.OpencxDB.UpdateDeposits(deposits, height, coinType); err != nil {
		server.UnlockIngests()
		logging.Errorf("Error updating deposits")
		return
	}
	server.UnlockIngests()
	logging.Debugf("Finished ingesting %s block at height %d", coinType.Name, height)
	if height%10000 == 0 {
		logging.Infof("Finished ingesting %s block at height %d\n", coinType.Name, height)
	}
	return
}
func ( server * OpencxServer ) ingestTransactionListAndHeight ( txList [ ] * wire . MsgTx , height uint64 , coinType * coinparam . Params ) ( err error ) { defer func ( ) { if err != nil { err = fmt . Errorf ( " \n " , err ) return } } ( ) var addressesWeOwn map [ string ] * koblitz . PublicKey server . LockIngests ( ) if addressesWeOwn , err = server . OpencxDB . GetDepositAddressMap ( coinType ) ; err != nil { server . UnlockIngests ( ) logging . Errorf ( " " ) return } server . UnlockIngests ( ) var deposits [ ] match . Deposit for _ , tx := range txList { for _ , output := range tx . TxOut { scriptType , data := util . ScriptType ( output . PkScript ) if scriptType == " " { var addr * btcutil . AddressPubKeyHash if addr , err = btcutil . NewAddressPubKeyHash ( data , coinType ) ; err != nil { logging . Errorf ( " " ) return } if pubkey , found := addressesWeOwn [ addr . String ( ) ] ; found { newDeposit := match . Deposit { Pubkey : pubkey , Address : addr . String ( ) , Amount : uint64 ( output . Value ) , Txid : tx . TxHash ( ) . String ( ) , CoinType : coinType , BlockHeightReceived : height , Confirmations : 6 , } logging . Infof ( " " , newDeposit . Amount , newDeposit . CoinType . Name ) logging . Infof ( " \n " , newDeposit . String ( ) ) deposits = append ( deposits , newDeposit ) } } } } server . LockIngests ( ) if err = server . OpencxDB . UpdateDeposits ( deposits , height , coinType ) ; err != nil { server . UnlockIngests ( ) logging . Errorf ( " " ) return } server . UnlockIngests ( ) logging . Debugf ( " " , coinType . Name , height ) if height % 10000 == 0 { logging . Infof ( " \n " , coinType . Name , height ) } return }
IngestTransactionListAndHeight processes a transaction list and corresponding height
IngestTransactionListAndHeight processes a transaction list and corresponding height
// get list of addresses we own // check the sender, amounts, receiver of all the transactions // check if the receiver is us // if so, add the deposit to the table, create a # of confirmations past the height at which it was received // if errors out, unlock // figure out if it's the right script type // It's P2PKH, let's get the address // if errors out, unlock