@@ -689,7 +689,7 @@ export class NodeCommandTasks {
689
689
690
690
// don't try to download from the same node we are deleting, it won't work
691
691
const nodeAlias =
692
- ctx . config . nodeAlias === config . existingNodeAliases [ 0 ]
692
+ ctx . config . nodeAlias === config . existingNodeAliases [ 0 ] && config . existingNodeAliases . length > 1
693
693
? config . existingNodeAliases [ 1 ]
694
694
: config . existingNodeAliases [ 0 ] ;
695
695
@@ -1282,17 +1282,20 @@ export class NodeCommandTasks {
1282
1282
1283
1283
const nodeId = Templates . nodeIdFromNodeAlias ( config . nodeAlias ) - 1 ;
1284
1284
self . logger . info ( `nodeId: ${ nodeId } , config.newAccountNumber: ${ config . newAccountNumber } ` ) ;
1285
- await self . accountManager . refreshNodeClient ( config . namespace , config . nodeAlias ) ;
1286
- config . nodeClient = await this . accountManager . loadNodeClient ( config . namespace ) ;
1285
+
1286
+ if ( config . existingNodeAliases . length > 1 ) {
1287
+ await self . accountManager . refreshNodeClient ( config . namespace , config . nodeAlias ) ;
1288
+ config . nodeClient = await this . accountManager . loadNodeClient ( config . namespace ) ;
1289
+ }
1287
1290
1288
1291
try {
1289
- const nodeUpdateTx = new NodeUpdateTransaction ( ) . setNodeId ( nodeId ) ;
1292
+ let nodeUpdateTx = new NodeUpdateTransaction ( ) . setNodeId ( nodeId ) ;
1290
1293
1291
1294
if ( config . tlsPublicKey && config . tlsPrivateKey ) {
1292
1295
self . logger . info ( `config.tlsPublicKey: ${ config . tlsPublicKey } ` ) ;
1293
1296
const tlsCertDer = self . _loadPermCertificate ( config . tlsPublicKey ) ;
1294
1297
const tlsCertHash = crypto . createHash ( 'sha384' ) . update ( tlsCertDer ) . digest ( ) ;
1295
- nodeUpdateTx . setCertificateHash ( tlsCertHash ) ;
1298
+ nodeUpdateTx = nodeUpdateTx . setCertificateHash ( tlsCertHash ) ;
1296
1299
1297
1300
const publicKeyFile = Templates . renderTLSPemPublicKeyFile ( config . nodeAlias ) ;
1298
1301
const privateKeyFile = Templates . renderTLSPemPrivateKeyFile ( config . nodeAlias ) ;
@@ -1303,7 +1306,7 @@ export class NodeCommandTasks {
1303
1306
if ( config . gossipPublicKey && config . gossipPrivateKey ) {
1304
1307
self . logger . info ( `config.gossipPublicKey: ${ config . gossipPublicKey } ` ) ;
1305
1308
const signingCertDer = self . _loadPermCertificate ( config . gossipPublicKey ) ;
1306
- nodeUpdateTx . setGossipCaCertificate ( signingCertDer ) ;
1309
+ nodeUpdateTx = nodeUpdateTx . setGossipCaCertificate ( signingCertDer ) ;
1307
1310
1308
1311
const publicKeyFile = Templates . renderGossipPemPublicKeyFile ( config . nodeAlias ) ;
1309
1312
const privateKeyFile = Templates . renderGossipPemPrivateKeyFile ( config . nodeAlias ) ;
@@ -1312,19 +1315,19 @@ export class NodeCommandTasks {
1312
1315
}
1313
1316
1314
1317
if ( config . newAccountNumber ) {
1315
- nodeUpdateTx . setAccountId ( config . newAccountNumber ) ;
1318
+ nodeUpdateTx = nodeUpdateTx . setAccountId ( config . newAccountNumber ) ;
1316
1319
}
1317
1320
1318
1321
let parsedNewKey ;
1319
1322
if ( config . newAdminKey ) {
1320
1323
parsedNewKey = PrivateKey . fromStringED25519 ( config . newAdminKey . toString ( ) ) ;
1321
- nodeUpdateTx . setAdminKey ( parsedNewKey . publicKey ) ;
1324
+ nodeUpdateTx = nodeUpdateTx . setAdminKey ( parsedNewKey . publicKey ) ;
1322
1325
}
1323
- await nodeUpdateTx . freezeWith ( config . nodeClient ) ;
1326
+ nodeUpdateTx = nodeUpdateTx . freezeWith ( config . nodeClient ) ;
1324
1327
1325
1328
// config.adminKey contains the original key, needed to sign the transaction
1326
1329
if ( config . newAdminKey ) {
1327
- await nodeUpdateTx . sign ( parsedNewKey ) ;
1330
+ nodeUpdateTx = await nodeUpdateTx . sign ( parsedNewKey ) ;
1328
1331
}
1329
1332
const signedTx = await nodeUpdateTx . sign ( config . adminKey ) ;
1330
1333
const txResp = await signedTx . execute ( config . nodeClient ) ;
0 commit comments