Skip to content

Commit

Permalink
feat: Lotus Send CLI: Lotus send should work with ETH address receipi…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
vladmair committed Oct 15, 2024
1 parent 8f3035f commit 81e82cb
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions cmd/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,25 @@ var msgSendCmd = &cmds.Command{
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
ctx := req.Context

is0xRecipient := false
toAddr, err := address.NewFromString(req.Arguments[0])
if err != nil {
return err
// could be an ETH address
ea, err := types.ParseEthAddress(req.Arguments[0])
if err != nil {
return err
}
is0xRecipient = true
// this will be either "f410f..." or "f0..."
toAddr, err = ea.ToFilecoinAddress()
if err != nil {
return err
}
// ideally, this should never happen
if !(toAddr.Protocol() == address.ID || toAddr.Protocol() == address.Delegated) {
return err
}

}
v := req.Arguments[1]
val, err := types.ParseFIL(v)
Expand Down Expand Up @@ -131,7 +147,7 @@ var msgSendCmd = &cmds.Command{

methodID := builtin.MethodSend
method := req.Options["method"]
if types.IsEthAddress(fromAddr) {
if types.IsEthAddress(fromAddr) || is0xRecipient {
// Method numbers don't make sense from eth accounts.
if method != nil {
return fmt.Errorf("messages from f410f addresses may not specify a method number")
Expand Down

0 comments on commit 81e82cb

Please sign in to comment.