1
0

store and display signatures of own requests

This commit is contained in:
ThomasV
2015-07-09 14:15:30 +02:00
parent affd64125c
commit cb2bc54f96
4 changed files with 46 additions and 28 deletions

View File

@@ -297,6 +297,7 @@ def make_payment_request(outputs, memo, time, expires, key_path, cert_path, alia
pr = pb2.PaymentRequest()
pr.serialized_payment_details = pd.SerializeToString()
pr.signature = ''
requestor = None
if alias and alias_privkey:
pr.pki_type = 'dnssec+btc'
@@ -306,6 +307,7 @@ def make_payment_request(outputs, memo, time, expires, key_path, cert_path, alia
address = bitcoin.address_from_private_key(alias_privkey)
compressed = bitcoin.is_compressed(alias_privkey)
pr.signature = ec_key.sign_message(message, compressed, address)
requestor = alias
if key_path and cert_path:
import tlslite
@@ -322,7 +324,9 @@ def make_payment_request(outputs, memo, time, expires, key_path, cert_path, alia
hashBytes = bytearray(hashlib.sha256(msgBytes).digest())
sig = rsakey.sign(x509.PREFIX_RSA_SHA256 + hashBytes)
pr.signature = bytes(sig)
return pr.SerializeToString()
requestor = 'x'
return pr, requestor
def make_request(config, req, alias=None, alias_privkey=None):

View File

@@ -1256,16 +1256,22 @@ class Abstract_Wallet(object):
status = PR_UNKNOWN
return status
def add_payment_request(self, addr, amount, message, expiration, config):
import paymentrequest, shutil, os
def make_payment_request(self, addr, amount, message, expiration):
timestamp = int(time.time())
_id = Hash(addr + "%d"%timestamp).encode('hex')[0:10]
r = {'timestamp':timestamp, 'amount':amount, 'expiration':expiration, 'address':addr, 'memo':message, 'id':_id}
self.receive_requests[addr] = r
return r
def add_payment_request(self, req, config):
import paymentrequest, shutil, os
addr = req['address']
amount = req.get('amount')
message = req.get('memo')
self.receive_requests[addr] = req
self.storage.put('payment_requests', self.receive_requests)
self.set_label(addr, message) # should be a default label
rdir = config.get('requests_dir')
req = self.get_payment_request(addr, config)
if rdir and amount is not None:
if not os.path.exists(rdir):
os.mkdir(rdir)