Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 2ba35cb

Browse files
committed
Re-sign contract when moderators are updated
1 parent 493b028 commit 2ba35cb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

market/network.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,7 @@ def update_moderators_on_listings(self, moderator_list):
11221122
l.ParseFromString(self.db.listings.get_proto())
11231123
except Exception:
11241124
return
1125+
keychain = KeyChain(self.db)
11251126
for listing in l.listing:
11261127
contract_hash = listing.contract_hash
11271128
c = Contract(self.db, hash_value=contract_hash, testnet=self.protocol.multiplexer.testnet)
@@ -1159,6 +1160,14 @@ def update_moderators_on_listings(self, moderator_list):
11591160
if "moderators" in c.contract["vendor_offer"]["listing"] and \
11601161
len(c.contract["vendor_offer"]["listing"]["moderators"]) == 0:
11611162
del c.contract["vendor_offer"]["listing"]["moderators"]
1163+
1164+
listing = json.dumps(c.contract["vendor_offer"]["listing"], indent=4)
1165+
c.contract["vendor_offer"]["signatures"] = {}
1166+
c.contract["vendor_offer"]["signatures"]["guid"] = \
1167+
base64.b64encode(keychain.signing_key.sign(listing)[:64])
1168+
c.contract["vendor_offer"]["signatures"]["bitcoin"] = \
1169+
bitcointools.encode_sig(*bitcointools.ecdsa_raw_sign(
1170+
listing, bitcointools.bip32_extract_key(keychain.bitcoin_master_privkey)))
11621171
c.previous_title = None
11631172
c.save()
11641173

0 commit comments

Comments
 (0)