@@ -1447,6 +1447,67 @@ def updatememokey(account, key):
14471447 print (tx )
14481448
14491449
1450+ @cli .command ()
1451+ @click .argument ('authorperm' , nargs = 1 )
1452+ @click .argument ('beneficiaries' , nargs = - 1 )
1453+ def beneficiaries (authorperm , beneficiaries ):
1454+ """Set beneficaries"""
1455+ stm = shared_steem_instance ()
1456+ if stm .rpc is not None :
1457+ stm .rpc .rpcconnect ()
1458+ c = Comment (authorperm , steem_instance = stm )
1459+ account = c ["author" ]
1460+
1461+ if not account :
1462+ account = stm .config ["default_account" ]
1463+ if not unlock_wallet (stm ):
1464+ return
1465+ beneficiaries_list = []
1466+ beneficiaries_accounts = []
1467+ beneficiaries_sum = 0
1468+
1469+ options = {"author" : c ["author" ],
1470+ "permlink" : c ["permlink" ],
1471+ "max_accepted_payout" : c ["max_accepted_payout" ],
1472+ "percent_steem_dollars" : c ["percent_steem_dollars" ],
1473+ "allow_votes" : c ["allow_votes" ],
1474+ "allow_curation_rewards" : c ["allow_curation_rewards" ]}
1475+
1476+ for w in beneficiaries [0 ].split ("," ):
1477+ account_name = w .strip ().split (":" )[0 ]
1478+ if account_name [0 ] == "@" :
1479+ account_name = account_name [1 :]
1480+ a = Account (account_name , steem_instance = stm )
1481+ if a ["name" ] in beneficiaries_accounts :
1482+ continue
1483+ if w .find (":" ) == - 1 :
1484+ percentage = - 1
1485+ else :
1486+ percentage = w .strip ().split (":" )[1 ]
1487+ if "%" in percentage :
1488+ percentage = percentage .strip ().split ("%" )[0 ].strip ()
1489+ percentage = float (percentage )
1490+ beneficiaries_sum += percentage
1491+ beneficiaries_list .append ({"account" : a ["name" ], "weight" : int (percentage * 100 )})
1492+ beneficiaries_accounts .append (a ["name" ])
1493+
1494+ missing = 0
1495+ for bene in beneficiaries_list :
1496+ if bene ["weight" ] < 0 :
1497+ missing += 1
1498+ index = 0
1499+ for bene in beneficiaries_list :
1500+ if bene ["weight" ] < 0 :
1501+ beneficiaries_list [index ]["weight" ] = int ((int (100 * 100 ) - int (beneficiaries_sum * 100 )) / missing )
1502+ index += 1
1503+ beneficiaries_list_sorted = sorted (beneficiaries_list , key = lambda beneficiaries_list : beneficiaries_list ["account" ])
1504+ tx = stm .comment_options (options , authorperm , beneficiaries_list_sorted , account = account )
1505+ if stm .unsigned and stm .nobroadcast and stm .steemconnect is not None :
1506+ tx = stm .steemconnect .url_from_tx (tx )
1507+ tx = json .dumps (tx , indent = 4 )
1508+ print (tx )
1509+
1510+
14501511@cli .command ()
14511512@click .argument ('witness' , nargs = 1 )
14521513@click .option ('--account' , '-a' , help = 'Your account' )
0 commit comments