Register a stake address generated by HW wallet

Hi there. I’ve been trying to register a stake address generated by hardware wallet.
My script I’ve ran to register is as follow.

# producer environment
cardano-cli stake-address registration-certificate \ 
    --stake-verification-key-file ${STAKE_VKEY} \
    --out-file ${REG_CERT}

cardano-cli transaction build-raw \
    ${TX_IN} \
    ${TX_OUT} \
    --invalid-hereafter $(( ${SLOT} + 10000)) \
    --fee ${FEE} \
    --alonzo-era \
    —certificate-file ${REG_CERT}
    --out-file ${TX_RAW} \
    --cddl-format 

# local environment
cardano-hw-cli transaction transform \                                                                                                                                                                               
        --tx-file ${TX_RAW} \                                                                              
        --out-file ${TX_TRANSFORMED}                                                 
                                                                                                                        
cardano-hw-cli transaction witness \                                                        
        --tx-file ${TX_TRANSFORMED} \                                                               
        --hw-signing-file ${PAYMENT_HWSFILE} \              
        --hw-signing-file ${STAKE_HWSFILE} \                        
        —testnet-magic 2 \                                                                                              
        --out-file ${PAYMENT_WITNESS} \                          
        --out-file ${STAKE_WITNESS} \                                    
        --derivation-type LEDGER                                          

I think the above script has no problem, but the last command puts following warning and doesn’t generate a witness file of the stake key.

Warning! A superfluous HW signing file specified (2 of 2), the witness was not created.
Warning! A superfluous output file specified (2 of 2), the file was not written to.

${STAKE_HWSFILE} and ${STAKE_VKEY} was created by following command.

cardano-hw-cli address key-gen \
    --path 1852H/1815H/0H/2/${INDEX} \
    --verification-key-file ${STAKE_VKEY} \
    --hw-signing-file ${STAKE_HWSFILE}

I think the witness file of the stake key is needed to sign to the transaction.
Does anyone let me know where the problem is?

I have never tried to create two witnesses with one call. Are you sure that that is possible?

Have you tried creating the witnesses in two separate calls?

Thank you for replying me.
I’ve already tried that.

The call for creating the payment witness fails as follows.

cardano-hw-cli transaction witness \                                                        
        --tx-file ${TX_TRANSFORMED} \                                                               
        --hw-signing-file ${PAYMENT_HWSFILE} \              
        —testnet-magic 2 \                                                                                              
        --out-file ${PAYMENT_WITNESS} \                          
        --derivation-type LEDGER              

> Error: Missing signing file for certificate

The call for creating the stake witness puts warning messages and doesn’t create the witness file.

cardano-hw-cli transaction witness \                                                        
        --tx-file ${TX_TRANSFORMED} \                                                               
        --hw-signing-file ${STAKE_HWSFILE} \                        
        —testnet-magic 2 \                                                                                              
        --out-file ${STAKE_WITNESS} \                                    
        --derivation-type LEDGER   

> Warning! A superfluous HW signing file specified (1 of 1), the witness was not created.
> Warning! A superfluous output file specified (1 of 1), the file was not written to.

What is ${INDEX}? The stake key should be 1852H/1815H/0H/2/0, not another index.
That could explain the superfluous HW signing file (and subsequently a missing signature from the real stake key).

Regarding Missing signing file for certificate: What is the content of the ${PAYMENT_HWSFILE} variable? Is it really the correct HW signing file?

${INDEX} I’ve tried is 0.
The variable of `${PAYMENT_HWSFILE} is

{
    "type": "PaymentHWSigningFileShelley_ed25519",
    "description": "Payment Hardware Signing File",
    "path": "1852H/1815H/0H/0/0",
    "cborXPubKeyHex": "..."
}

The variable of `${STAKE_HWSFILE} is

{
    "type": "StakeHWSigningFileShelley_ed25519",
    "description": "Stake Hardware Signing File",
    "path": "1852H/1815H/0H/2/0",
    "cborXPubKeyHex": "..."
}

These files are not changed since created by cardano-hw-cli.

Sorry! I have no idea anymore. You seem to do everything as in https://github.com/vacuumlabs/cardano-hw-cli/blob/develop/docs/delegation-example.md. It should work.

Thank you for taking your time.
I’ll investigate that a little more.

You can take a look at the SPO Scripts (GitHub - gitmachtl/scripts: StakePool Operator Scripts. Learn how to create and manage your StakePool with these simple scripts. Hardware-Ledger/Trezor Support, Token/Asset Sending, Offline-Mode and more...), they fully include hardware support.

Registering a Stake-VKEY from a HW-Wallet is not different than a normal VKEY.

You can take a look at script 03a to see the key generation for hw wallets. The script 03b is registering it on the chain.

Thank you for sharing the scripts.
I can’t run that immediately because of my environment setting.
As far as I checked, There is not much difference with my scripts.
I’ll check my scripts in detail based on the scripts you shared.

Were the examples copied and pasted or typed by hand? It appears to be missing an escape at the end of one line, possibly dropping your final flags.

cardano-cli transaction build-raw \
    ${TX_IN} \
    ${TX_OUT} \
    --invalid-hereafter $(( ${SLOT} + 10000)) \
    --fee ${FEE} \
    --alonzo-era \
    —certificate-file ${REG_CERT}  <----------MISSING ESCAPE--------
    --out-file ${TX_RAW} \    
    --cddl-format

Guessing that’s not the real issue though since transaction transport is run against ${TX_RAW} and you don’t get an error until transaction witness.

Thank you for checking my codes.

I’ve confirmed it again, but there was no missing escape char.

I don’t know why this error occurs yet, but I’ve avoided this problem by using the scripts my acquaintance created.

@kmazz

I went through this in more depth and opened tickets w/ VacuumLabs to fix the documentation. The “gist” is to sign the transaction with both hwsfile of stake and pyament. However, cardano-hw-cli will not produce two separate signature (--out-file) as the vacuumlabs documentation suggests when signing, it only produces one.

The step to assemble the transactions needs to not include a second, missing, signature which was not produced by cardano-hw-cli, and then it will assemble a final signed transaction, and this transaction can be submitted successfully.

This issue #163 was opened w/ vacuumlabs/cardano-hw-cli repository to address their documentation and what appears to be an incorrect, or at least quite strange, behavior of always warning something is superfluous when clearly it still necessary to produce a signature.

I hope others who ran into this issue find this helpful until the documentation is fixed and/or warnings removed or at least clarified.

@Trevor_Benson
Thank you for letting me know the details.
I understand why my scripts shown above doesn’t work. I’ve also tried to run a script which is modified to use single witness file, and then succesfully submited.
I’ll follow up the issue you’ve posted.