Exemplo n.º 1
0
def test_download_single_squeak(
    admin_stub,
    other_admin_stub,
    signing_profile_id,
    saved_squeak_hash,
    admin_peer,
):

    with subscribe_squeak_entry(other_admin_stub, saved_squeak_hash) as subscription_queue, \
            subscribe_squeak_ancestor_entries(other_admin_stub, saved_squeak_hash) as ancestor_subscription_queue:

        # Get the squeak display item (should be empty)
        squeak_display_entry = get_squeak_display(
            other_admin_stub, saved_squeak_hash)
        assert squeak_display_entry is None

        # Get buy offers for the squeak hash (should be empty)
        get_buy_offers_response = other_admin_stub.GetBuyOffers(
            squeak_admin_pb2.GetBuyOffersRequest(
                squeak_hash=saved_squeak_hash,
            )
        )
        # print(get_buy_offers_response)
        assert len(get_buy_offers_response.offers) == 0

        # Download squeak
        download_result = download_squeak(other_admin_stub, saved_squeak_hash)
        # Download secret key
        download_squeak_secret_key(other_admin_stub, saved_squeak_hash)
        assert download_result.number_downloaded == 1
        assert download_result.number_requested == 1

        # Get the squeak display item
        squeak_display_entry = get_squeak_display(
            other_admin_stub, saved_squeak_hash)
        assert squeak_display_entry is not None

        # Get the buy offer
        get_buy_offers_response = other_admin_stub.GetBuyOffers(
            squeak_admin_pb2.GetBuyOffersRequest(
                squeak_hash=saved_squeak_hash,
            )
        )
        # print(get_buy_offers_response)
        assert len(get_buy_offers_response.offers) > 0

        item = subscription_queue.get()
        print("subscription_queue item:")
        print(item)
        assert item.squeak_hash == saved_squeak_hash

        item = ancestor_subscription_queue.get()
        print("ancestor_subscription_queue item:")
        print(item)
        assert item[0].squeak_hash == saved_squeak_hash
Exemplo n.º 2
0
def test_download_squeaks_for_address(
    admin_stub,
    other_admin_stub,
    connected_tcp_peer_id,
    signing_profile_id,
    saved_squeak_hash,
):
    squeak_profile = get_squeak_profile(admin_stub, signing_profile_id)
    squeak_profile_address = squeak_profile.address

    with subscribe_squeaks_for_address(
            other_admin_stub, squeak_profile_address) as subscription_queue:

        # Get the squeak display item (should be empty)
        squeak_display_entry = get_squeak_display(other_admin_stub,
                                                  saved_squeak_hash)
        assert squeak_display_entry is None

        # Get buy offers for the squeak hash (should be empty)
        get_buy_offers_response = other_admin_stub.GetBuyOffers(
            squeak_admin_pb2.GetBuyOffersRequest(
                squeak_hash=saved_squeak_hash, ))
        # print(get_buy_offers_response)
        assert len(get_buy_offers_response.offers) == 0

        # Download squeaks for address
        download_result = download_squeaks_for_address(other_admin_stub,
                                                       squeak_profile_address)
        assert download_result.number_downloaded == 1
        assert download_result.number_requested == 10

        # Get the squeak display item
        squeak_display_entry = get_squeak_display(other_admin_stub,
                                                  saved_squeak_hash)
        assert squeak_display_entry is not None

        item = subscription_queue.get()
        print("item:")
        print(item)
        assert item.squeak_hash == saved_squeak_hash
Exemplo n.º 3
0
def test_buy_squeak(
    admin_stub,
    other_admin_stub,
    connected_tcp_peer_id,
    signing_profile_id,
    saved_squeak_hash,
):
    # Download squeak
    download_squeak(other_admin_stub, saved_squeak_hash)

    # Download offer
    download_offers(other_admin_stub, saved_squeak_hash)
    time.sleep(5)

    # Get the sent offers from the seller node
    get_sent_offers_response = admin_stub.GetSentOffers(
        squeak_admin_pb2.GetSentOffersRequest(), )
    squeak_hashes = [
        sent_offer.squeak_hash
        for sent_offer in get_sent_offers_response.sent_offers
    ]
    assert saved_squeak_hash in squeak_hashes

    # Get the buy offer
    get_buy_offers_response = other_admin_stub.GetBuyOffers(
        squeak_admin_pb2.GetBuyOffersRequest(squeak_hash=saved_squeak_hash, ))
    # print(get_buy_offers_response)
    assert len(get_buy_offers_response.offers) > 0

    offer = get_buy_offers_response.offers[0]

    print("Tring to connect LND peer with offer: {}".format(offer))
    with peer_connection(other_admin_stub, offer.node_host,
                         offer.node_pubkey), channel(other_admin_stub,
                                                     offer.node_pubkey,
                                                     1000000):

        print("Channel context manager opened.")

        # Pay the offer
        list_channels_response = other_admin_stub.LndListChannels(
            ln.ListChannelsRequest(active_only=True, ))
        print("list_channels_response: {}".format(list_channels_response))

        # Pay the offer
        pay_offer_response = other_admin_stub.PayOffer(
            squeak_admin_pb2.PayOfferRequest(offer_id=offer.offer_id, ))
        # print(pay_offer_response)
        assert pay_offer_response.sent_payment_id > 0

        # Get the squeak display item
        get_squeak_display_entry = get_squeak_display(other_admin_stub,
                                                      saved_squeak_hash)
        assert (get_squeak_display_entry.content_str ==
                "Hello from the profile on the server!")

        # Get all sent payments
        get_sent_payments_response = other_admin_stub.GetSentPayments(
            squeak_admin_pb2.GetSentPaymentsRequest(limit=10, ), )
        squeak_hashes = [
            sent_payment.squeak_hash
            for sent_payment in get_sent_payments_response.sent_payments
        ]
        assert saved_squeak_hash in squeak_hashes

        # Get the single sent payment
        for sent_payment in get_sent_payments_response.sent_payments:
            if sent_payment.squeak_hash == saved_squeak_hash:
                sent_payment_id = sent_payment.sent_payment_id
        get_sent_payment_response = other_admin_stub.GetSentPayment(
            squeak_admin_pb2.GetSentPaymentRequest(
                sent_payment_id=sent_payment_id, ), )
        assert saved_squeak_hash == get_sent_payment_response.sent_payment.squeak_hash
        assert get_sent_payment_response.sent_payment.price_msat == 1000000
        assert get_sent_payment_response.sent_payment.valid

        # Get the received payment from the seller node
        get_received_payments_response = admin_stub.GetReceivedPayments(
            squeak_admin_pb2.GetReceivedPaymentsRequest(limit=100, ), )
        # print(
        #     "get_received_payments_response: {}".format(
        #         get_received_payments_response)
        # )
        payment_hashes = [
            received_payment.payment_hash for received_payment in
            get_received_payments_response.received_payments
        ]
        assert sent_payment.payment_hash in payment_hashes
        for received_payment in get_received_payments_response.received_payments:
            received_payment_time_ms = received_payment.time_ms
            # print("received_payment_time_s: {}".format(
            #     received_payment_time_s))
            received_payment_time = datetime.datetime.fromtimestamp(
                received_payment_time_ms / 1000, )
            five_minutes = datetime.timedelta(minutes=5)
            assert received_payment_time > datetime.datetime.now(
            ) - five_minutes
            assert received_payment_time < datetime.datetime.now()
            assert len(received_payment.peer_address.host) > 4

        # Subscribe to received payments starting from index zero
        subscribe_received_payments_response = admin_stub.SubscribeReceivedPayments(
            squeak_admin_pb2.SubscribeReceivedPaymentsRequest(
                payment_index=0, ), )
        for payment in subscribe_received_payments_response:
            # print("Got payment from subscription: {}".format(payment))
            assert payment.received_payment_id == 1
            break

        # Get the payment summary from the seller node
        get_payment_summary_response = admin_stub.GetPaymentSummary(
            squeak_admin_pb2.GetPaymentSummaryRequest(), )
        # print(
        #     "get_payment_summary_response from seller: {}".format(
        #         get_payment_summary_response)
        # )
        assert get_payment_summary_response.payment_summary.num_received_payments > 0
        assert get_payment_summary_response.payment_summary.amount_earned_msat > 0

        # Get the payment summary from the buyer node
        get_payment_summary_response = other_admin_stub.GetPaymentSummary(
            squeak_admin_pb2.GetPaymentSummaryRequest(), )
        # print(
        #     "get_payment_summary_response from buyer: {}".format(
        #         get_payment_summary_response)
        # )
        assert get_payment_summary_response.payment_summary.num_sent_payments > 0
        assert get_payment_summary_response.payment_summary.amount_spent_msat > 0

    print("Channel context manager closed.")
Exemplo n.º 4
0
def create_app(handler, username, password):
    # create and configure the app
    logger.debug("Starting flask app from directory: {}".format(os.getcwd()))
    app = Flask(
        __name__,
        static_url_path="/",
        static_folder="static/build",
    )
    app.config.from_mapping(SECRET_KEY="dev", )
    login = LoginManager(app)
    valid_user = User(
        username,
        password,
    )
    logger.debug("Starting flask with app.root_path: {}".format(app.root_path))
    logger.debug("Files in root path: {}".format(os.listdir(app.root_path)))

    @login.user_loader
    def load_user(id):
        return valid_user.get_user_by_username(id)

    @login.unauthorized_handler
    def unauthorized_callback():
        return redirect(url_for("login"))

    def protobuf_serialized(request_message):
        def decorator(func):
            @wraps(func)
            def wrapper(*args, **kwargs):
                data = request.get_data()
                request_message.ParseFromString(data)
                try:
                    reply = func(request_message)
                    return reply.SerializeToString()
                except Exception as e:
                    logger.exception("Error in handle admin web request.")
                    return str(e), 500

            return wrapper

        return decorator

    @app.route("/login", methods=["GET", "POST"])
    def login():
        logger.info("Trying to login")
        if current_user.is_authenticated:
            return redirect(url_for("index"))
        default_username = request.args.get('user')
        form = LoginForm(username=default_username)
        if form.validate_on_submit():
            user = valid_user.get_user_by_username(form.username.data)
            if user is None or not user.check_password(form.password.data):
                flash("Invalid username or password")
                return redirect(url_for("login"))
            login_user(user, remember=form.remember_me.data)
            return redirect(url_for("index"))
        return render_template("login.html", title="Sign In", form=form)

    @app.route("/logout")
    def logout():
        logout_user()
        return redirect(url_for("index"))

    @app.route("/")
    @login_required
    def index():
        logger.info("Getting index route.")
        return app.send_static_file("index.html")

    @app.route("/user")
    @login_required
    def user():
        logger.info("Getting user.")
        return current_user.username

    @app.route("/lndgetinfo", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.GetInfoRequest())
    def lndgetinfo(msg):
        return handler.handle_lnd_get_info(msg)

    @app.route("/lndwalletbalance", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.WalletBalanceRequest())
    def lndwalletbalance(msg):
        return handler.handle_lnd_wallet_balance(msg)

    @app.route("/lndgettransactions", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.GetTransactionsRequest())
    def lndgettransactions(msg):
        return handler.handle_lnd_get_transactions(msg)

    @app.route("/lndlistpeers", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.ListPeersRequest())
    def lndlistpeers(msg):
        return handler.handle_lnd_list_peers(msg)

    @app.route("/lndlistchannels", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.ListChannelsRequest())
    def lndlistchannels(msg):
        return handler.handle_lnd_list_channels(msg)

    @app.route("/lndpendingchannels", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.PendingChannelsRequest())
    def lndpendingchannels(msg):
        return handler.handle_lnd_pending_channels(msg)

    @app.route("/lndconnectpeer", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.ConnectPeerRequest())
    def lndconnectpeer(msg):
        return handler.handle_lnd_connect_peer(msg)

    @app.route("/lnddisconnectpeer", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.DisconnectPeerRequest())
    def lnddisconnectpeer(msg):
        return handler.handle_lnd_disconnect_peer(msg)

    @app.route("/lndopenchannelsync", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.OpenChannelRequest())
    def lndopenchannelsync(msg):
        return handler.handle_lnd_open_channel_sync(msg)

    @app.route("/lndclosechannel", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.CloseChannelRequest())
    def lndclosechannel(msg):
        return handler.handle_lnd_close_channel(msg)

    @app.route("/lndnewaddress", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.NewAddressRequest())
    def lndnewaddress(msg):
        return handler.handle_lnd_new_address(msg)

    @app.route("/lndsendcoins", methods=["POST"])
    @login_required
    @protobuf_serialized(lnd_pb2.SendCoinsRequest())
    def lndsendcoins(msg):
        return handler.handle_lnd_send_coins(msg)

    @app.route("/gettimelinesqueakdisplays", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetTimelineSqueakDisplaysRequest())
    def gettimelinesqueakdisplays(msg):
        return handler.handle_get_timeline_squeak_display_entries(msg)

    @app.route("/getsqueakprofile", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSqueakProfileRequest())
    def getsqueakprofile(msg):
        return handler.handle_get_squeak_profile(msg)

    @app.route("/setsqueakprofilefollowing", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.SetSqueakProfileFollowingRequest())
    def setsqueakprofilefollowing(msg):
        return handler.handle_set_squeak_profile_following(msg)

    @app.route("/renamesqueakprofile", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.RenameSqueakProfileRequest())
    def renamesqueakprofile(msg):
        return handler.handle_rename_squeak_profile(msg)

    @app.route("/setsqueakprofileimage", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.SetSqueakProfileImageRequest())
    def setsqueakprofileimage(msg):
        return handler.handle_set_squeak_profile_image(msg)

    @app.route("/clearsqueakprofileimage", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.ClearSqueakProfileImageRequest())
    def clearsqueakprofileimage(msg):
        return handler.handle_clear_squeak_profile_image(msg)

    @app.route("/getpeers", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetPeersRequest())
    def getpeers(msg):
        return handler.handle_get_squeak_peers(msg)

    @app.route("/payoffer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.PayOfferRequest())
    def payoffer(msg):
        return handler.handle_pay_offer(msg)

    @app.route("/decryptsqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DecryptSqueakRequest())
    def decryptsqueak(msg):
        return handler.handle_decrypt_squeak(msg)

    @app.route("/getbuyoffers", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetBuyOffersRequest())
    def getbuyoffers(msg):
        return handler.handle_get_buy_offers(msg)

    @app.route("/getbuyoffer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetBuyOfferRequest())
    def getbuyoffer(msg):
        return handler.handle_get_buy_offer(msg)

    @app.route("/getpeer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetPeerRequest())
    def getpeer(msg):
        return handler.handle_get_squeak_peer(msg)

    @app.route("/getpeerbyaddress", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetPeerByAddressRequest())
    def getpeerbyaddress(msg):
        return handler.handle_get_squeak_peer_by_address(msg)

    @app.route("/setpeerautoconnect", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.SetPeerAutoconnectRequest())
    def setpeerautoconnect(msg):
        return handler.handle_set_squeak_peer_autoconnect(msg)

    @app.route("/setpeershareforfree", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.SetPeerShareForFreeRequest())
    def setpeershareforfree(msg):
        return handler.handle_set_squeak_peer_share_for_free(msg)

    @app.route("/renamepeer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.RenamePeerRequest())
    def renamepeer(msg):
        return handler.handle_rename_squeak_peer(msg)

    @app.route("/getprofiles", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetProfilesRequest())
    def getprofiles(msg):
        return handler.handle_get_profiles(msg)

    @app.route("/getsigningprofiles", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSigningProfilesRequest())
    def getsigningprofiles(msg):
        return handler.handle_get_signing_profiles(msg)

    @app.route("/getcontactprofiles", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetContactProfilesRequest())
    def getcontactprofiles(msg):
        return handler.handle_get_contact_profiles(msg)

    @app.route("/makesqueakrequest", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.MakeSqueakRequest())
    def makesqueakrequest(msg):
        return handler.handle_make_squeak(msg)

    @app.route("/makeresqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.MakeResqueakRequest())
    def makeresqueak(msg):
        return handler.handle_make_resqueak(msg)

    @app.route("/getsqueakdisplay", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSqueakDisplayRequest())
    def getsqueakdisplay(msg):
        return handler.handle_get_squeak_display_entry(msg)

    @app.route("/getancestorsqueakdisplays", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetAncestorSqueakDisplaysRequest())
    def getancestorsqueakdisplays(msg):
        return handler.handle_get_ancestor_squeak_display_entries(msg)

    @app.route("/getreplysqueakdisplays", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetReplySqueakDisplaysRequest())
    def getreplysqueakdisplays(msg):
        return handler.handle_get_reply_squeak_display_entries(msg)

    @app.route("/getsqueakprofilebypubkey", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSqueakProfileByPubKeyRequest())
    def getsqueakprofilebypubkey(msg):
        return handler.handle_get_squeak_profile_by_pubkey(msg)

    @app.route("/getpubkeysqueakdisplays", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetPubKeySqueakDisplaysRequest())
    def getaddresssqueakdisplays(msg):
        return handler.handle_get_squeak_display_entries_for_pubkey(msg)

    @app.route("/getsearchsqueakdisplays", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSearchSqueakDisplaysRequest())
    def getsearchsqueakdisplays(msg):
        return handler.handle_get_squeak_display_entries_for_text_search(msg)

    @app.route("/createcontactprofile", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.CreateContactProfileRequest())
    def createcontactprofile(msg):
        return handler.handle_create_contact_profile(msg)

    @app.route("/createsigningprofile", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.CreateSigningProfileRequest())
    def createsigningprofile(msg):
        return handler.handle_create_signing_profile(msg)

    @app.route("/importsigningprofile", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.ImportSigningProfileRequest())
    def importsigningprofile(msg):
        return handler.handle_import_signing_profile(msg)

    @app.route("/createpeer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.CreatePeerRequest())
    def createpeer(msg):
        return handler.handle_create_peer(msg)

    @app.route("/deletepeer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DeletePeerRequest())
    def deletepeer(msg):
        return handler.handle_delete_squeak_peer(msg)

    @app.route("/deleteprofile", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DeleteSqueakProfileRequest())
    def deleteprofile(msg):
        return handler.handle_delete_squeak_profile(msg)

    @app.route("/deletesqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DeleteSqueakRequest())
    def deletesqueak(msg):
        return handler.handle_delete_squeak(msg)

    @app.route("/downloadsqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DownloadSqueakRequest())
    def downloadsqueak(msg):
        return handler.handle_download_squeak(msg)

    @app.route("/downloadsqueaksecretkey", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DownloadSqueakSecretKeyRequest())
    def downloadsqueaksecretkey(msg):
        return handler.handle_download_squeak_secret_key(msg)

    @app.route("/downloadoffers", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DownloadOffersRequest())
    def downloadoffers(msg):
        return handler.handle_download_offers(msg)

    @app.route("/downloadreplies", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DownloadRepliesRequest())
    def downloadreplies(msg):
        return handler.handle_download_replies(msg)

    @app.route("/downloadaddresssqueaks", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DownloadPubKeySqueaksRequest())
    def downloadaddresssqueaks(msg):
        return handler.handle_download_pubkey_squeaks(msg)

    @app.route("/getsentpayments", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSentPaymentsRequest())
    def getsentpayments(msg):
        return handler.handle_get_sent_payments(msg)

    @app.route("/getsentpaymentsforsqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSentPaymentsForSqueakRequest())
    def getsentpaymentsforsqueak(msg):
        return handler.handle_get_sent_payments_for_squeak(msg)

    @app.route("/getsentpaymentsforpubkey", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSentPaymentsForPubkeyRequest())
    def getsentpaymentsforpubkey(msg):
        return handler.handle_get_sent_payments_for_pubkey(msg)

    @app.route("/getsentpaymentsforpeer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSentPaymentsForPeerRequest())
    def getsentpaymentsforpeer(msg):
        return handler.handle_get_sent_payments_for_peer(msg)

    @app.route("/getsentoffers", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSentOffersRequest())
    def getsentoffers(msg):
        return handler.handle_get_sent_offers(msg)

    @app.route("/getreceivedpayments", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetReceivedPaymentsRequest())
    def getreceivedpayments(msg):
        return handler.handle_get_received_payments(msg)

    @app.route("/getreceivedpaymentsforsqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(
        squeak_admin_pb2.GetReceivedPaymentsForSqueakRequest())
    def getreceivedpaymentsforsqueak(msg):
        return handler.handle_get_received_payments_for_squeak(msg)

    @app.route("/getreceivedpaymentsforpubkey", methods=["POST"])
    @login_required
    @protobuf_serialized(
        squeak_admin_pb2.GetReceivedPaymentsForPubkeyRequest())
    def getreceivedpaymentsforpubkey(msg):
        return handler.handle_get_received_payments_for_pubkey(msg)

    @app.route("/getreceivedpaymentsforpeer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetReceivedPaymentsForPeerRequest())
    def getreceivedpaymentsforpeer(msg):
        return handler.handle_get_received_payments_for_peer(msg)

    @app.route("/getnetwork", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetNetworkRequest())
    def getnetwork(msg):
        return handler.handle_get_network(msg)

    @app.route("/getsqueakprofileprivatekey", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSqueakProfilePrivateKeyRequest())
    def getsqueakprofileprivatekey(msg):
        return handler.handle_get_squeak_profile_private_key(msg)

    @app.route("/getpaymentsummary", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetPaymentSummaryRequest())
    def getpaymentsummary(msg):
        return handler.handle_get_payment_summary(msg)

    @app.route("/getpaymentsummaryforsqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetPaymentSummaryForSqueakRequest())
    def getpaymentsummaryforsqueak(msg):
        return handler.handle_get_payment_summary_for_squeak(msg)

    @app.route("/getpaymentsummaryforpubkey", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetPaymentSummaryForPubkeyRequest())
    def getpaymentsummaryforpubkey(msg):
        return handler.handle_get_payment_summary_for_pubkey(msg)

    @app.route("/getpaymentsummaryforpeer", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetPaymentSummaryForPeerRequest())
    def getpaymentsummaryforpeer(msg):
        return handler.handle_get_payment_summary_for_peer(msg)

    @app.route("/reprocessreceivedpayments", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.ReprocessReceivedPaymentsRequest())
    def reprocessreceivedpayments(msg):
        return handler.handle_reprocess_received_payments(msg)

    @app.route("/likesqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.LikeSqueakRequest())
    def likesqueak(msg):
        return handler.handle_like_squeak(msg)

    @app.route("/unlikesqueak", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.UnlikeSqueakRequest())
    def unlikesqueak(msg):
        return handler.handle_unlike_squeak(msg)

    @app.route("/getlikedsqueakdisplays", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetLikedSqueakDisplaysRequest())
    def getlikedsqueakdisplays(msg):
        return handler.handle_get_liked_squeak_display_entries(msg)

    @app.route("/getexternaladdress", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetExternalAddressRequest())
    def getexternaladdress(msg):
        return handler.handle_get_external_address(msg)

    @app.route("/getdefaultpeerport", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetDefaultPeerPortRequest())
    def getdefaultpeerport(msg):
        return handler.handle_get_default_peer_port(msg)

    @app.route("/setsellprice", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.SetSellPriceRequest())
    def setsellprice(msg):
        return handler.handle_set_sell_price(msg)

    @app.route("/clearsellprice", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.ClearSellPriceRequest())
    def clearsellprice(msg):
        return handler.handle_clear_sell_price(msg)

    @app.route("/getsellprice", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetSellPriceRequest())
    def getsellprice(msg):
        return handler.handle_get_sell_price(msg)

    @app.route("/addtwitteraccount", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.AddTwitterAccountRequest())
    def addtwitteraccount(msg):
        return handler.handle_add_twitter_account(msg)

    @app.route("/gettwitteraccounts", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.GetTwitterAccountsRequest())
    def gettwitteraccounts(msg):
        return handler.handle_get_twitter_accounts(msg)

    @app.route("/deletetwitteraccount", methods=["POST"])
    @login_required
    @protobuf_serialized(squeak_admin_pb2.DeleteTwitterAccountRequest())
    def deletetwitteraccount(msg):
        return handler.handle_delete_twitter_account(msg)

    return app