blockchain-certificates/cert-issuer

UnableToSignTxError('Unable to sign transaction')

KhoiUna opened this issue · 8 comments

When run cert-issuer -c /etc/cert-issuer/conf.ini , I got this error:

WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
Traceback (most recent call last):
  File "/usr/bin/cert-issuer", line 8, in <module>
    sys.exit(cert_issuer_main())
  File "/usr/lib/python3.8/site-packages/cert_issuer/__main__.py", line 17, in cert_issuer_main
    issue_certificates.main(parsed_config)
  File "/usr/lib/python3.8/site-packages/cert_issuer/issue_certificates.py", line 36, in main
    return issue(app_config, certificate_batch_handler, transaction_handler)
  File "/usr/lib/python3.8/site-packages/cert_issuer/issue_certificates.py", line 22, in issue
    tx_id = issuer.issue(app_config.chain)
  File "/usr/lib/python3.8/site-packages/cert_issuer/issuer.py", line 27, in issue
    txid = self.transaction_handler.issue_transaction(blockchain_bytes)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/transaction_handlers.py", line 56, in issue_transaction
    signed_tx = self.sign_transaction(prepared_tx)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/transaction_handlers.py", line 92, in sign_transaction
    signed_tx = signer.sign_transaction(prepared_tx)
  File "/usr/lib/python3.8/site-packages/cert_issuer/models.py", line 233, in sign_transaction
    return self.signer.sign_transaction(self.wif, transaction_to_sign)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/signer.py", line 35, in sign_transaction
    raise UnableToSignTxError('Unable to sign transaction')
cert_issuer.errors.UnableToSignTxError: Unable to sign transaction

How to resolve this?

I can't really help there, I don't have enough details. It could be something with your issuing address? It could be your private key file too. I have found that it prefers the WIF format of the key.

I use bitcoin-cli getnewaddress to get the issuing address. How do I get that in the WIF format?

hm it looks like it might already be what you did from the readme:

https://chainquery.com/bitcoin-cli/dumpprivkey

Can you make sure that this private key looks valid? This tool might help you: https://learnmeabitcoin.com/technical/wif

I have made sure the key is valid. Here're more details of the error:

WARNING - Your app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
INFO - This run will try to issue on the bitcoin_regtest chain
INFO - Set cost constants to recommended_tx_fee=0.000600,min_per_output=0.000028,satoshi_per_byte=250
INFO - Processing 1 certificates
INFO - Processing 1 certificates under work path=/etc/cert-issuer/work
INFO - Total cost will be 133500 satoshis
INFO - Starting finalizable signer
WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
INFO - Stopping finalizable signer
WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
INFO - here is the op_return_code data: f4906de7db4f9a826b5998472f51eaac762d429b29b6c2496f38870a477929d9
INFO - Unsigned hextx=0100000001723b97c3f21222d4c3c152ed195e222c32371a6992d18c4248990710ceb303570100000000ffffffff02a07acc1d0000000016001469a84665f30277fc4a75571d3413ac24d83c0aba0000000000000000226a20f4906de7db4f9a826b5998472f51eaac762d429b29b6c2496f38870a477929d900000000
INFO - Preparing tx for signing
INFO - Starting finalizable signer
WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
ERROR - Unable to sign transaction. hextx=01000000000101723b97c3f21222d4c3c152ed195e222c32371a6992d18c4248990710ceb303570100000000ffffffff02a07acc1d0000000016001469a84665f30277fc4a75571d3413ac24d83c0aba0000000000000000226a20f4906de7db4f9a826b5998472f51eaac762d429b29b6c2496f38870a477929d902473044022056ec60cf16bb916385d334cbaef6c139c3cefd3d2300c81997379dc79618b10502202521c3b02ee69ba44ba339f1185da1727461287933ae8550546399942364bcbc012102833db6109cb447aa10c8ca46ce43d3e663fd2b5333914756230c002db7e3e3fd00000000
INFO - Stopping finalizable signer
WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
Traceback (most recent call last):
  File "/usr/bin/cert-issuer", line 8, in <module>
    sys.exit(cert_issuer_main())
  File "/usr/lib/python3.8/site-packages/cert_issuer/__main__.py", line 17, in cert_issuer_main
    issue_certificates.main(parsed_config)
  File "/usr/lib/python3.8/site-packages/cert_issuer/issue_certificates.py", line 36, in main
    return issue(app_config, certificate_batch_handler, transaction_handler)
  File "/usr/lib/python3.8/site-packages/cert_issuer/issue_certificates.py", line 22, in issue
    tx_id = issuer.issue(app_config.chain)
  File "/usr/lib/python3.8/site-packages/cert_issuer/issuer.py", line 27, in issue
    txid = self.transaction_handler.issue_transaction(blockchain_bytes)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/transaction_handlers.py", line 56, in issue_transaction
    signed_tx = self.sign_transaction(prepared_tx)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/transaction_handlers.py", line 92, in sign_transaction
    signed_tx = signer.sign_transaction(prepared_tx)
  File "/usr/lib/python3.8/site-packages/cert_issuer/models.py", line 233, in sign_transaction
    return self.signer.sign_transaction(self.wif, transaction_to_sign)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/signer.py", line 35, in sign_transaction
    raise UnableToSignTxError('Unable to sign transaction')
cert_issuer.errors.UnableToSignTxError: Unable to sign transaction

Also I had to comment the rpcport=8332 in the bitcoin.conf file because when I ran bitcoind -regtest -daemon it said:

Error: Config setting for -rpcport only applied on regtest network when in [regtest] section.

So I commented bitcoind in /etc/cert-issuer/conf.ini .

issuing_address=bcrt1qdx5yve0nqfmlcjn42uwngyavynvrcz46wg83dh

verification_method=did:ion:EiA_Z6LQILbB2zj_eVrqfQ2xDm4HNqeJUw5Kj2Z7bFOOeQ

chain=bitcoin_regtest

usb_name=/etc/cert-issuer/
key_file=pk_issuer.txt

unsigned_certificates_dir=/etc/cert-issuer/data/unsigned_certificates
blockchain_certificates_dir=/etc/cert-issuer/data/blockchain_certificates
work_dir=/etc/cert-issuer/work

no_safe_mode

#bitcoind

Then run cert-issuer -c /etc/cert-issuer/conf.ini and got a different error:

WARNING - Your app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
INFO - This run will try to issue on the bitcoin_regtest chain
INFO - Set cost constants to recommended_tx_fee=0.000600,min_per_output=0.000028,satoshi_per_byte=250
INFO - Processing 1 certificates
INFO - Processing 1 certificates under work path=/etc/cert-issuer/work
Traceback (most recent call last):
  File "/usr/bin/cert-issuer", line 8, in <module>
    sys.exit(cert_issuer_main())
  File "/usr/lib/python3.8/site-packages/cert_issuer/__main__.py", line 17, in cert_issuer_main
    issue_certificates.main(parsed_config)
  File "/usr/lib/python3.8/site-packages/cert_issuer/issue_certificates.py", line 36, in main
    return issue(app_config, certificate_batch_handler, transaction_handler)
  File "/usr/lib/python3.8/site-packages/cert_issuer/issue_certificates.py", line 16, in issue
    transaction_handler.ensure_balance()
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/transaction_handlers.py", line 42, in ensure_balance
    balance = self.connector.get_balance(self.issuing_address)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/connectors.py", line 181, in get_balance
    spendables = self.get_unspent_outputs(address)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/connectors.py", line 170, in get_unspent_outputs
    spendables = self.spendables_for_address(bitcoin_address=address)
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/connectors.py", line 153, in spendables_for_address
    get_providers_for_chain(self.bitcoin_chain, self.bitcoind)):
  File "/usr/lib/python3.8/site-packages/cert_issuer/blockchain_handlers/bitcoin/connectors.py", line 273, in get_providers_for_chain
    return connectors[chain]
KeyError: <Chain.bitcoin_regtest: 2>

I don't know about this error. Can you try with bitcoin testnet instead? Make sure your address is valid for that network.

Hi did you find a solution to this?

Hi did you find a solution to this?

No, I haven't