Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tdev #32

Merged
merged 27 commits into from
Apr 17, 2018
Merged

Tdev #32

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enhance channel enable
  • Loading branch information
pigxo committed Apr 17, 2018
commit 8713ff6947077aa9225236efa22ee2908d438c50
8 changes: 8 additions & 0 deletions wallet/ChannelManagement/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ def toJson(self):
"Balance":self.get_balance()}
return jsn

def get_role_in_channel(self, url):
if url == self.src_addr:
return "Founder"
elif url == self.dest_addr:
return "Partner"
else:
return None



def create_channel(founder, partner, asset_type, depoist:int, cli=True):
Expand Down
11 changes: 11 additions & 0 deletions wallet/TransactionManagement/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,13 +1018,23 @@ def handle_message(self):
tx_data_sign_self = self.wallet.SignContent(tx_data)
tx_id = self.settlement.get("originalData").get("txId")
witness = self.settlement.get("originalData").get("witness")
role = ch.Channel.channel(self.channel_name).get_role_in_channel(self.wallet.url)
if role =="Founder":
sign_self = tx_data_sign_self
sign_other = tx_data_sign_other
elif role == "Partner":
sign_self = tx_data_sign_other
sign_other = tx_data_sign_self
else:
raise Exception("Not Find the url")
raw_data = witness.format(signSelf=tx_data_sign_self, signOther=tx_data_sign_other)
TrinityTransaction.sendrawtransaction(TrinityTransaction.genarate_raw_data(tx_data, raw_data))
register_monitor(tx_id,monitor_founding,self.channel_name, EnumChannelState.CLOSED.name)

def verify(self):
return True, None


def monitor_founding(height, channel_name, state):
channel = ch.Channel.channel(channel_name)
deposit = channel.get_deposit()
Expand All @@ -1036,6 +1046,7 @@ def monitor_founding(height, channel_name, state):
def monitor_height(height, txdata, signother, signself):
register_block(str(int(height)+1000),send_rsmcr_transaction,height,txdata,signother, signself)


def send_rsmcr_transaction(height,txdata,signother, signself):
height_script = blockheight_to_script(height)
rawdata = txdata.format(blockheight_script=height_script,signOther=signother,signSelf=signself)
Expand Down