Package: nostrfastr
nostrfastrWhat is this?This package attempts to be a well documented and tested instance of a
very basic client framework and other tools that use the nostr
protocol. The goal is to help others understand nostr quickly and get
started sending messages from python in minutes.Contained is a collection of tools built on top of this basicClientclass showing some potential uses of nostr any how quickly we can
build on it in python.A “sentinel” node that serves as a barebones client to rebroadcast
user data across additional nostr relays. While this is a relatively
simple concept I haven’t seen much discussion around the potential
benefits and implications.notifyr- a decorator that will alert on success or failure of any
decorated function via nostr DMa vanity address generator decorated with the notifyr function so
you can leave it running and get notified when it finishesWhy nbdev?This library uses thenbdevframework to
aggregate some useful tools frompython-nostrinto a more
structuredclientclass that could serve as the basis for other python
tools.nbdevis great because it allows for relatively easy
development of code in-line with readable and explanatory documentation.
This webpage is a rendering of the same notebooks that are exported to
form the package code. If you clone the Github repository you can view
and run the code you see in the documentation. It will almost certainly
not be the most perfomant way to implement much of what I am doing here,
but I hope it can make thenostrprotocol more
accessible to a wider audience.SuggestionsIf you have suggestions for topics or concepts related to nostr that
this package could help document or explain in python, please feel free
tosubmit an issue with a suggestion
hereKnown issuesnotifyr-
see thenotifyrpage for more detail on these issueskeyringmay need uninstalled dependencies on linux buildsCurrent spec of nostr DMs is likely not adequate for secure usage of
this module for sensitive data.Installpipinstallnostrfastror alternatively, clone the github repositorand refer to this
guideto get started
working in nbdev.How to useDocumentation can be found athttps://armstrys.github.io/nostrfastr/fromnostrfastr.clientimportClientConnect and perform an operation…withClient(relay_urls=['wss://relay.damus.io'])asclient:print('Are we connected?')print('\t',client.relay_manager.connection_statuses)print('Are we connected?')print('\t',client.relay_manager.connection_statuses)Are we connected?
     {'wss://relay.damus.io': True}
Are we connected?
     {'wss://relay.damus.io': False}And use the client to build something useful with nostr - like a bot
that notifies you of your python processing status on long code runsfromnostrfastr.notifyrimportnotifyr@notifyrdefraise_error():raiseException('Oh no! Process failed!')@notifyrdefsuccess():return1+1Or generate an vanity address and have it notify you at another nostr
address when it’s donefromnostrfastr.vanityimportvanity_notifyrprivate_key=vanity_notifyr(startswith='23',style='npub')print(private_key.public_key.bech32())/Users/ryanarmstrong/python/nostrfastr/nostrfastr/client.py:479: UserWarning: the current implementation of messages should be used with caution
                    see https://github.com/nostr-protocol/nips/issues/107
  warnings.warn('''the current implementation of messages should be used with caution

It might take 0 seconds to find a npub pubkey that starts with npub123. Note that this is a very rough estimate and due to the random nature of finding vanity keys it could take MUCH longer.
npub1237z2shf8rlgs8xqg0cggz7dhxjtkszy205wesht2xr3nat86m7s30lqw5