Example #1
0
    def btc_register_script_config(
        self, coin: btc.BTCCoin, script_config: btc.BTCScriptConfig, keypath: List[int], name: str
    ) -> None:
        """
        Raises Bitbox02Exception with ERR_USER_ABORT on user abort.
        """
        assert len(name) <= 30

        # pylint: disable=no-member
        request = btc.BTCRequest()
        request.register_script_config.CopyFrom(
            btc.BTCRegisterScriptConfigRequest(
                registration=btc.BTCScriptConfigRegistration(
                    coin=coin, script_config=script_config, keypath=keypath
                ),
                name=name,
            )
        )
        try:
            self._btc_msg_query(request, expected_response="success")
        except Bitbox02Exception as err:
            if err.code == ERR_DUPLICATE_ENTRY:
                raise DuplicateEntryException(
                    "A multisig account configuration with this name already exists.\n"
                    "Choose another name."
                )
            raise
    def btc_register_script_config(
        self,
        coin: btc.BTCCoin,
        script_config: btc.BTCScriptConfig,
        keypath: Sequence[int],
        name: str,
        xpub_type: btc.BTCRegisterScriptConfigRequest.XPubType = btc.BTCRegisterScriptConfigRequest.XPubType.AUTO_ELECTRUM,
    ) -> None:
        """
        Raises Bitbox02Exception with ERR_USER_ABORT on user abort.
        If name is the empty string, it will be prompted on the device.
        """
        # pylint: disable=no-member,too-many-arguments

        if name == "":
            # prompt on device only available since v9.3.0
            self._require_atleast(semver.VersionInfo(9, 3, 0))

        assert len(name) <= 30

        # pylint: disable=no-member
        request = btc.BTCRequest()
        request.register_script_config.CopyFrom(
            btc.BTCRegisterScriptConfigRequest(
                registration=btc.BTCScriptConfigRegistration(
                    coin=coin, script_config=script_config, keypath=keypath
                ),
                name=name,
                xpub_type=xpub_type,
            )
        )
        try:
            self._btc_msg_query(request, expected_response="success")
        except Bitbox02Exception as err:
            if err.code == ERR_DUPLICATE_ENTRY:
                raise DuplicateEntryException(
                    "A multisig account configuration with this name already exists.\n"
                    "Choose another name."
                )
            raise