Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: upgrade nanoid-dictionary from 5.0.0-beta.1 to 5.0.0 #22

fix: upgrade nanoid-dictionary from 5.0.0-beta.1 to 5.0.0

fix: upgrade nanoid-dictionary from 5.0.0-beta.1 to 5.0.0 #22

Workflow file for this run

const axios = require('axios');
const mongoose = require('mongoose');
// MongoDB connection
mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,

Check failure on line 6 in .github/workflows/python-app.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/python-app.yml

Invalid workflow file

You have an error in your yaml syntax on line 6
useUnifiedTopology: true,
});
// Define Mongoose Schema
const blockSchema = new mongoose.Schema({
height: Number,
hash: String,
time: Number,
txIndexes: [Number],
});
const transactionSchema = new mongoose.Schema({
hash: String,
time: Number,
inputs: Array,
outputs: Array,
});
// Create models
const Block = mongoose.model('Block', blockSchema);
const Transaction = mongoose.model('Transaction', transactionSchema);
// Fetch Latest Block
async function fetchLatestBlock() {
try {
const response = await axios.get("https://blockchain.info/latestblock");
const blockData = response.data;
// Check if block already exists
const existingBlock = await Block.findOne({ height: blockData.height });
if (!existingBlock) {
const newBlock = new Block(blockData);
await newBlock.save();
console.log(`Block ${blockData.height} saved.`);
} else {
console.log(`Block ${blockData.height} already exists.`);
}
} catch (error) {
console.error("Error fetching block:", error);
}
}
// Fetch Transactions for Your Bitcoin Address
async function fetchTransactions(address) {
try {
const response = await axios.get(`https://blockchain.info/rawaddr/${address}`);
const transactions = response.data.txs;
for (const tx of transactions) {
const existingTx = await Transaction.findOne({ hash: tx.hash });
if (!existingTx) {
const newTx = new Transaction(tx);
await newTx.save();
console.log(`Transaction ${tx.hash} saved.`);
}
}
} catch (error) {
console.error("Error fetching transactions:", error);
}
}
// Run both functions
async function updateData() {
await fetchLatestBlock();
await fetchTransactions("bc1qn56zm7hsxzdshuxdc7s7ytcv3qznf7wntj80g3"); // Your BTC address
}
// Run every 5 minutes
setInterval(updateData, 5 * 60 * 1000);
console.log("Bitcoin block & transaction tracker started...");
Morty Proxy This is a proxified and sanitized view of the page, visit original site.