-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
lotus-fountain: make compatible with 0x addresses #10560 #10784
Conversation
cmd/lotus-fountain/main.go
Outdated
} | ||
to = filecoinAddress | ||
} else { | ||
filecoinAddress, err := address.NewFromString(r.FormValue("address")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filecoinAddress, err := address.NewFromString(r.FormValue("address")) | |
filecoinAddress, err := address.NewFromString(addressInput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot, will merge into the commit.
cmd/lotus-fountain/main.go
Outdated
http.Error(w, err.Error(), http.StatusBadRequest) | ||
return | ||
} | ||
to = filecoinAddress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to skip the check for empty address with checking filecoinAddress == address.Undef like when its not a 0x address? Can we make the checks for both scenarios the same and maybe refactor the code a bit to use the same error checking code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToFilecoinAddress
can return address.Undef
but in such case it also returns error
so it's not strictly needed because the error is checked here. The point about having the same error handling is legit, will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fridrik01 Is this the way to go in Go 6c25f21 ? 🙂
3bee767
to
6c25f21
Compare
cmd/lotus-fountain/main.go
Outdated
@@ -193,12 +195,30 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
return | |||
} | |||
|
|||
to, err := address.NewFromString(r.FormValue("address")) | |||
if err != nil { | |||
var to address.Address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not setting this anywhere, and using for the send destination, probably want to remove this var, and swap uses of to
to filecoinAddress
6c25f21
to
08e6e04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Related Issues
Closes #10560
Proposed Changes
Check if address starts with
Ox
. If so, parse it as Eth address. Otherwise, use the previous logic.