def broadcast_tx(self, txdata): '''Broadcast new transaction (as a hex stream) to trusted node''' tx = halfnode.msg_tx() tx.deserialize(StringIO.StringIO(binascii.unhexlify(txdata))) alternate = get_alternate_connection() d = alternate.observe_tx("%x" % tx.tx.calc_sha256(), 5) self.send_message(tx) # Defer will throw confirm when alternate connection # confirm that tx has been broadcasted or errback on timeouts return d
def connectionMade(self): halfnode.BitcoinP2PProtocol.connectionMade(self) if self.on_connect: log("Checking connection ready") self.on_connect.callback(True) self.on_connect = None if self.send_or_check == True: # We're sending transaction self.broadcast_tx(self.tx) log("Transaction broadcasted to the network") else: # We're watching transaction tx = halfnode.msg_tx() tx.deserialize(StringIO.StringIO(binascii.unhexlify(self.tx))) tx.tx.calc_sha256() self.txhash = tx.tx.sha256 log("Watching the network for %x" % self.txhash)
def broadcast_tx(self, txdata): '''Broadcast new transaction (as a hex stream) to trusted node''' tx = halfnode.msg_tx() tx.deserialize(StringIO.StringIO(binascii.unhexlify(txdata))) self.send_message(tx)