Skip to content

Commit

Permalink
construction: implement derive
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-wh committed Jul 31, 2020
1 parent 41563b9 commit 215acd8
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions services/construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,23 @@ func (s *constructionAPIService) ConstructionDerive(
return nil, terr
}

// According to the Rosetta spec:
// Blockchains that require an on-chain action to create an account
// should not implement this method.
return nil, ErrNotImplemented
var pk signature.PublicKey
if err := pk.UnmarshalBinary(request.PublicKey.Bytes); err != nil {
loggerCons.Error("ConstructionDerive: malformed public key",
"public_key_hex_bytes", hex.EncodeToString(request.PublicKey.Bytes),
"err", err,
)
return nil, ErrMalformedValue
}

resp := &types.ConstructionDeriveResponse{
Address: staking.NewAddress(pk).String(),
}

jr, _ := json.Marshal(resp)
loggerCons.Debug("ConstructionDerive OK", "response", jr)

return resp, nil
}

// ConstructionCombine implements the /construction/combine endpoint.
Expand Down

0 comments on commit 215acd8

Please sign in to comment.