simulator nLockTime
This commit is contained in:
parent
7ff8342e01
commit
0ccd701421
@ -2,7 +2,7 @@
|
||||
#
|
||||
# ccc.py - ColdCard Cosign feature. Be a leg in a 2-of-3 that signed based on policy.
|
||||
#
|
||||
import gc, chains, version, ngu, web2fa, bip39, re
|
||||
import gc, chains, version, ngu, web2fa, bip39, re, ckcc
|
||||
from utils import swab32, a2b_hex, b2a_hex, xfp2str, truncate_address, pad_raw_secret
|
||||
from glob import settings
|
||||
from ux import ux_confirm, ux_show_story, the_ux, OK, ux_dramatic_pause, ux_enter_number
|
||||
@ -77,7 +77,9 @@ class CCCFeature:
|
||||
def default_policy(cls):
|
||||
# a very basic an permissive policy, but non-zero too.
|
||||
# - 1BTC per day
|
||||
return dict(mag=1, vel=144, block_h=0, web2fa='', addrs=[])
|
||||
chain = chains.current_chain()
|
||||
return dict(mag=1, vel=144, block_h=chain.CCC_MIN_BLOCK,
|
||||
web2fa='', addrs=[])
|
||||
|
||||
@classmethod
|
||||
def get_policy(cls):
|
||||
@ -139,7 +141,7 @@ class CCCFeature:
|
||||
# this is unix timestamp - not allowed - fail
|
||||
raise CCCPolicyViolationError("nLockTime not block height")
|
||||
|
||||
block_h = pol.get("block_h", 0) or 865321
|
||||
block_h = pol.get("block_h", chains.current_chain().CCC_MIN_BLOCK)
|
||||
if psbt.lock_time <= block_h:
|
||||
raise CCCPolicyViolationError("rewound")
|
||||
|
||||
|
||||
@ -32,6 +32,9 @@ Slip132Version = namedtuple('Slip132Version', ('pub', 'priv', 'hint'))
|
||||
class ChainsBase:
|
||||
|
||||
curve = 'secp256k1'
|
||||
menu_name = None # use 'name' if this isn't defined
|
||||
core_name = None # name of chain's "core" p2p software
|
||||
CCC_MIN_BLOCK = 0
|
||||
|
||||
# b44_cointype comes from
|
||||
# <https://github.com/satoshilabs/slips/blob/master/slip-0044.md>
|
||||
@ -292,6 +295,7 @@ class BitcoinMain(ChainsBase):
|
||||
# see <https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp#L140>
|
||||
ctype = 'BTC'
|
||||
name = 'Bitcoin Mainnet'
|
||||
CCC_MIN_BLOCK = 865572
|
||||
|
||||
slip132 = {
|
||||
AF_CLASSIC: Slip132Version(0x0488B21E, 0x0488ADE4, 'x'),
|
||||
@ -309,7 +313,7 @@ class BitcoinMain(ChainsBase):
|
||||
|
||||
b44_cointype = 0
|
||||
|
||||
class BitcoinTestnet(BitcoinMain):
|
||||
class BitcoinTestnet(ChainsBase):
|
||||
# testnet4 (was testnet3 up until 2025 but all parameters are the same)
|
||||
ctype = 'XTN'
|
||||
name = 'Bitcoin Testnet 4'
|
||||
@ -331,7 +335,7 @@ class BitcoinTestnet(BitcoinMain):
|
||||
b44_cointype = 1
|
||||
|
||||
|
||||
class BitcoinRegtest(BitcoinMain):
|
||||
class BitcoinRegtest(ChainsBase):
|
||||
ctype = 'XRT'
|
||||
name = 'Bitcoin Regtest'
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user