-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
251 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
mode: separate-outputs | ||
|
||
etching: | ||
rune: BLT.BACON.TOKENS | ||
turbo: true | ||
divisibility: 8 | ||
premine: 1000000 | ||
supply: 1000000 | ||
symbol: 🥓 | ||
|
||
inscriptions: | ||
- file: /blockchain/bacon.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# example split file | ||
|
||
# output fields: | ||
# address: output recipient bitcoin address | ||
# value: output bitcoin value (optional, defaults to minimal-non dust value for `address`) | ||
# runes: output rune value map (values respect rune divisibility) | ||
outputs: | ||
- address: bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297 | ||
value: 10 sat | ||
runes: | ||
UNCOMMON•GOODS: 1234 | ||
GRIEF•WAGE: 5000000 | ||
- address: 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy | ||
runes: | ||
HELLO•WORLD: 22.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
datacarriersize=1000000 | ||
regtest=1 | ||
datadir=/blockchain/regtest/data | ||
listen=0 | ||
txindex=1 | ||
printtoconsole=1 | ||
rpcuser=bitcoin | ||
rpcpassword=bitcoin | ||
|
||
[regtest] | ||
rpcport=18443 | ||
rpcbind=0.0.0.0:18443 | ||
rpcallowip=0.0.0.0/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 5.1.5 on 2025-01-30 20:27 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("website", "0186_userprofile_contribution_rank_and_more"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="BaconEarning", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"tokens_earned", | ||
models.DecimalField(decimal_places=2, default=0.0, max_digits=10), | ||
), | ||
("timestamp", models.DateTimeField(auto_now_add=True)), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import json | ||
|
||
import requests | ||
from django.conf import settings | ||
from django.http import JsonResponse | ||
|
||
from blt import settings | ||
from website.models import BaconEarning | ||
|
||
|
||
# @login_required | ||
def batch_send_bacon_tokens_view(request): | ||
# Get all users with non-zero tokens_earned | ||
users_with_tokens = BaconEarning.objects.filter(tokens_earned__gt=0) | ||
|
||
if not users_with_tokens.exists(): | ||
return JsonResponse({"status": "error", "message": "No eligible users with tokens to send."}) | ||
|
||
# Build YAML content | ||
yaml_outputs = [] | ||
for token_earning in users_with_tokens: | ||
user = token_earning.user | ||
btc_address = getattr(user.userprofile, "btc_address", None) | ||
tokens_to_send = token_earning.tokens_earned | ||
|
||
if btc_address and tokens_to_send > 0: | ||
yaml_outputs.append(f"- address: {btc_address}\n runes:\n BLT•BACON•TOKENS: {tokens_to_send}") | ||
|
||
# Form the YAML string payload | ||
yaml_content = "outputs:\n" + "\n".join(yaml_outputs) | ||
|
||
# Payload for POST request | ||
payload = {"yaml_content": yaml_content} | ||
ORD_SERVER_URL = settings.ORD_SERVER_URL | ||
try: | ||
# Send the request to the ORD server | ||
response = requests.post( | ||
f"{ORD_SERVER_URL}/send-bacon-tokens", | ||
headers={"Content-Type": "application/json"}, | ||
data=json.dumps(payload), | ||
) | ||
response_data = response.json() | ||
|
||
# Reset the tokens_earned for all users if the request was successful | ||
if response.status_code == 200 and response_data.get("success"): | ||
users_with_tokens.update(tokens_earned=0) | ||
return JsonResponse( | ||
{ | ||
"status": "success", | ||
"message": "Tokens successfully sent to all eligible users. If it doesnt appear in the users wallet yet , wait for the miners to confirm the transaction.", | ||
} | ||
) | ||
else: | ||
return JsonResponse({"status": "error", "message": response_data.get("error", "Unknown error")}) | ||
|
||
except requests.RequestException as e: | ||
return JsonResponse({"status": "error", "message": str(e)}) | ||
|
||
|
||
def pending_transactions_view(request): | ||
# Fetch all users with non-zero tokens_earned | ||
pending_transactions = BaconEarning.objects.filter(tokens_earned__gt=0) | ||
# Prepare a list of user: address: tokens data | ||
transactions_data = [] | ||
for transaction in pending_transactions: | ||
user = transaction.user | ||
btc_address = getattr(user.userprofile, "btc_address", None) | ||
transactions_data = [{"user": user.username, "address": btc_address, "tokens": transaction.tokens_earned}] | ||
|
||
# If you want to return it as a JSON response: | ||
return JsonResponse({"pending_transactions": transactions_data}) |
Oops, something went wrong.