def on_JM_IOAUTH(self, nick, utxolist, pubkey, cjaddr, changeaddr, pubkeysig): """Daemon constructs full !ioauth message to be sent on message channel based on data from Maker. Relevant data (utxos, addresses) are stored in the active_orders dict keyed by the nick of the Taker. """ nick, utxolist, pubkey, cjaddr, changeaddr, pubkeysig = [_byteify( x) for x in nick, utxolist, pubkey, cjaddr, changeaddr, pubkeysig] if not self.role == "MAKER": return if not nick in self.active_orders: return utxos= json.loads(utxolist) #completed population of order/offer object self.active_orders[nick]["cjaddr"] = cjaddr self.active_orders[nick]["changeaddr"] = changeaddr self.active_orders[nick]["utxos"] = utxos msg = str(",".join(utxos.keys())) + " " + " ".join( [pubkey, cjaddr, changeaddr, pubkeysig]) self.mcc.prepare_privmsg(nick, "ioauth", msg) #In case of *blacklisted (ie already used) commitments, we already #broadcasted them on receipt; in case of valid, and now used commitments, #we broadcast them here, and not early - to avoid accidentally #blacklisting commitments that are broadcast between makers in real time #for the same transaction. self.transfer_commitment(self.active_orders[nick]["commit"]) #now persist the fact that the commitment is actually used. check_utxo_blacklist(self.active_orders[nick]["commit"], persist=True) return {"accepted": True}
def on_JM_TX_SIGS(self, nick, sigs): """Signatures that the Maker has produced are passed here to the daemon as a list and broadcast one by one. TODO: could shorten this, have more than one sig per message. """ sigs = _byteify(json.loads(sigs)) for sig in sigs: self.mcc.prepare_privmsg(nick, "sig", sig) return {"accepted": True}
def on_JM_TX_RECEIVED(self, nick, txhex, offer): offer = _byteify(json.loads(offer)) retval = self.client.on_tx_received(nick, txhex, offer) if not retval[0]: jlog.info("Maker refuses to continue on receipt of tx") else: sigs = retval[1] self.finalized_offers[nick] = offer tx = btc.deserialize(txhex) self.finalized_offers[nick]["txd"] = tx jm_single().bc_interface.add_tx_notify(tx, self.unconfirm_callback, self.confirm_callback, offer["cjaddr"], wallet_name=jm_single().bc_interface.get_wallet_name( self.client.wallet), txid_flag=False, vb=get_p2sh_vbyte()) d = self.callRemote(commands.JMTXSigs, nick=nick, sigs=json.dumps(sigs)) self.defaultCallbacks(d) return {"accepted": True}
def on_JM_TX_SIGS(self, nick, sigs): sigs = _byteify(json.loads(sigs)) for sig in sigs: self.mcc.prepare_privmsg(nick, "sig", sig) return {"accepted": True}