@@ -171,6 +171,7 @@ pub enum ProgramCliCommand {
171
171
} ,
172
172
ExtendProgramChecked {
173
173
program_pubkey : Pubkey ,
174
+ authority_signer_index : SignerIndex ,
174
175
additional_bytes : u32 ,
175
176
} ,
176
177
MigrateProgram {
@@ -1009,17 +1010,22 @@ pub fn parse_program_subcommand(
1009
1010
let program_pubkey = pubkey_of ( matches, "program_id" ) . unwrap ( ) ;
1010
1011
let additional_bytes = value_of ( matches, "additional_bytes" ) . unwrap ( ) ;
1011
1012
1013
+ let ( authority_signer, authority_pubkey) =
1014
+ signer_of ( matches, "authority" , wallet_manager) ?;
1015
+
1012
1016
let signer_info = default_signer. generate_unique_signers (
1013
- vec ! [ Some (
1014
- default_signer. signer_from_path( matches, wallet_manager) ?,
1015
- ) ] ,
1017
+ vec ! [
1018
+ Some ( default_signer. signer_from_path( matches, wallet_manager) ?) ,
1019
+ authority_signer,
1020
+ ] ,
1016
1021
matches,
1017
1022
wallet_manager,
1018
1023
) ?;
1019
1024
1020
1025
CliCommandInfo {
1021
1026
command : CliCommand :: Program ( ProgramCliCommand :: ExtendProgramChecked {
1022
1027
program_pubkey,
1028
+ authority_signer_index : signer_info. index_of ( authority_pubkey) . unwrap ( ) ,
1023
1029
additional_bytes,
1024
1030
} ) ,
1025
1031
signers : signer_info. signers ,
@@ -1233,8 +1239,15 @@ pub fn process_program_subcommand(
1233
1239
) ,
1234
1240
ProgramCliCommand :: ExtendProgramChecked {
1235
1241
program_pubkey,
1242
+ authority_signer_index,
1236
1243
additional_bytes,
1237
- } => process_extend_program ( & rpc_client, config, * program_pubkey, * additional_bytes) ,
1244
+ } => process_extend_program (
1245
+ & rpc_client,
1246
+ config,
1247
+ * program_pubkey,
1248
+ * authority_signer_index,
1249
+ * additional_bytes,
1250
+ ) ,
1238
1251
ProgramCliCommand :: MigrateProgram {
1239
1252
program_pubkey,
1240
1253
authority_signer_index,
@@ -2366,9 +2379,11 @@ fn process_extend_program(
2366
2379
rpc_client : & RpcClient ,
2367
2380
config : & CliConfig ,
2368
2381
program_pubkey : Pubkey ,
2382
+ authority_signer_index : SignerIndex ,
2369
2383
additional_bytes : u32 ,
2370
2384
) -> ProcessResult {
2371
2385
let payer_pubkey = config. signers [ 0 ] . pubkey ( ) ;
2386
+ let authority_signer = config. signers [ authority_signer_index] ;
2372
2387
2373
2388
if additional_bytes == 0 {
2374
2389
return Err ( "Additional bytes must be greater than zero" . into ( ) ) ;
@@ -2414,6 +2429,15 @@ fn process_extend_program(
2414
2429
let upgrade_authority_address = upgrade_authority_address
2415
2430
. ok_or_else ( || format ! ( "Program {program_pubkey} is not upgradeable" ) ) ?;
2416
2431
2432
+ if authority_signer. pubkey ( ) != upgrade_authority_address {
2433
+ return Err ( format ! (
2434
+ "Upgrade authority {} does not match {}" ,
2435
+ upgrade_authority_address,
2436
+ authority_signer. pubkey( ) ,
2437
+ )
2438
+ . into ( ) ) ;
2439
+ }
2440
+
2417
2441
let blockhash = rpc_client. get_latest_blockhash ( ) ?;
2418
2442
let feature_set = fetch_feature_set ( rpc_client) ?;
2419
2443
@@ -2434,7 +2458,7 @@ fn process_extend_program(
2434
2458
} ;
2435
2459
let mut tx = Transaction :: new_unsigned ( Message :: new ( & [ instruction] , Some ( & payer_pubkey) ) ) ;
2436
2460
2437
- tx. try_sign ( & [ config. signers [ 0 ] ] , blockhash) ?;
2461
+ tx. try_sign ( & [ config. signers [ 0 ] , authority_signer ] , blockhash) ?;
2438
2462
let result = rpc_client. send_and_confirm_transaction_with_spinner_and_config (
2439
2463
& tx,
2440
2464
config. commitment ,
@@ -4440,6 +4464,7 @@ mod tests {
4440
4464
CliCommandInfo {
4441
4465
command: CliCommand :: Program ( ProgramCliCommand :: ExtendProgramChecked {
4442
4466
program_pubkey,
4467
+ authority_signer_index: 0 ,
4443
4468
additional_bytes
4444
4469
} ) ,
4445
4470
signers: vec![ Box :: new( read_keypair_file( & keypair_file) . unwrap( ) ) ] ,
0 commit comments