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

Generate address from output script #202

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

sekulicd
Copy link
Collaborator

This adds FromOutputScript func to the payment pkg which is supposed to create address from provided output script.

@tiero @altafan please review.

.golangci.yml Outdated Show resolved Hide resolved
@@ -373,3 +373,89 @@ func buildScript(hash []byte, scriptType string) []byte {
script, _ := builder.Script()
return script
}

func FromOutputScript(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should stay in address package and should not make use of the payment one, like a "raw" address builder.
The idea is to allow the user to retrieve and address from an output script with either address or payment. The former lacks such API, while the latter already provides the necessary ones.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thing is that if adding it to address pkg can use payment cause of cyclic import.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to say that this function should be moved to address and its implementation must change so that it doesn't make use of payment's types/functions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you don't look at the liquidjs-lib implementation, rather this function should analyze the incoming script to understand its type and encode it to an address using the proper format (base58, bech32...).
I would remove also the blinding key argument and return always an unconfidential address from an output script to keep it simple. The user can translate it to confidential with existing types and functions of the address package if needed.

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

Successfully merging this pull request may close these issues.

2 participants