Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account Update incorrectly sets the receiver signature required field #2449

Closed
SvetBorislavov opened this issue Aug 7, 2024 · 0 comments · Fixed by #2450
Closed

Account Update incorrectly sets the receiver signature required field #2449

SvetBorislavov opened this issue Aug 7, 2024 · 0 comments · Fixed by #2450
Assignees
Labels
bug Something isn't working
Milestone

Comments

@SvetBorislavov
Copy link
Contributor

Description

Account Update transaction sets the receiver signature required field to false if setReceiverSignatureRequired is not called.
This is problematic if we want to track the changes in an account.

Imagine we have an account with the receiver signature required set to true and we want to update the key of the account.
We create an Account Update transaction and only invoke setKey.
After executed the key is correctly updated, but the receiver signature required is now set to false

Steps to reproduce

  1. Paste this snippet
const {
  AccountCreateTransaction,
  AccountId,
  AccountInfoQuery,
  AccountUpdateTransaction,
  Client,
  Hbar,
  PrivateKey,
} = require('@hashgraph/sdk');

async function run() {
  const payerId = AccountId.fromString('');
  const payerPrivateKey = PrivateKey.fromStringED25519(''); //Testnet private key

  const client = Client.forTestnet();
  client.setOperator(payerId, payerPrivateKey);
  client.setDefaultMaxTransactionFee(new Hbar(100));

  let createTx = await new AccountCreateTransaction()
    .setKey(payerPrivateKey.publicKey)
    .setReceiverSignatureRequired(true)
    .freezeWith(client);

  const response = await createTx.execute(client);
  const receipt = await response.getReceipt(client);

  const newAccountId = receipt.accountId;
  console.log('The new account ID is:', newAccountId.toString());

  let accountInfo = await new AccountInfoQuery()
    .setAccountId(newAccountId)
    .execute(client);

  console.log(
    'After create, the account receiver sig required is:',
    accountInfo.isReceiverSignatureRequired
  ); // This should be true

  await (
    await (
      await new AccountUpdateTransaction()
        .setAccountId(newAccountId)
        .freezeWith(client)
    ).execute(client)
  ).getReceipt(client);

  accountInfo = await new AccountInfoQuery()
    .setAccountId(newAccountId)
    .execute(client);

  console.log(
    'After update, the account receiver sig required is:',
    accountInfo.isReceiverSignatureRequired
  ); // This should be true

  if (accountInfo.isReceiverSignatureRequired !== true) {
    console.error(
      'SDK BUG: Account receiver sig required is updated even though it was not set in the update transaction'
    );
  }

  client.close();
}
run();
  1. Fill the private key & payer
  2. Run the snippet

Additional context

No response

Hedera network

No response

Version

2.49.2

Operating system

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants