I am trying to understand the required number of witnesses in a transaction.
Case 1:
Two TxIns from the same address. Shall I add one witness signed by the private key of the address or two?
Case 2:
Two TxIns from different addresses. Shall I add two witnesses signed by two private keys?
I am sorry for the naive question but I could not find a clear explanation…
One witness per required signing key. If your Q is related to cardano-cli transaction build-raw, there is now also cardano-cli transaction build, which is much simpler to use and does not require you to calculate the fees upfront.
@tomdx , thank you for the prompt reply.
I am building a transaction in my code and using cardano-cli for testing:)
So just to confirm: when you say “One witness per required signing key” you mean that if I have two input transactions from the same address, I need only one witness (signing key associated with the address), if I have two inputs from two different addresses, I need two witnesses(signed by keys of each address), is it correct?
Yes, the scope of the signing key is actually the BIP44 account, which in case of Cardano is also the scope of the staking key i.e. each account has its own private key. Multiple distinct addresses may belong to the same account. If they do, you only need to witness once for those.
Alright @tomdx I appreciate this reference but I give up on figuring out how to use it and/or finding documentation on that CLI syntax. I can see the acceptable options in the CLI itself but not which combination of them will produce a well-defined transaction.
Do you know of a reference that illustrates a transaction with cardano-cli transaction build as completely as in the legacy page here (Create a simple transaction) for build-raw?