Skip to content

Infer relative derivation when parent key level > 0 #326

@Sjors

Description

@Sjors

The new bip32_key_from_parent_path_str function takes a path_str argument. When this starts with m/ it should strip the first depth levels from the path string. Currently it just treats everything as a relative path.

This would help me avoid a string manipulation workaround like this:

// Convert absolute path to relative:
var tmpPath = path
if path.split(separator: "/").first == "m" {
  tmpPath = path.split(separator: "/").dropFirst(1 + Int(self.wally_ext_key.depth)).joined(separator: "/")
}

It's especially useful in de context of PSBT processing, where the PSBT will have absolute paths, but the wallet may want to derive from a (cached) xpub to see if it can sign something, as well as for change detection.

Perhaps a flag could be added to (dis)allow the use of absolute paths when deriving from depth > 0 since that can lead to mistakes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions