Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rfc-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ Tech stack - Preferably Node.js/Golang for the servers

## Bounties
1. Simple Servers without UTXOs (in memory balances) - $200
<<<<<<< HEAD
2. UTXOs for ins and outs - $200 (for point 1) + $200
=======
2. UTXOs for ins and outs - $200 (for point 1) + $200
>>>>>>> 06c256234fcc03aaa134cc3c13753cb4184dd04a
41 changes: 41 additions & 0 deletions rfc-1/fundServer/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
26 changes: 26 additions & 0 deletions rfc-1/fundServer/backend/db/connect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import mongoose from "mongoose";

export async function connect() {
try {
mongoose.connect(
process.env.MONGO_URL!
);
const connection = mongoose.connection;

connection.on("connected", () => {
console.log("MongoDB connected successfully");
});

connection.on("error", (err) => {
console.log(
"MongoDB connection error. Please make sure MongoDB is running. " + err
);
process.exit();
});
} catch (error) {
console.log("Failed to connect!!😓");
console.log(error);
}
}

module.exports = { connect}
28 changes: 28 additions & 0 deletions rfc-1/fundServer/backend/model/transactions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import mongoose from "mongoose";

const transactionSchema = new mongoose.Schema({
signature: {
type: String,
required: true,
},
sender_pub_id: {
type: String,
required: true,
},
receiver_pub_id: {
type: String,
required: true,
},
amount: {
type: Number,
required: true,
},
timestamp: {
type: Date,
default: Date.now,
},
});

const Transaction = mongoose.model("Transaction", transactionSchema);

export default Transaction;
20 changes: 20 additions & 0 deletions rfc-1/fundServer/backend/model/utxo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import mongoose from "mongoose";

const utxoSchema = new mongoose.Schema({
utxoId:{
type: String,
required: true,
unique: true
},
pub_id: {
type: String,
required: true
},
amount:{
type: Number,
required: true
}
})

const UTXO = mongoose.model("UTXO", utxoSchema);
export default UTXO;
Loading