def easy_add_transaction(tx_orig, privkey, DB): tx = copy.deepcopy(tx_orig) pubkey = pt.privtopub(privkey) try: tx['count'] = blockchain.count(pubkey, DB) except: tx['count'] = 1 tx['signature'] = pt.ecdsa_sign(tools.det_hash(tx), privkey) blockchain.add_tx(tx, DB)
def easy_add_transaction(tx_orig, privkey, DB): tx=copy.deepcopy(tx_orig) pubkey=tools.privtopub(privkey) try: tx['count']=blockchain.count(pubkey, DB) except: tx['count']=1 tx['signature']=[tools.sign(tools.det_hash(tx), privkey)] print('CREATED TX: ' +str(tx)) blockchain.add_tx(tx, DB)
def easy_add_transaction(tx_orig, privkey, DB): tx=copy.deepcopy(tx_orig) pubkey=tools.privtopub(privkey) address=tools.make_address([pubkey], 1) try: tx['count']=blockchain.count(address, DB) except: tx['count']=1 tx['signatures']=[tools.sign(tools.det_hash(tx), privkey)] blockchain.add_tx(tx, DB)
def easy_add_transaction(tx_orig, privkey, DB): tx = copy.deepcopy(tx_orig) pubkey = tools.privtopub(privkey) address = tools.make_address([pubkey], 1) try: tx['count'] = blockchain.count(address, DB) except: tx['count'] = 1 tx['signatures'] = [tools.sign(tools.det_hash(tx), privkey)] blockchain.add_tx(tx, DB)
def suggestions(DB): #the other thread called listener.server is listening to peers and adding #suggested transactions and blocks from them into these lists of #suggestions. for tx in DB['suggested_txs']: #print('SUGGESTED TX') #print('tx: ' +str(tx)) blockchain.add_tx(tx, DB) #[blockchain.add_tx(tx, DB) for tx in DB['suggested_txs']] [blockchain.add_block(block, DB) for block in DB['suggested_blocks']] DB['suggested_txs']=[] DB['suggested_blocks']=[]
def easy_add_transaction(tx_orig, privkey='default'): tx = copy.deepcopy(tx_orig) if privkey in ['default', 'Default']: if tools.db_existence('privkey'): privkey = tools.db_get('privkey') else: return 'No private key is known, so the tx cannot be signed. ' pubkey = tools.privtopub(privkey) address = tools.make_address([pubkey], 1) if 'count' not in tx: try: tx['count'] = tools.count(address, {}) except: tx['count'] = 1 # add our pubkey if 'pubkeys' not in tx: tx['pubkeys'] = [pubkey] # this is IMPORTANT # when adding new transaction which is signed by us, # this procedure is applied. tx without signatures is signed with our privkey. if 'signatures' not in tx: tx['signatures'] = [tools.sign(tools.det_hash(tx), privkey)] return blockchain.add_tx(tx)
def suggestions(DB): #the other thread called listener.server is listening to peers and adding #suggested transactions and blocks from them into these lists of #suggestions. [blockchain.add_tx(tx, DB) for tx in DB['suggested_txs']] [blockchain.add_block(block, DB) for block in DB['suggested_blocks']] DB['suggested_txs']=[] DB['suggested_blocks']=[]
def easy_add_transaction(tx_orig, DB): tx = copy.deepcopy(tx_orig) if 'pubkeys' not in tx: tx['pubkeys']=[DB['pubkey']] try: tx['count'] = tools.count(DB['address'], DB) except: tx['count'] = 1 tx['signatures'] = [tools.sign(tools.det_hash(tx), DB['privkey'])] return(blockchain.add_tx(tx, DB))
def easy_add_transaction(tx_orig, DB): tx = copy.deepcopy(tx_orig) if 'pubkeys' not in tx: tx['pubkeys'] = [DB['pubkey']] try: tx['count'] = tools.count(DB['address'], DB) except: tx['count'] = 1 tx['signatures'] = [tools.sign(tools.det_hash(tx), DB['privkey'])] return (blockchain.add_tx(tx, DB))
def easy_add_transaction(tx_orig, DB, privkey='default'): tx = copy.deepcopy(tx_orig) try: tx['count'] = tools.count(DB['address'], DB) except: tx['count'] = 1 if privkey=='default': if 'privkey' in DB: privkey=DB['privkey'] else: return('no private key is known, so the tx cannot be signed. Here is the tx: \n'+str(tools.package(tx_orig).encode('base64').replace('\n', ''))) if 'pubkeys' not in tx: tx['pubkeys']=[tools.privtopub(privkey)] tx['signatures'] = [tools.sign(tools.det_hash(tx), privkey)] tools.log('collect winnings 3') return(blockchain.add_tx(tx, DB))
def easy_add_transaction(tx_orig, DB, privkey='default'): tx = copy.deepcopy(tx_orig) if privkey in ['default', 'Default']: if tools.db_existence('privkey'): privkey=tools.db_get('privkey') else: return('no private key is known, so the tx cannot be signed. Here is the tx: \n'+str(tools.package(tx_orig).encode('base64').replace('\n', ''))) pubkey=tools.privtopub(privkey) address=tools.make_address([pubkey], 1) if 'count' not in tx: try: tx['count'] = tools.count(address, {}) except: tx['count'] = 1 if 'pubkeys' not in tx: tx['pubkeys']=[pubkey] if 'signatures' not in tx: tx['signatures'] = [tools.sign(tools.det_hash(tx), privkey)] return(blockchain.add_tx(tx, DB))
def easy_add_transaction(tx_orig, DB, privkey='default'): tx = copy.deepcopy(tx_orig) if privkey in ['default', 'Default']: if tools.db_existence('privkey'): privkey = tools.db_get('privkey') else: return ('no private key is known, so the tx cannot be signed. Here is the tx: \n' + str( tools.package(tx_orig).encode('base64').replace('\n', ''))) pubkey = tools.privtopub(privkey) address = tools.make_address([pubkey], 1) if 'count' not in tx: try: tx['count'] = tools.count(address, {}) except: tx['count'] = 1 if 'pubkeys' not in tx: tx['pubkeys'] = [pubkey] if 'signatures' not in tx: tx['signatures'] = [tools.sign(tools.det_hash(tx), privkey)] return (blockchain.add_tx(tx, DB))
def suggestions(DB): [blockchain.add_tx(tx, DB) for tx in DB['suggested_txs']] DB['suggested_txs'] = [] [blockchain.add_block(block, DB) for block in DB['suggested_blocks']] DB['suggested_blocks'] = []