Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Jul 16, 2024
1 parent 6910b8f commit 0df3690
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,6 @@ SLASHED_BOND_REWARD_SPLIT = 0.5

# Username for HTLCs escrows
ESCROW_USERNAME = 'admin'

#Social
NOSTR_NSEC = 'nsec1vxhs2zc4kqe0dhz4z2gfrdyjsrwf8pg3neeqx6w4nl8djfzdp0dqwd6rxh'
11 changes: 7 additions & 4 deletions api/nostr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ class Nostr:
async def send_order_event(self, order):
"""Creates the event and sends it to the coordinator relay"""

if config("NOSTR_NSEC", cast=str, default="") == "":
return

print("Sending nostr event")

# Initialize with coordinator Keys
keys = Keys.generate()
keys = Keys.parse(config("NOSTR_NSEC", cast=str))
signer = NostrSigner.keys(keys)
client = Client(signer)

Expand All @@ -24,6 +27,7 @@ async def send_order_event(self, order):
await client.connect()

event = EventBuilder(38383, "", self.generate_tags(order)).to_event(keys)
event.custom_created_at(order.created_at.timestamp())
output = await client.send_event(event)
print(f"Nostr event sent: {output}")

Expand All @@ -38,7 +42,7 @@ def generate_tags(self, order):
["k", order.type.lower()],
["f", order.currency],
["s", self.get_status_tag(order)],
["amt", order.last_satoshis],
["amt", "0"],
["fa", order.amount],
["pm", order.payment_method.split(" ")],
["premium", order.premium_percentile],
Expand All @@ -47,13 +51,12 @@ def generate_tags(self, order):
f"{config("HOST_NAME")}/{config("COORDINATOR_ALIAS")}/order/{order.id}",
],
["expiration", order.expires_at.timestamp()],
["y", "robosats"],
["y", "robosats", config("COORDINATOR_ALIAS", cast=str)],
["n", order.network],
["layer", "lightning"],
["g", pygeohash.encode(order.latitude, order.longitude)],
["bond", order.bond],
["z", "order"],
["coordinator", config("COORDINATOR_ALIAS", cast=str)],
]

def get_status_tag(self, order):
Expand Down
2 changes: 1 addition & 1 deletion tests/strfry/config/strfry.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ events {

relay {
# Interface to listen on. Use 0.0.0.0 to listen on all interfaces (restart required)
bind = "127.0.0.1"
bind = "0.0.0.0"

# Port to open for the nostr websocket protocol (restart required)
port = 7777
Expand Down

0 comments on commit 0df3690

Please sign in to comment.