Skip to content

Commit

Permalink
SFT-4094: updated multisig policy constant names for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mjg-foundation committed Aug 20, 2024
1 parent 61635e3 commit 03c3737
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
get_deriv_path_from_addr_type_and_acct,
get_addr_type_from_deriv,
derive_address)
from public_constants import TRUST_PSBT
from public_constants import MUSIG_SKIP
from wallets.constants import EXPORT_MODE_MICROSD, EXPORT_MODE_QR
from wallets.sw_wallets import supported_software_wallets
from utils import random_hex, spinner_task
Expand Down Expand Up @@ -306,7 +306,7 @@ async def export_by_qr(self):
self.set_result(False)
return
else:
common.settings.set('multisig_policy', TRUST_PSBT)
common.settings.set('multisig_policy', MUSIG_SKIP)
self.goto(self.complete)
else:
self.goto(self.complete)
Expand Down Expand Up @@ -375,7 +375,7 @@ async def export_by_microsd(self):
self.set_result(False)
return
else:
common.settings.set('multisig_policy', TRUST_PSBT)
common.settings.set('multisig_policy', MUSIG_SKIP)
self.goto(self.complete)
else:
self.goto(self.complete)
Expand Down Expand Up @@ -475,7 +475,7 @@ async def do_multisig_config_import(self):
self.set_result(False)
return
else:
common.settings.set('multisig_policy', TRUST_PSBT)
common.settings.set('multisig_policy', MUSIG_SKIP)
self.goto(self.complete)
else:
self.goto(self.complete)
Expand Down
8 changes: 4 additions & 4 deletions ports/stm32/boards/Passport/modules/multisig_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ubinascii import hexlify as b2a_hex
from utils import xfp2str, str2xfp, cleanup_deriv_path, keypath_to_str, str_to_keypath
from public_constants import (AF_P2SH, AF_P2WSH_P2SH, AF_P2WSH, AFC_SCRIPT,
TRUST_DEFAULT, TRUST_PSBT, TRUST_VERIFY, MAX_SIGNERS)
MUSIG_DEFAULT, MUSIG_SKIP, MUSIG_REQUIRE, MAX_SIGNERS)
from constants import MAX_MULTISIG_NAME_LEN
from exceptions import FatalPSBTIssue
from opcodes import OP_CHECKMULTISIG
Expand Down Expand Up @@ -159,7 +159,7 @@ def chain(self):
@classmethod
def get_trust_policy(cls):
from common import settings
return settings.get('multisig_policy', TRUST_DEFAULT)
return settings.get('multisig_policy', MUSIG_DEFAULT)

def serialize(self):
# return a JSON-able object
Expand Down Expand Up @@ -864,7 +864,7 @@ def import_from_psbt(cls, M, N, xpubs_list):
trust_mode = cls.get_trust_policy()
# print('import_from_psbt(): trust_mode = {}'.format(trust_mode))

if trust_mode == TRUST_VERIFY:
if trust_mode == MUSIG_REQUIRE:
# already checked for existing import and wasn't found, so fail
raise FatalPSBTIssue("XPUBs in PSBT do not match any existing wallet as required by multisig policy")

Expand Down Expand Up @@ -895,7 +895,7 @@ def import_from_psbt(cls, M, N, xpubs_list):

# may just keep just in-memory version, no approval required, if we are
# trusting PSBT's today, otherwise caller will need to handle UX w.r.t new wallet
return ms, (trust_mode != TRUST_PSBT)
return ms, (trust_mode != MUSIG_SKIP)

def validate_psbt_xpubs(self, xpubs_list):
# The xpubs provided in PSBT must be exactly right, compared to our record.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
# multisig_policy_setting_page.py - Set the multisig policy

from pages import SettingPage
from public_constants import TRUST_OFFER, TRUST_VERIFY, TRUST_PSBT, TRUST_DEFAULT
from public_constants import MUSIG_ASK, MUSIG_REQUIRE, MUSIG_SKIP, MUSIG_DEFAULT

# Chooser for trust policy
ch = ['Ask to Import', 'Require Existing', 'Skip Verification']
values = [TRUST_OFFER, TRUST_VERIFY, TRUST_PSBT]
values = [MUSIG_ASK, MUSIG_REQUIRE, MUSIG_SKIP]


class MultisigPolicySettingPage(SettingPage):
OPTIONS = [
{'label': 'Ask to Import', 'value': TRUST_OFFER},
{'label': 'Require Existing', 'value': TRUST_VERIFY},
{'label': 'Skip Verification', 'value': TRUST_PSBT},
{'label': 'Ask to Import', 'value': MUSIG_ASK},
{'label': 'Require Existing', 'value': MUSIG_REQUIRE},
{'label': 'Skip Verification', 'value': MUSIG_SKIP},
]

def __init__(self, card_header=None, statusbar=None):
Expand All @@ -24,4 +24,4 @@ def __init__(self, card_header=None, statusbar=None):
statusbar=statusbar,
setting_name='multisig_policy',
options=self.OPTIONS,
default_value=TRUST_DEFAULT)
default_value=MUSIG_DEFAULT)
8 changes: 4 additions & 4 deletions ports/stm32/boards/Passport/modules/public_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@
MAX_SIGNERS = const(15)

# PSBT Xpub trust policies
TRUST_VERIFY = const(0)
TRUST_OFFER = const(1)
TRUST_PSBT = const(2)
TRUST_DEFAULT = TRUST_OFFER
MUSIG_REQUIRE = const(0)
MUSIG_ASK = const(1)
MUSIG_SKIP = const(2)
MUSIG_DEFAULT = MUSIG_ASK

# Default Directories
DIR_BACKUPS = 'backups'
Expand Down

0 comments on commit 03c3737

Please sign in to comment.