Skip to content

Commit

Permalink
When/if server provides "txid" for transactions, use that instead of …
Browse files Browse the repository at this point in the history
…hashing them
  • Loading branch information
luke-jr committed Jan 29, 2016
1 parent e154959 commit 39b9b3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 5 additions & 2 deletions bitcoin/txn.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
_nullprev = b'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'

class Txn:
def __init__(self, data=None):
def __init__(self, data=None, txid=None):
if data:
self.data = data
self.idhash()
if txid:
self.txid = txid
else:
self.idhash()

@classmethod
def new(cls):
Expand Down
13 changes: 9 additions & 4 deletions merklemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,15 @@ def _ProcessGBT(self, MP, TS = None):
txninfo.insert(0, {
})

txnlist = [a for a in map(Txn, txnlist[1:])]
txnlist.insert(0, cbtxn)
txnlist = list(txnlist)
newMerkleTree = MerkleTree(txnlist)
txnobjs = [cbtxn]
for i in range(1, len(txnlist)):
iinfo = txninfo[i]
ka = {}
if 'txid' in iinfo:
ka['txid'] = iinfo['txid']
txnobjs.append(Txn(data=txnlist[i], **ka))
txnobjs = list(txnobjs)
newMerkleTree = MerkleTree(txnobjs)
newMerkleTree.POTInfo = MP.get('POTInfo')
newMerkleTree.MP = MP
newMerkleTree.oMP = oMP
Expand Down

0 comments on commit 39b9b3a

Please sign in to comment.