Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquid: support issuance and reissuance transactions #201

Merged
merged 3 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions hwidevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,18 @@ def enumerate(password=""):
for port in serial.tools.list_ports.comports()
if is_micropython(port)
]
try:
# check if there is a simulator on port 8789
# and we can connect to it
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", 8789))
s.close()
ports.append("127.0.0.1:8789")
except Exception as e:
print(e)
pass
for i in range(10):
try:
# check if there is a simulator on port 8789
# and we can connect to it
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 8789+i
s.connect(("127.0.0.1", port))
s.close()
ports.append("127.0.0.1:%d" % port)
except Exception as e:
print(e)
pass

for port in ports:
# for every port try to get a fingerprint
Expand Down
15 changes: 12 additions & 3 deletions src/apps/wallets/liquid/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async def confirm_transaction(self, wallets, meta, show_screen):
# ask the user to label assets
await self.check_unknown_assets(meta, show_screen)

return await super().confirm_transaction(wallets,meta, show_screen)
return await super().confirm_transaction(wallets, meta, show_screen)


async def check_unknown_assets(self, meta, show_screen):
Expand Down Expand Up @@ -231,16 +231,18 @@ async def confirm_transaction_final(self, wallets, meta, show_screen):
spend = ", ".join("%s %s" % ("???" if val < 0 else "%.8f" % (val/1e8), self.asset_label(asset)) for asset, val in amount.items())
spends.append('%s\nfrom "%s"' % (spend, name))
title = "Inputs:\n" + "\n".join(spends)
if meta.get("issuance", False):
title = "Issuance transaction"
if meta.get("reissuance", False):
title = "Reissuance transaction"
return await show_screen(TransactionScreen(title, meta))

def preprocess_psbt(self, stream, fout):
"""
Processes incoming PSBT, fills missing information and writes to fout.
Returns:
- PSBTView class to use (PSBTView or PSETView)
- wallets in inputs: list of tuples (wallet, amount)
- metadata for tx display including warnings that require user confirmation
- default sighash to use for signing
"""
self.show_loader(title="Parsing transaction...")

Expand Down Expand Up @@ -270,6 +272,7 @@ def preprocess_psbt(self, stream, fout):
meta = {
"inputs": [{} for i in range(psbtv.num_inputs)],
"outputs": [{} for i in range(psbtv.num_outputs)],
"issuance": False, "reissuance": False,
}

fingerprint = self.keystore.fingerprint
Expand All @@ -291,6 +294,12 @@ def preprocess_psbt(self, stream, fout):
if inp.sighash_type is not None and inp.sighash_type != self.DEFAULT_SIGHASH:
metainp["sighash"] = self.get_sighash_info(inp.sighash_type)["name"]

if inp.issue_value:
if inp.issue_entropy:
meta["reissuance"] = True
else:
meta["issuance"] = True

# in Liquid we may need to rewind the rangeproof to get values
rangeproof_offset = None

Expand Down
1 change: 0 additions & 1 deletion src/apps/wallets/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ def preprocess_psbt(self, stream, fout):
Returns:
- wallets in inputs: dict {wallet: amount}
- metadata for tx display including warnings that require user confirmation
- default sighash to use for signing
"""
self.show_loader(title="Parsing transaction...")

Expand Down
5 changes: 4 additions & 1 deletion src/config_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
# to overwrite these settings create a config.py file

if simulator:
storage_root = "./fs"
if len(sys.argv) > 1:
storage_root = sys.argv[1]
else:
storage_root = "./fs"
try:
os.mkdir(storage_root)
except:
Expand Down
1 change: 1 addition & 0 deletions src/gui/screens/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, title, meta):
enable_inputs = len([k for k in meta["inputs"] if k.get("sighash", "")]) > 0
# if there is at least one unknown value (liquid)
enable_inputs = enable_inputs or (-1 in [out["value"] for out in meta["outputs"]])
enable_inputs = enable_inputs or meta.get("issuance", False) or meta.get("reissuance", False)

lbl = add_label("Show detailed information ", scr=self)
lbl.align(obj, lv.ALIGN.CENTER, 0, 0)
Expand Down
1 change: 1 addition & 0 deletions src/specter.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ async def select_network(self):
("test", "Testnet"),
("signet", "Signet"),
("regtest", "Regtest"),
("liquidtestnet", "Liquid Testnet"),
("elementsregtest", "Liquid Regtest"),
]
# wait for menu selection
Expand Down