# Path: jmbase/jmbase/arguments.py
# class JsonEncodable(String):
#     def toString(self, inObject):
#         return super().toString(json.dumps(inObject).encode('ascii'))
# 
#     def fromString(self, inString):
#         return super().fromString(json.loads(inString))


from twisted.protocols.amp import Boolean, Command, Integer, Unicode, ListOf,\
    String
from .bigstring import BigUnicode
from .arguments import JsonEncodable
class SNICKERRequestPowTarget(JMCommand):
    arguments = [(b'server', Unicode())]

class SNICKERReceivePowTarget(JMCommand):
    arguments = [(b'server', Unicode()),
                 (b'targetbits', Integer())]

""" Payjoin-related commands
"""

""" Sender-specific commands.
"""

class BIP78SenderInit(JMCommand):
    """ Initialization data for a BIP78 service.
    See documentation of `netconfig` in
    jmdaemon.HTTPPassThrough.on_INIT
    """
    arguments = [(b'netconfig', JsonEncodable())]

class BIP78SenderUp(JMCommand):
    arguments = []

class BIP78SenderOriginalPSBT(JMCommand):
    """ Sends the payjoin url and the original
    payment PSBT, base64 encoded,
    from the client to the daemon,
    to be sent as an http request to the receiver.
    """
    arguments = [(b'body', BigUnicode()),

# Path: jmbase/jmbase/arguments.py
# class JsonEncodable(String):
#     def toString(self, inObject):
#         return super().toString(json.dumps(inObject).encode('ascii'))
# 
#     def fromString(self, inString):
#         return super().fromString(json.loads(inString))


# Path: jmbase/jmbase/commands.py
from twisted.protocols.amp import Boolean, Command, Integer, Unicode, ListOf,\
    String
from .bigstring import BigUnicode
from .arguments import JsonEncodable

class SNICKERRequestPowTarget(JMCommand):
    arguments = [(b'server', Unicode())]

class SNICKERReceivePowTarget(JMCommand):
    arguments = [(b'server', Unicode()),
                 (b'targetbits', Integer())]

""" Payjoin-related commands
"""

""" Sender-specific commands.
"""

class BIP78SenderInit(JMCommand):
    """ Initialization data for a BIP78 service.
    See documentation of `netconfig` in
    jmdaemon.HTTPPassThrough.on_INIT
    """
    arguments = [(b'netconfig', JsonEncodable())]

class BIP78SenderUp(JMCommand):
    arguments = []

class BIP78SenderOriginalPSBT(JMCommand):
    """ Sends the payjoin url and the original
    payment PSBT, base64 encoded,
    from the client to the daemon,
    to be sent as an http request to the receiver.
    """
    arguments = [(b'body', BigUnicode()),

                 (b'params', JsonEncodable())]