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

Recovery File #55

Open
i5hi opened this issue Jun 27, 2024 · 4 comments
Open

Recovery File #55

i5hi opened this issue Jun 27, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@i5hi
Copy link
Collaborator

i5hi commented Jun 27, 2024

Code for recovery file for refunds for scripts are incomplete.

@i5hi i5hi added the enhancement New feature or request label Jun 28, 2024
@i5hi
Copy link
Collaborator Author

i5hi commented Jun 28, 2024

@michael1011 @jackstar12 Please share any relevant notes / types for this.

@i5hi
Copy link
Collaborator Author

i5hi commented Jun 28, 2024

This is what we currently have:

// Boltz standard JSON refund swap file. Can be used to create a file that can be uploaded to boltz.exchange
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RefundSwapFile {
    pub id: String,
    pub currency: String,
    pub redeem_script: String,
    pub private_key: String,
    pub timeout_block_height: u32,
}
impl RefundSwapFile {
    pub fn file_name(&self) -> String {
        format!("boltz-{}.json", self.id)
    }
    pub fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Error> {
        let mut full_path = PathBuf::from(path.as_ref());
        full_path.push(self.file_name());
        let mut file = File::create(&full_path)?;
        let json = serde_json::to_string_pretty(self)?;
        writeln!(file, "{}", json)?;
        Ok(())
    }
    pub fn read_from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
        let mut file = File::open(path)?;
        let mut contents = String::new();
        file.read_to_string(&mut contents)?;
        Ok(serde_json::from_str(&contents)?)
    }
}

@michael1011
Copy link
Collaborator

michael1011 commented Jul 1, 2024

@i5hi that's what our refund files for the web app look like:

{
  "id": "SUk5ZpvByr7T",
  "address": "lq1pqgvpgdd3l8r9r5872u6807995c3tjvng29uva6d4wjpeasnqwwrut7l957w7ywwaypn5zp309x6klalrk552avv04mhvg8lrxc8h3qr7syyar9ar4g0e",
  "swapTree": {
    "claimLeaf": {
      "version": 196,
      "output": "a9148016aecb6c365862c758abc506b7237b016e2cc38820262003a199ebba1632920977a38b156171e1b423b453b32c8e267ddf53fedb8eac"
    },
    "refundLeaf": {
      "version": 196,
      "output": "20b6f5bf61251d25e625fc9b1a4fd8782616ceba3b229ad80556c7223e7388bbcead039ec62cb1"
    }
  },
  "blindingKey": "44d827dc1be2e27cc077160861e1f895d4a424f653c0192e2917c193fb64d173",
  "claimPublicKey": "03262003a199ebba1632920977a38b156171e1b423b453b32c8e267ddf53fedb8e",
  "timeoutBlockHeight": 2934430,
  "type": "submarine",
  "assetSend": "L-BTC",
  "assetReceive": "BTC",
  "date": 1719830282064,
  "version": 3,
  "sendAmount": 52315,
  "receiveAmount": 52248,
  "refundPrivateKey": "1ec2e1d1d3a2f2e489e884092b378ad51e2a2be9b9f804c7878ce58b7909f2e0"
}

blindingKey can be omitted for BTC swaps

@i5hi
Copy link
Collaborator Author

i5hi commented Oct 2, 2024

additional information that would really help wallet users is key derivation paths used; it would deviate from the standard but they can be optional fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants