Beispiel #1
0
	def request(self, amount, receipt):
		"""
		Request a payment.

		Arguments:
		amount : The amount (integer, in Satoshi) to be paid
		receipt: A receipt for the payment

		Return value:
		The URL of the payment request
		"""

		#ID can be nonsecure random:
		#It only needs to be semi-unique, not secret.
		ID = randomsource.getNonSecureRandom(8).encode("hex")

		#Token must be secure random
		token = randomsource.getSecureRandom(32)

		newPayee = paylink.Payee(
			self.context, self.routingContext, ID, amount, receipt, token)
		self.payees.append(newPayee)

		return "amikopay://%s/%s" % \
			(self.settings.getAdvertizedNetworkLocation(), ID)
Beispiel #2
0
	def msg_request(self, msg):
		#ID can be nonsecure random:
		#It only needs to be semi-unique, not secret.
		payeeLinkID = randomsource.getNonSecureRandom(8).encode("hex")

		#Token must be secure random
		token = randomsource.getSecureRandom(32)

		newPayeeLink = payeelink.PayeeLink(
			amount=msg.amount, receipt=msg.receipt, token=token)

		self.payeeLinks[payeeLinkID] = newPayeeLink

		self.connections[payeeLinkID] = \
			persistentconnection.PersistentConnection(host=None, port=None)

		#Returned messages:
		return [messages.ReturnValue(value=payeeLinkID)]
Beispiel #3
0
	def msg_request(self, msg):
		#ID can be nonsecure random:
		#It only needs to be semi-unique, not secret.
		payeeLinkID = randomsource.getNonSecureRandom(8).encode("hex")

		#Token must be secure random
		token = randomsource.getSecureRandom(32)

		newPayeeLink = payeelink.PayeeLink(
			ID=payeeLinkID,
			amount=msg.amount, receipt=msg.receipt, token=token,
			meetingPoints=msg.meetingPoints, routingContext=msg.routingContext)

		self.payeeLinks[payeeLinkID] = newPayeeLink

		self.connections[payeeLinkID] = \
			persistentconnection.PersistentConnection(host=None, port=None)

		#Returned messages:
		return [messages.ReturnValue(value=payeeLinkID)]
Beispiel #4
0
	def makeConnection(self, address, localID, connectMessage):
		log.log('Making connection %s' % localID)

		if self.interfaceExists(localID):
			log.log('Connection %s already exists -> don\'t create it' % localID)
			return

		try:
			sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
			sock.connect(address)
		except Exception as e:
			log.log("Connect failed: " + str(e))
			raise ConnectFailed("Connect failed: " + str(e))

		connection = self.makeConnectionFromSocket(sock)
		connection.localID = localID
		connection.dice = randomsource.getNonSecureRandom(numBytes=4)

		connectMessage.dice = connection.dice
		connection.sendMessage(None, connectMessage)

		return connection
Beispiel #5
0
    def makeConnection(self, address, localID, connectMessage):
        log.log('Making connection %s' % localID)

        if self.interfaceExists(localID):
            log.log('Connection %s already exists -> don\'t create it' %
                    localID)
            return

        try:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.connect(address)
        except Exception as e:
            log.log("Connect failed: " + str(e))
            raise ConnectFailed("Connect failed: " + str(e))

        connection = self.makeConnectionFromSocket(sock)
        connection.localID = localID
        connection.dice = randomsource.getNonSecureRandom(numBytes=4)

        connectMessage.dice = connection.dice
        connection.sendMessage(None, connectMessage)

        return connection