Skip to content

Commit

Permalink
fix: bbqr now uses correct file type for psbt and txn, use zlib encod…
Browse files Browse the repository at this point in the history
…ing instead of hex.
  • Loading branch information
Fonta1n3 committed Jul 11, 2024
1 parent 4fbda78 commit d745288
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 21 deletions.
4 changes: 2 additions & 2 deletions FullyNoded.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.485;
MARKETING_VERSION = 1.487;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.fontaine.FullyNoded;
"PRODUCT_BUNDLE_IDENTIFIER[sdk=macosx*]" = com.fontaine.fullynodedmacos;
Expand Down Expand Up @@ -1590,7 +1590,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.485;
MARKETING_VERSION = 1.487;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.fontaine.FullyNoded;
"PRODUCT_BUNDLE_IDENTIFIER[sdk=macosx*]" = com.fontaine.fullynodedmacos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "015ca1eace5e197d26c87a84df1e35989789fbbf4144fff38fe5fff9341c36a2",
"originHash" : "dbc57cb905ea6d2c86cdcb51ff9b9cf19432f8eab192b534539f6a1f065226c0",
"pins" : [
{
"identity" : "bbqr-swift",
Expand Down
4 changes: 2 additions & 2 deletions FullyNoded/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -4453,7 +4453,7 @@ You can upload the wallets.fullynoded file that was created when you made the ba
</objects>
<point key="canvasLocation" x="2718" y="376"/>
</scene>
<!--v1.1.1-->
<!--v1.1.2-->
<scene sceneID="Ajv-p7-tUm">
<objects>
<viewController extendedLayoutIncludesOpaqueBars="YES" id="AS8-ke-Yxh" customClass="SettingsViewController" customModule="FullyNoded" customModuleProvider="target" sceneMemberID="viewController">
Expand Down Expand Up @@ -4694,7 +4694,7 @@ You can upload the wallets.fullynoded file that was created when you made the ba
</constraints>
</view>
<tabBarItem key="tabBarItem" title="" image="Settings" id="n34-O3-Fyo"/>
<navigationItem key="navigationItem" title="v1.1.1" id="YNb-Gd-Hqq"/>
<navigationItem key="navigationItem" title="v1.1.2" id="YNb-Gd-Hqq"/>
<connections>
<outlet property="settingsTable" destination="hcp-eG-lok" id="xPg-8r-KBs"/>
<segue destination="bKH-sI-MiM" kind="show" identifier="goLogIn" id="qed-hl-jG5"/>
Expand Down
43 changes: 34 additions & 9 deletions FullyNoded/View Controllers/QRDisplayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class QRDisplayerViewController: UIViewController {

var text = ""
var psbt = ""
var txn = ""
var tapQRGesture = UITapGestureRecognizer()
var tapTextViewGesture = UITapGestureRecognizer()
var headerText = ""
Expand Down Expand Up @@ -48,12 +49,23 @@ class QRDisplayerViewController: UIViewController {
animateOutlet.alpha = 0

if isBbqr {
guard let parts = try? split(string: text == "" ? psbt : text) else {
return
var parts: [String]? = []

if psbt != "" {
parts = try? split(string: psbt)
}

showBbqrParts(bbQrparts: parts)
if txn != "" {
parts = try? split(string: txn)
}

if text != "" {
parts = try? split(string: text)
}

if let parts = parts {
showBbqrParts(bbQrparts: parts)
}
} else if psbt != "" {
animateOutlet.alpha = 0
spinner.addConnectingView(vc: self, description: "loading QR parts...")
Expand All @@ -70,7 +82,11 @@ class QRDisplayerViewController: UIViewController {
animateOutlet.alpha = 1
}

imageView.image = qR()
if txn != "" {
imageView.image = qR(text: txn)
} else if text != "" {
imageView.image = qR(text: text)
}
}
}

Expand All @@ -79,10 +95,19 @@ class QRDisplayerViewController: UIViewController {

// EXAMPLE DEFAULT OPTIONS
// let options = defaultSplitOptions()
// let options = SplitOptions(encoding: Encoding.zlib, minVersion: Version.v01, maxVersion: Version.v40)
let options = SplitOptions(encoding: Encoding.zlib, minVersion: Version.v01, maxVersion: Version.v40)
var fileType: FileType = .unicodeText

if psbt != "" {
fileType = .psbt
}

if txn != "" {
fileType = .transaction
}

let options = SplitOptions(encoding: Encoding.hex, minVersion: Version.v01, maxVersion: Version.v02)
let split = try Split.tryFromData(bytes: large, fileType: FileType.unicodeText, options: options)
//let options = SplitOptions(encoding: Encoding.hex, minVersion: Version.v01, maxVersion: Version.v02)
let split = try Split.tryFromData(bytes: large, fileType: fileType, options: options)

return split.parts()
}
Expand All @@ -101,7 +126,7 @@ class QRDisplayerViewController: UIViewController {
}
}

private func qR() -> UIImage {
private func qR(text: String) -> UIImage {
qrGenerator.textInput = text
return qrGenerator.getQRCode()
}
Expand Down Expand Up @@ -158,7 +183,7 @@ class QRDisplayerViewController: UIViewController {
}

private func showBbqrParts(bbQrparts: [String]) {
let timer = Timer.scheduledTimer(withTimeInterval: 0.3, repeats: true) { [weak self] _ in
let _ = Timer.scheduledTimer(withTimeInterval: 0.3, repeats: true) { [weak self] _ in
guard let self = self else { return }

if partIndex < bbQrparts.count {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2686,7 +2686,7 @@ class VerifyTransactionViewController: UIViewController, UINavigationControllerD
}
}

if segue.identifier == "segueToExportPsbtAsQr" {
if segue.identifier == "segueToExportPsbtAsQr" {
if let vc = segue.destination as? QRDisplayerViewController {
vc.isBbqr = self.isBBQr

Expand All @@ -2706,7 +2706,7 @@ class VerifyTransactionViewController: UIViewController, UINavigationControllerD
vc.descriptionText = "This psbt still needs more signatures to be complete, you can share it with another signer."
}
} else if signedRawTx != "" {
vc.text = signedRawTx
vc.txn = signedRawTx
vc.headerIcon = UIImage(systemName: "square.and.arrow.up")
vc.headerText = "Signed Transaction"
vc.descriptionText = "You can save this signed transaction and broadcast it later or share it with someone else."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CreateMultisigViewController: UIViewController, UITextViewDelegate, UIText
var alertStyle = UIAlertController.Style.alert
var multiSigAccountDesc = ""
var qrToExport = ""
var isBbqr = false

@IBOutlet weak var derivationField: UITextField!
@IBOutlet weak var fingerprintField: UITextField!
Expand Down Expand Up @@ -317,7 +318,7 @@ class CreateMultisigViewController: UIViewController, UITextViewDelegate, UIText
self.export(text: text)
}))

alert.addAction(UIAlertAction(title: "Export QR Code (Passport, Sparrow, Blue)", style: .default, handler: { action in
alert.addAction(UIAlertAction(title: "Export UR QR Code", style: .default, handler: { action in
guard let ur = URHelper.dataToUrBytes(text.utf8) else {
showAlert(vc: self, title: "Error", message: "Unable to convert the text into a UR.")
return
Expand All @@ -332,6 +333,17 @@ class CreateMultisigViewController: UIViewController, UITextViewDelegate, UIText
}
}))

alert.addAction(UIAlertAction(title: "Export BBQr", style: .default, handler: { action in
self.qrToExport = text
self.isBbqr = true

DispatchQueue.main.async { [weak self] in
guard let self = self else { return }

self.performSegue(withIdentifier: "segueToExportMsig", sender: self)
}
}))

alert.addAction(UIAlertAction(title: "Done", style: .default, handler: { action in
DispatchQueue.main.async {
NotificationCenter.default.post(name: .refreshWallet, object: nil, userInfo: nil)
Expand Down Expand Up @@ -622,11 +634,15 @@ class CreateMultisigViewController: UIViewController, UITextViewDelegate, UIText
case "segueToExportMsig":
guard let vc = segue.destination as? QRDisplayerViewController else { return }

vc.psbt = self.qrToExport
print("qrToExport: \(qrToExport)")
vc.text = self.qrToExport
vc.isBbqr = self.isBbqr
vc.headerIcon = UIImage(systemName: "square.and.arrow.up")
vc.headerText = "Multisig Wallet Export"
vc.descriptionText = "Scan this with Passport, Blue Wallet, Sparrow or other wallets which support UR QR to import the multisig wallet."

if isBbqr {
vc.headerText = "Multisig Wallet BBQr"
} else {
vc.headerText = "Multisig Wallet UR Bytes"
}

default:
break
Expand Down

0 comments on commit d745288

Please sign in to comment.