@@ -1670,23 +1670,33 @@ def disapprovewitness(witness, account):
16701670
16711671
16721672@cli .command ()
1673- @click .option ('--file' , help = 'Load transaction from file. If "-", read from stdin (defaults to "-")' )
1674- def sign (file ):
1673+ @click .option ('--file' , '-i' , help = 'Load transaction from file. If "-", read from stdin (defaults to "-")' )
1674+ @click .option ('--outfile' , '-o' , help = 'Load transaction from file. If "-", read from stdin (defaults to "-")' )
1675+ def sign (file , outfile ):
16751676 """Sign a provided transaction with available and required keys"""
16761677 stm = shared_steem_instance ()
16771678 if stm .rpc is not None :
16781679 stm .rpc .rpcconnect ()
1680+ if not unlock_wallet (stm ):
1681+ return
16791682 if file and file != "-" :
16801683 if not os .path .isfile (file ):
16811684 raise Exception ("File %s does not exist!" % file )
16821685 with open (file ) as fp :
16831686 tx = fp .read ()
1687+ if tx .find ('\0 ' ) > 0 :
1688+ with open (file , encoding = 'utf-16' ) as fp :
1689+ tx = fp .read ()
16841690 else :
16851691 tx = click .get_text_stream ('stdin' )
16861692 tx = ast .literal_eval (tx )
16871693 tx = stm .sign (tx )
16881694 tx = json .dumps (tx , indent = 4 )
1689- print (tx )
1695+ if outfile and outfile != "-" :
1696+ with open (outfile , 'w' ) as fp :
1697+ fp .write (tx )
1698+ else :
1699+ print (tx )
16901700
16911701
16921702@cli .command ()
@@ -1701,6 +1711,9 @@ def broadcast(file):
17011711 raise Exception ("File %s does not exist!" % file )
17021712 with open (file ) as fp :
17031713 tx = fp .read ()
1714+ if tx .find ('\0 ' ) > 0 :
1715+ with open (file , encoding = 'utf-16' ) as fp :
1716+ tx = fp .read ()
17041717 else :
17051718 tx = click .get_text_stream ('stdin' )
17061719 tx = ast .literal_eval (tx )
0 commit comments