From a1253e413a8909a16264fc0b3cd09d74d86a839c Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Mon, 11 Jan 2021 19:21:34 +0100 Subject: [PATCH 1/3] feat: set impossible lock_transfer_block_id after threshold reached to prevent wallet txs --- blockstack/blockstackd.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/blockstack/blockstackd.py b/blockstack/blockstackd.py index d68a5996031..0cd37d5b027 100644 --- a/blockstack/blockstackd.py +++ b/blockstack/blockstackd.py @@ -1423,7 +1423,7 @@ def export_account_state(self, account_state): """ Make an account state presentable to external consumers """ - return { + result = { 'address': account_state['address'], 'type': account_state['type'], 'credit_value': '{}'.format(account_state['credit_value']), @@ -1433,6 +1433,11 @@ def export_account_state(self, account_state): 'vtxindex': account_state['vtxindex'], 'txid': account_state['txid'], } + # if block height is after the migration export threshold, return a lock height that will force the wallet to error when sending a tx + if result['block_id'] >= 665750: + print log.warning('[v2-upgrade] Forcing lock_transfer_block_id to 9999999 to prevent wallet txs') + result['lock_transfer_block_id'] = 9999999 + return result def rpc_get_account_record(self, address, token_type, **con_info): From 34192b86c687dee77dd76697b4eb9102cb4b3f37 Mon Sep 17 00:00:00 2001 From: Aaron Blankstein Date: Mon, 11 Jan 2021 12:42:24 -0600 Subject: [PATCH 2/3] use IMPORT_HEIGHT from virtualchain_hooks --- blockstack/blockstackd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockstack/blockstackd.py b/blockstack/blockstackd.py index 0cd37d5b027..b074c977c5b 100644 --- a/blockstack/blockstackd.py +++ b/blockstack/blockstackd.py @@ -1434,7 +1434,7 @@ def export_account_state(self, account_state): 'txid': account_state['txid'], } # if block height is after the migration export threshold, return a lock height that will force the wallet to error when sending a tx - if result['block_id'] >= 665750: + if result['block_id'] >= virtualchain_hooks.IMPORT_HEIGHT: print log.warning('[v2-upgrade] Forcing lock_transfer_block_id to 9999999 to prevent wallet txs') result['lock_transfer_block_id'] = 9999999 return result From 1c1903aae5b16d5938b8a6a42f37cf596f2a5deb Mon Sep 17 00:00:00 2001 From: Aaron Blankstein Date: Mon, 11 Jan 2021 13:44:28 -0600 Subject: [PATCH 3/3] check db.lastblock, not account[block_id] --- blockstack/blockstackd.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/blockstack/blockstackd.py b/blockstack/blockstackd.py index b074c977c5b..8703b8c0fc6 100644 --- a/blockstack/blockstackd.py +++ b/blockstack/blockstackd.py @@ -1433,10 +1433,6 @@ def export_account_state(self, account_state): 'vtxindex': account_state['vtxindex'], 'txid': account_state['txid'], } - # if block height is after the migration export threshold, return a lock height that will force the wallet to error when sending a tx - if result['block_id'] >= virtualchain_hooks.IMPORT_HEIGHT: - print log.warning('[v2-upgrade] Forcing lock_transfer_block_id to 9999999 to prevent wallet txs') - result['lock_transfer_block_id'] = 9999999 return result @@ -1456,11 +1452,17 @@ def rpc_get_account_record(self, address, token_type, **con_info): db = get_db_state(self.working_dir) account = db.get_account(address, token_type) + last_block = db.lastblock db.close() if account is None: return {'error': 'No such account', 'http_status': 404} + # if block height is after the migration export threshold, return a lock height that will force the wallet to error when sending a tx + if last_block >= virtualchain_hooks.IMPORT_HEIGHT: + print log.warning('[v2-upgrade] Forcing lock_transfer_block_id to 9999999 to prevent wallet txs') + account['lock_transfer_block_id'] = 9999999 + state = self.export_account_state(account) return self.success_response({'account': state})