Browse Source

prettyify commands module, remove unused commands

master
Adam Gibson 9 years ago
parent
commit
e685274363
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 151
      jmbase/jmbase/commands.py
  2. 4
      jmdaemon/jmdaemon/daemon_protocol.py

151
jmbase/jmbase/commands.py

@ -14,7 +14,12 @@ class JMCommand(Command):
#a default response type #a default response type
response = [('accepted', Boolean())] response = [('accepted', Boolean())]
#commands from client to daemon """COMMANDS FROM CLIENT TO DAEMON
=================================
"""
"""Messages used by both MAKER and TAKER
"""
class JMInit(JMCommand): class JMInit(JMCommand):
"""Communicates the client's required setup """Communicates the client's required setup
@ -36,52 +41,74 @@ class JMStartMC(JMCommand):
arguments = [('nick', String())] arguments = [('nick', String())]
class JMSetup(JMCommand): class JMSetup(JMCommand):
"""Communicates which of "MAKER" or "TAKER"
roles are to be taken by this client; for MAKER
role, passes initial offers for announcement (for TAKER, this data is "none")
"""
arguments = [('role', String()), arguments = [('role', String()),
('initdata', String())] ('initdata', String())]
"""Taker specific commands class JMMsgSignature(JMCommand):
"""A response to a request for a bitcoin signature
on a message-channel layer message from the daemon
"""
arguments = [('nick', String()),
('cmd', String()),
('msg_to_return', String()),
('hostid', String())]
class JMMsgSignatureVerify(JMCommand):
"""A response to a request to verify the bitcoin signature
of a message-channel layer message from the daemon
"""
arguments = [('verif_result', Boolean()),
('nick', String()),
('fullmsg', String()),
('hostid', String())]
"""TAKER specific commands
""" """
class JMRequestOffers(JMCommand): class JMRequestOffers(JMCommand):
"""Get orderbook from daemon
"""
arguments = [] arguments = []
class JMFill(JMCommand): class JMFill(JMCommand):
"""Fill an offer/order
"""
arguments = [('amount', Integer()), arguments = [('amount', Integer()),
('commitment', String()), ('commitment', String()),
('revelation', String()), ('revelation', String()),
('filled_offers', String())] ('filled_offers', String())]
class JMMakeTx(JMCommand): class JMMakeTx(JMCommand):
"""Send a hex encoded raw bitcoin transaction
to a set of counterparties
"""
arguments = [('nick_list', String()), arguments = [('nick_list', String()),
('txhex', String())] ('txhex', String())]
class JMPushTx(JMCommand): class JMPushTx(JMCommand):
"""Pass a raw hex transaction to a specific
counterparty (maker) for pushing (anonymity feature in JM)
"""
arguments = [('nick', String()), arguments = [('nick', String()),
('txhex', String())] ('txhex', String())]
class JMMsgSignature(JMCommand): """MAKER specific commands
arguments = [('nick', String()),
('cmd', String()),
('msg_to_return', String()),
('hostid', String())]
class JMMsgSignatureVerify(JMCommand):
arguments = [('verif_result', Boolean()),
('nick', String()),
('fullmsg', String()),
('hostid', String())]
"""Maker specific commands
""" """
class JMAnnounceOffers(JMCommand): class JMAnnounceOffers(JMCommand):
"""Send list (actually dict) of offers
to the daemon
"""
arguments = [('offerlist', String())] arguments = [('offerlist', String())]
class JMMakerPubkey(JMCommand):
arguments = [('nick', String()),
('pubkey', String())]
class JMIOAuth(JMCommand): class JMIOAuth(JMCommand):
"""Send contents of !ioauth message after
verifying Taker's auth message
"""
arguments = [('nick', String()), arguments = [('nick', String()),
('utxolist', String()), ('utxolist', String()),
('pubkey', String()), ('pubkey', String()),
@ -90,42 +117,94 @@ class JMIOAuth(JMCommand):
('pubkeysig', String())] ('pubkeysig', String())]
class JMTXSigs(JMCommand): class JMTXSigs(JMCommand):
"""Send signatures on the bitcoin transaction
sent by TAKER
"""
arguments = [('nick', String()), arguments = [('nick', String()),
('sigs', String())] ('sigs', String())]
#commands from daemon to client """COMMANDS FROM CLIENT TO DAEMON
=================================
"""
class JMInitProto(JMCommand): class JMInitProto(JMCommand):
"""Pass to the client the messaging protocol parameters
(which are defined in daemon package), required to construct
the user nick, given the bitcoin private key used for authentication
(that key being controlled by the client; the daemon knows nothing
about bitcoin).
"""
arguments = [('nick_hash_length', Integer()), arguments = [('nick_hash_length', Integer()),
('nick_max_encoded', Integer()), ('nick_max_encoded', Integer()),
('joinmarket_nick_header', String()), ('joinmarket_nick_header', String()),
('joinmarket_version', Integer())] ('joinmarket_version', Integer())]
class JMUp(JMCommand): class JMUp(JMCommand):
"""Used to signal readiness of message channels to client.
"""
arguments = [] arguments = []
class JMSetupDone(JMCommand): class JMSetupDone(JMCommand):
"""Used to signal that initial setup action
has been taken (e.g. !orderbook call).
"""
arguments = [] arguments = []
class JMRequestMsgSig(JMCommand):
"""Request the client to sign a message-channel
layer message with the bitcoin key for the nick
"""
arguments = [('nick', String()),
('cmd', String()),
('msg', String()),
('msg_to_be_signed', String()),
('hostid', String())]
class JMRequestMsgSigVerify(JMCommand):
"""Request the client to verify a counterparty's
message-channel layer message against the provided nick
"""
arguments = [('msg', String()),
('fullmsg', String()),
('sig', String()),
('pubkey', String()),
('nick', String()),
('hashlen', Integer()),
('max_encoded', Integer()),
('hostid', String())]
""" TAKER-specific commands
"""
class JMOffers(JMCommand): class JMOffers(JMCommand):
"""Return the entire contents of the
orderbook to TAKER, as a json-ified dict;
note uses BigString because can be very large
"""
arguments = [('orderbook', BigString())] arguments = [('orderbook', BigString())]
class JMFillResponse(JMCommand): class JMFillResponse(JMCommand):
"""Returns ioauth data from MAKER if successful.
"""
arguments = [('success', Boolean()), arguments = [('success', Boolean()),
('ioauth_data', String())] ('ioauth_data', String())]
class JMSigReceived(JMCommand): class JMSigReceived(JMCommand):
"""Returns an individual bitcoin transaction signature
from a MAKER
"""
arguments = [('nick', String()), arguments = [('nick', String()),
('sig', String())] ('sig', String())]
"""Maker specific daemon-client messages """MAKER-specific commands
""" """
class JMCommitmentOpen(JMCommand):
arguments = [('nick', String()),
('revelation', String())]
class JMAuthReceived(JMCommand): class JMAuthReceived(JMCommand):
"""Return the commitment and revelation
provided in !fill, !auth by the TAKER,
allowing the MAKER to verify against btc library
before setting up encryption and continuing.
"""
arguments = [('nick', String()), arguments = [('nick', String()),
('offer', String()), ('offer', String()),
('commitment', String()), ('commitment', String()),
@ -134,23 +213,9 @@ class JMAuthReceived(JMCommand):
('kphex', String())] ('kphex', String())]
class JMTXReceived(JMCommand): class JMTXReceived(JMCommand):
"""Send back transaction template provided
by TAKER, along with offerdata to verify fees.
"""
arguments = [('nick', String()), arguments = [('nick', String()),
('txhex', String()), ('txhex', String()),
('offer', String())] ('offer', String())]
class JMRequestMsgSig(JMCommand):
arguments = [('nick', String()),
('cmd', String()),
('msg', String()),
('msg_to_be_signed', String()),
('hostid', String())]
class JMRequestMsgSigVerify(JMCommand):
arguments = [('msg', String()),
('fullmsg', String()),
('sig', String()),
('pubkey', String()),
('nick', String()),
('hashlen', Integer()),
('max_encoded', Integer()),
('hostid', String())]

4
jmdaemon/jmdaemon/daemon_protocol.py

@ -197,10 +197,6 @@ class JMDaemonServerProtocol(amp.AMP, OrderbookWatch):
self.jm_state = 1 self.jm_state = 1
return {'accepted': True} return {'accepted': True}
@JMMakerPubkey.responder
def on_JM_MAKER_PUBKEY(self, nick, pubkey):
self.mcc.prepare_privmsg(nick, "pubkey", pubkey)
@JMTXSigs.responder @JMTXSigs.responder
def on_JM_TX_SIGS(self, nick, sigs): def on_JM_TX_SIGS(self, nick, sigs):
sigs = _byteify(json.loads(sigs)) sigs = _byteify(json.loads(sigs))

Loading…
Cancel
Save