@@ -75,7 +75,11 @@ static bool add_key(in3_t* c, bytes32_t pk) {
7575 in3_sign_account_ctx_t ctx = {0 };
7676
7777 for (in3_plugin_t * p = c -> plugins ; p ; p = p -> next ) {
78- if (p -> acts & (PLGN_ACT_SIGN_ACCOUNT | PLGN_ACT_SIGN ) && p -> action_fn (p -> data , PLGN_ACT_SIGN_ACCOUNT , & ctx ) == IN3_OK && memcmp (ctx .account , address , 20 ) == 0 ) return false;
78+ if (p -> acts & (PLGN_ACT_SIGN_ACCOUNT | PLGN_ACT_SIGN ) && p -> action_fn (p -> data , PLGN_ACT_SIGN_ACCOUNT , & ctx ) == IN3_OK && ctx .accounts_len ) {
79+ bool is_same_address = memcmp (ctx .accounts , address , 20 ) == 0 ;
80+ _free (ctx .accounts );
81+ if (is_same_address ) return false;
82+ }
7983 }
8084
8185 eth_set_pk_signer (c , pk );
@@ -104,7 +108,9 @@ static in3_ret_t eth_sign_pk(void* data, in3_plugin_act_t action, void* action_c
104108 // generate the address from the key
105109 in3_sign_account_ctx_t * ctx = action_ctx ;
106110 ctx -> signer_type = SIGNER_ECDSA ;
107- memcpy (ctx -> account , k -> account , 20 );
111+ ctx -> accounts = _malloc (20 );
112+ ctx -> accounts_len = 1 ;
113+ memcpy (ctx -> accounts , k -> account , 20 );
108114 return IN3_OK ;
109115 }
110116
@@ -182,11 +188,17 @@ static in3_ret_t pk_rpc(void* data, in3_plugin_act_t action, void* action_ctx) {
182188 if (strcmp (method , "eth_accounts" ) == 0 ) {
183189 sb_t * sb = in3_rpc_handle_start (ctx );
184190 bool first = true;
185- in3_sign_account_ctx_t sc = {0 };
191+ in3_sign_account_ctx_t sc = {. ctx = ctx -> ctx , . accounts = NULL , . accounts_len = 0 , . signer_type = 0 };
186192 for (in3_plugin_t * p = ctx -> ctx -> client -> plugins ; p ; p = p -> next ) {
187193 if (p -> acts & PLGN_ACT_SIGN_ACCOUNT && p -> action_fn (p -> data , PLGN_ACT_SIGN_ACCOUNT , & sc ) == IN3_OK ) {
188- sb_add_rawbytes (sb , first ? "[\"0x" : "\",\"0x" , bytes (sc .account , 20 ), 20 );
189- first = false;
194+ for (int i = 0 ; i < sc .accounts_len ; i ++ ) {
195+ sb_add_rawbytes (sb , first ? "[\"0x" : "\",\"0x" , bytes (sc .accounts + i * 20 , 20 ), 20 );
196+ first = false;
197+ }
198+ if (sc .accounts ) {
199+ _free (sc .accounts );
200+ sc .accounts_len = 0 ;
201+ }
190202 }
191203 }
192204 sb_add_chars (sb , first ? "[]" : "\"]" );
0 commit comments