@@ -61,7 +61,7 @@ def __init__(self, mixin_config):
61
61
def decode_ed25519 (cls , priv ):
62
62
if not len (priv ) % 4 == 0 :
63
63
priv = priv + '===='
64
- priv = base64 .b64decode (priv , altchars = b'-_' )
64
+ priv = base64 .urlsafe_b64decode (priv )
65
65
return ed25519 .Ed25519PrivateKey .from_private_bytes (priv [:32 ])
66
66
67
67
def generate_sig (self , method , uri , body ):
@@ -517,19 +517,38 @@ async def get_address(self, address_id):
517
517
"""
518
518
return await self .__genNetworkGetRequest ('/addresses/' + address_id )
519
519
520
- async def transfer_to (self , to_user_id , to_asset_id , to_asset_amount , memo , trace_uuid = "" ):
521
- """
522
- Transfer of assets between Mixin Network users.
523
- """
524
- # generate encrypted pin
520
+ async def transfer_to (self , user_id , asset_id , amount , memo , trace_id = None ):
525
521
encrypted_pin = self .gen_encrypted_pin ()
522
+ if not trace_id :
523
+ trace_id = str (uuid .uuid1 ())
524
+ if isinstance (user_id , str ):
525
+ body = {
526
+ 'asset_id' : asset_id ,
527
+ 'counter_user_id' : user_id ,
528
+ 'amount' : str (amount ),
529
+ 'pin' : encrypted_pin ,
530
+ 'trace_id' : trace_id ,
531
+ 'memo' : memo
532
+ }
533
+ return await self .__genNetworkPostRequest ('/transfers' , body )
526
534
527
- body = { ' asset_id' : to_asset_id , 'counter_user_id' : to_user_id , 'amount' : str ( to_asset_amount ),
528
- 'pin' : encrypted_pin , 'trace_id' : trace_uuid , 'memo' : memo }
529
- if trace_uuid == "" :
530
- body [ ' trace_id' ] = str (uuid .uuid1 ())
535
+ async def transfer_to_users ( self , user_ids , threshold , asset_id , amount , memo , trace_id = None ):
536
+ encrypted_pin = self . gen_encrypted_pin ()
537
+ if not trace_id :
538
+ trace_id = str (uuid .uuid1 ())
531
539
532
- return await self .__genNetworkPostRequest ('/transfers' , body )
540
+ body = {
541
+ "asset_id" : asset_id ,
542
+ "amount" : str (amount ),
543
+ "trace_id" : trace_id ,
544
+ "memo" : memo ,
545
+ "opponent_multisig" : {
546
+ "receivers" : user_ids ,
547
+ "threshold" : threshold
548
+ },
549
+ "pin" : encrypted_pin
550
+ }
551
+ return await self .__genNetworkPostRequest ('/transactions' , body )
533
552
534
553
async def get_transfer (self , trace_id ):
535
554
"""
0 commit comments